Skip to content

Commit

Permalink
Fixed PDF media calculations issue
Browse files Browse the repository at this point in the history
Resolved the problem with PDF media calculations that was causing blank pages in the rendered PDF.
  • Loading branch information
jhabjan authored Sep 29, 2023
1 parent 814b25e commit 1e27dc0
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
//
// GhostscriptViewerPdfFormatHandler.cs
// This file is part of Ghostscript.NET library
//
// Author: Josip Habjan ([email protected], http://www.linkedin.com/in/habjan)
// Copyright (c) 2013-2021 by Josip Habjan. All rights reserved.
// Copyright (c) 2013-2023 by Josip Habjan. All rights reserved.
//
// Author ported some parts of this code from GSView.
//
Expand Down Expand Up @@ -265,7 +265,7 @@ public override void StdOutput(string message)

public override void StdError(string message)
{

System.Diagnostics.Debug.WriteLine($"GS:StdError > {message}");
}

#endregion
Expand All @@ -277,10 +277,15 @@ public override void InitPage(int pageNumber)
if (pageNumber >= this.FirstPageNumber && pageNumber <= this.LastPageNumber)
{
this.Execute(string.Format("{0} GSNETViewer_PDFpage", pageNumber));

if (this.Viewer.Interpreter.LibraryRevision >= 10010)
{
this.Execute("Page pdfshowpage_init");
}
}
else
{
throw new GhostscriptException("Page number is not in pages number range!");
throw new GhostscriptException("The page number falls outside the range of valid page numbers!");
}
}

Expand All @@ -292,11 +297,18 @@ public override void ShowPage(int pageNumber)
{
if (pageNumber >= this.FirstPageNumber && pageNumber <= this.LastPageNumber)
{
this.Execute("Page pdfshowpage");
if (this.Viewer.Interpreter.LibraryRevision >= 10010)
{
this.Execute("Page pdfshowpage_finish");
}
else
{
this.Execute("Page pdfshowpage");
}
}
else
{
throw new GhostscriptException("Page number is not in pages number range!");
throw new GhostscriptException("The page number falls outside the range of valid page numbers!");
}
}

Expand Down

0 comments on commit 1e27dc0

Please sign in to comment.