Skip to content

Commit 76b27f5

Browse files
committed
fixed Ghostscript v.9.50+ compatibility issues
1 parent e496e79 commit 76b27f5

File tree

14 files changed

+124
-26
lines changed

14 files changed

+124
-26
lines changed

Ghostscript.NET.DisplayTest/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.2")]
36-
[assembly: AssemblyFileVersion("1.2.2")]
35+
[assembly: AssemblyVersion("1.2.3")]
36+
[assembly: AssemblyFileVersion("1.2.3")]

Ghostscript.NET.Samples/Ghostscript.NET.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</SccProvider>
2525
</PropertyGroup>
2626
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
27-
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<PlatformTarget>x64</PlatformTarget>
2828
<DebugSymbols>true</DebugSymbols>
2929
<DebugType>full</DebugType>
3030
<Optimize>false</Optimize>

Ghostscript.NET.Samples/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.2")]
36-
[assembly: AssemblyFileVersion("1.2.2")]
35+
[assembly: AssemblyVersion("1.2.3")]
36+
[assembly: AssemblyFileVersion("1.2.3")]

Ghostscript.NET.Samples/Samples/RasterizerSample1.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
// required Ghostscript.NET namespaces
2828
using System;
29-
using System.Collections;
30-
using System.Collections.Generic;
3129
using System.Drawing.Imaging;
3230
using System.IO;
3331
using Ghostscript.NET.Rasterizer;
@@ -52,12 +50,14 @@ public void Sample1()
5250
{
5351
int desired_dpi = 96;
5452

55-
string inputPdfPath = @"E:\gss_test\test\a.pdf";
53+
string inputPdfPath = @"E:\gss_test\test.pdf";
5654
string outputPath = @"E:\gss_test\output\";
5755

56+
GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(@"C:\Program Files\gs\gs9.53.3\bin\gsdll64.dll");
57+
5858
using (var rasterizer = new GhostscriptRasterizer())
5959
{
60-
rasterizer.Open(inputPdfPath);
60+
rasterizer.Open(inputPdfPath, gvi, false);
6161

6262
for (var pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++)
6363
{

Ghostscript.NET.Viewer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.2")]
36-
[assembly: AssemblyFileVersion("1.2.2")]
35+
[assembly: AssemblyVersion("1.2.3")]
36+
[assembly: AssemblyFileVersion("1.2.3")]

Ghostscript.NET/GhostscriptDisplayDeviceHandler.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,33 @@ public abstract class GhostscriptDisplayDeviceHandler
3939

4040
internal display_callback _callback;
4141

42+
internal GhostscriptLibrary _gs;
43+
4244
#endregion
4345

4446
#region Constructor
4547

4648
/// <summary>
4749
/// Initializes a new instance of the Ghostscript.NET.GhostscriptDisplayDeviceHandler class.
4850
/// </summary>
49-
public GhostscriptDisplayDeviceHandler()
51+
public GhostscriptDisplayDeviceHandler(GhostscriptLibrary gs)
5052
{
51-
_callback = new display_callback();
52-
53-
_callback.size = Marshal.SizeOf(_callback);
54-
55-
_callback.version_minor = gdevdsp.DISPLAY_VERSION_MINOR;
56-
_callback.version_major = gdevdsp.DISPLAY_VERSION_MAJOR;
53+
_gs = gs;
54+
55+
if (gs.Revision > 951)
56+
{
57+
_callback = new display_callback_v3();
58+
_callback.version_minor = gdevdsp.DISPLAY_VERSION_MINOR_V3;
59+
_callback.version_major = gdevdsp.DISPLAY_VERSION_MAJOR_V3;
60+
_callback.size = Marshal.SizeOf(typeof(display_callback_v3));
61+
}
62+
else
63+
{
64+
_callback = new display_callback();
65+
_callback.version_minor = gdevdsp.DISPLAY_VERSION_MINOR_V2;
66+
_callback.version_major = gdevdsp.DISPLAY_VERSION_MAJOR_V2;
67+
_callback.size = Marshal.SizeOf(typeof(display_callback));
68+
}
5769

5870
_callback.display_open = new display_open_callback(display_open);
5971
_callback.display_preclose = new display_preclose_callback(display_preclose);

Ghostscript.NET/Interpreter/GhostscriptInterpreter.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,14 @@ public int LibraryRevision
428428

429429
#endregion
430430

431+
#region GhostscriptLibrary
432+
433+
public GhostscriptLibrary GhostscriptLibrary
434+
{
435+
get { return _gs; }
436+
}
437+
438+
#endregion
439+
431440
}
432441
}

Ghostscript.NET/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
[assembly: Guid("5b1fe89e-e040-4b7a-9c05-478c1756b6e8")]
1717

1818

19-
[assembly: AssemblyVersion("1.2.2")]
20-
[assembly: AssemblyFileVersion("1.2.2")]
19+
[assembly: AssemblyVersion("1.2.3")]
20+
[assembly: AssemblyFileVersion("1.2.3")]

Ghostscript.NET/Viewer/FormatHandlers/GhostscriptViewerPdfFormatHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ public override void Open(string filePath)
120120
{
121121
throw new GhostscriptException("IO error for file: '" + filePath + "'", ierrors.e_ioerror);
122122
}
123+
else if (res == ierrors.e_invalidfileaccess)
124+
{
125+
throw new GhostscriptException("IO security problem (access control failure) for file: '" + filePath + "'", ierrors.e_ioerror);
126+
}
123127

124128
this.Execute("/FirstPage where { pop FirstPage } { 1 } ifelse");
125129
this.Execute("/LastPage where { pop LastPage } { pdfpagecount } ifelse");

Ghostscript.NET/Viewer/GhostscriptViewer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ private void Open()
384384
(int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());
385385

386386

387+
if (_interpreter.LibraryRevision > 950)
388+
{
389+
args.Add("--permit-file-read=" + _filePath);
390+
}
387391

388392
args.Add("-dDOINTERPOLATE");
389393
args.Add("-dGridFitTT=0");

0 commit comments

Comments
 (0)