PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Flattening a PDF doc
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3369
Page 1 of 1

Author:  devling [ Sat May 28, 2016 12:23 am ]
Post subject:  Flattening a PDF doc

Using PDF Sharp, i was able to parse over 600 records into multiple billing statements but when I open the PDF it shows blue areas where the data is - thus clicking on field will reveal the data.

I suspect what I need to do is flatten and or disable the fields the document before saving it.

I'm sure PDFSharp has this but I'm not seeing it..

Author:  (void) [ Mon Jun 13, 2016 5:34 pm ]
Post subject:  Re: Flattening a PDF doc

I recently made some progress implementing this in v1.32 of PdfSharp and merged the changes into the 1.50 version
(please see attached .patch file)

As it works "OK" in v1.32, i had no chance to test this with 1.50, so consider this "experimental".
But it should give you something to start with...

Usage is pretty simple:

Code:
var doc = PdfReader.Open("myForm.pdf", PdfDocumentOpenMode.Modify);
if (doc.AcroForm != null)
    doc.AcroForm.Flatten();   // NOTE: doc.AcroForm is null after flattening !


Attachments:
File comment: PdfSharp 1.50 patch file
FormFlattening.zip [9.56 KiB]
Downloaded 892 times

Author:  devling [ Mon Jun 13, 2016 8:57 pm ]
Post subject:  Re: Flattening a PDF doc

Thank you - how is this patch applied via Visual Studio?

(void) wrote:
I recently made some progress implementing this in v1.32 of PdfSharp and merged the changes into the 1.50 version
(please see attached .patch file)

As it works "OK" in v1.32, i had no chance to test this with 1.50, so consider this "experimental".
But it should give you something to start with...

Usage is pretty simple:

Code:
var doc = PdfReader.Open("myForm.pdf", PdfDocumentOpenMode.Modify);
if (doc.AcroForm != null)
    doc.AcroForm.Flatten();   // NOTE: doc.AcroForm is null after flattening !

Author:  (void) [ Tue Jun 14, 2016 9:12 am ]
Post subject:  Re: Flattening a PDF doc

The patch was created with Tortoise SVN.
I recommend installing Tortoise SVN and create a local repository.
Import PdfSharp to your repository and then check it out, so the files are versioned.

In the directory, where you have checked-out PdfSharp, navigate to the Folder where you find the Solution file. (*.sln)
Right-click in Windows Explorer, go to the "Tortoise SVN" Menu and select "Apply patch".
Select the attached patch file.

https://tortoisesvn.net/docs/release/To ... patch.html

For further information, please consult the Tortoise SVN Documentation.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/