Skip to content

Commit 1e27dc0

Browse files
authored
Fixed PDF media calculations issue
Resolved the problem with PDF media calculations that was causing blank pages in the rendered PDF.
1 parent 814b25e commit 1e27dc0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Ghostscript.NET/Viewer/FormatHandlers/GhostscriptViewerPdfFormatHandler.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//
1+
//
22
// GhostscriptViewerPdfFormatHandler.cs
33
// This file is part of Ghostscript.NET library
44
//
55
// Author: Josip Habjan ([email protected], http://www.linkedin.com/in/habjan)
6-
// Copyright (c) 2013-2021 by Josip Habjan. All rights reserved.
6+
// Copyright (c) 2013-2023 by Josip Habjan. All rights reserved.
77
//
88
// Author ported some parts of this code from GSView.
99
//
@@ -265,7 +265,7 @@ public override void StdOutput(string message)
265265

266266
public override void StdError(string message)
267267
{
268-
268+
System.Diagnostics.Debug.WriteLine($"GS:StdError > {message}");
269269
}
270270

271271
#endregion
@@ -277,10 +277,15 @@ public override void InitPage(int pageNumber)
277277
if (pageNumber >= this.FirstPageNumber && pageNumber <= this.LastPageNumber)
278278
{
279279
this.Execute(string.Format("{0} GSNETViewer_PDFpage", pageNumber));
280+
281+
if (this.Viewer.Interpreter.LibraryRevision >= 10010)
282+
{
283+
this.Execute("Page pdfshowpage_init");
284+
}
280285
}
281286
else
282287
{
283-
throw new GhostscriptException("Page number is not in pages number range!");
288+
throw new GhostscriptException("The page number falls outside the range of valid page numbers!");
284289
}
285290
}
286291

@@ -292,11 +297,18 @@ public override void ShowPage(int pageNumber)
292297
{
293298
if (pageNumber >= this.FirstPageNumber && pageNumber <= this.LastPageNumber)
294299
{
295-
this.Execute("Page pdfshowpage");
300+
if (this.Viewer.Interpreter.LibraryRevision >= 10010)
301+
{
302+
this.Execute("Page pdfshowpage_finish");
303+
}
304+
else
305+
{
306+
this.Execute("Page pdfshowpage");
307+
}
296308
}
297309
else
298310
{
299-
throw new GhostscriptException("Page number is not in pages number range!");
311+
throw new GhostscriptException("The page number falls outside the range of valid page numbers!");
300312
}
301313
}
302314

0 commit comments

Comments
 (0)