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

Should be able to render both annotations and form fields #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
26 changes: 19 additions & 7 deletions PdfiumViewer/PdfDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,6 @@ private PdfDocument(Stream stream, string password)
PageSizes = new ReadOnlyCollection<SizeF>(_pageSizes);
}

/// <summary>
/// Renders a page of the PDF document to the provided graphics instance.
/// </summary>
/// <param name="page">Number of the page to render.</param>
/// <param name="graphics">Graphics instance to render the page on.</param>
/// <param name="dpiX">Horizontal DPI.</param>
/// <param name="dpiY">Vertical DPI.</param>
/// <param name="bounds">Bounds to render the page in.</param>
Expand Down Expand Up @@ -289,7 +284,7 @@ public Image Render(int page, int width, int height, float dpiX, float dpiY, boo
/// <returns>The rendered image.</returns>
public Image Render(int page, int width, int height, float dpiX, float dpiY, PdfRenderFlags flags)
{
return Render(page, width, height, dpiX, dpiY, 0, flags);
return Render(page, width, height, dpiX, dpiY, 0, flags & ~PdfRenderFlags.Annotations, (flags & PdfRenderFlags.Annotations) != 0);
}

/// <summary>
Expand All @@ -304,6 +299,23 @@ public Image Render(int page, int width, int height, float dpiX, float dpiY, Pdf
/// <param name="flags">Flags used to influence the rendering.</param>
/// <returns>The rendered image.</returns>
public Image Render(int page, int width, int height, float dpiX, float dpiY, PdfRotation rotate, PdfRenderFlags flags)
{
return Render(page, width, height, dpiX, dpiY, rotate, flags, false);
}

/// <summary>
/// Renders a page of the PDF document to an image.
/// </summary>
/// <param name="page">Number of the page to render.</param>
/// <param name="width">Width of the rendered image.</param>
/// <param name="height">Height of the rendered image.</param>
/// <param name="dpiX">Horizontal DPI.</param>
/// <param name="dpiY">Vertical DPI.</param>
/// <param name="rotate">Rotation.</param>
/// <param name="flags">Flags used to influence the rendering.</param>
/// <param name="drawFormFields">Draw form fields.</param>
/// <returns>The rendered image.</returns>
public Image Render(int page, int width, int height, float dpiX, float dpiY, PdfRotation rotate, PdfRenderFlags flags, bool drawFormFields)
{
if (_disposed)
throw new ObjectDisposedException(GetType().Name);
Expand Down Expand Up @@ -336,7 +348,7 @@ public Image Render(int page, int width, int height, float dpiX, float dpiY, Pdf
0, 0, width, height,
(int)rotate,
FlagsToFPDFFlags(flags),
(flags & PdfRenderFlags.Annotations) != 0
drawFormFields
);

if (!success)
Expand Down
3 changes: 0 additions & 3 deletions PdfiumViewer/PdfFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public bool RenderPDFPageToBitmap(int pageNumber, IntPtr bitmapHandle, int dpiX,

using (var pageData = new PageData(_document, _form, pageNumber))
{
if (renderFormFill)
flags &= ~NativeMethods.FPDF.ANNOT;

NativeMethods.FPDF_RenderPageBitmap(bitmapHandle, pageData.Page, boundsOriginX, boundsOriginY, boundsWidth, boundsHeight, rotate, flags);

if (renderFormFill)
Expand Down