Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Fixed the blank space at the end of PDF file which has 1500 pages. #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions PdfiumViewer/PdfRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class PdfRenderer : PanningZoomingScrollControl
{
private static readonly Padding PageMargin = new Padding(4);

private int _height;
private int _maxWidth;
private int _maxHeight;
private double _documentScaleFactor;
Expand Down Expand Up @@ -404,14 +403,12 @@ public void Load(IPdfDocument document)

private void ReloadDocument()
{
_height = 0;
_maxWidth = 0;
_maxHeight = 0;

foreach (var size in Document.PageSizes)
{
var translated = TranslateSize(size);
_height += (int)translated.Height;
_maxWidth = Math.Max((int)translated.Width, _maxWidth);
_maxHeight = Math.Max((int)translated.Height, _maxHeight);
}
Expand Down Expand Up @@ -678,7 +675,14 @@ private void DrawPageImage(Graphics graphics, int page, Rectangle pageBounds)
/// <returns>The document bounds.</returns>
protected override Rectangle GetDocumentBounds()
{
int height = (int)(_height * _scaleFactor + (ShadeBorder.Size.Vertical + PageMargin.Vertical) * Document.PageCount);
int scaledHeight = 0;
for (int page = 0; page < Document.PageSizes.Count; page++)
{
var size = TranslateSize(Document.PageSizes[page]);
scaledHeight += (int)(size.Height * _scaleFactor);
}

int height = (int)(scaledHeight + (ShadeBorder.Size.Vertical + PageMargin.Vertical) * Document.PageCount);
int width = (int)(_maxWidth * _scaleFactor + ShadeBorder.Size.Horizontal + PageMargin.Horizontal);

var center = new Point(
Expand Down