PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu May 25, 2017 2:33 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Sep 06, 2016 10:02 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
Hi there, I am having a problem with the PDF program that I am currently writing. If I try to merge two PDFs that happen to use the same AcroField names, then the Fields in the 2nd PDF will simply become blank. I am currently using the following method to 'flatten' the PDFs:

Code:
if (Flatten) {
PdfAcroField.PdfAcroFieldCollection fields = inForm.Fields;
string[] names = fields.Names;

for (int idx = 0; idx < names.Length; ++idx)
{
  string fqName = names[idx];
  PdfAcroField field = fields[fqName];
  PdfTextField textField;

  if ((textField = field as PdfTextField) != null)
  {
      textField.ReadOnly = true;
                           
   }
 }
}


This works fine, in that it makes the Fields unable to be edited in Acrobat Reader. However it seems that the forms still exist as they can be edited in Adobe Acrobat, or by loading the PDF again with PDFSharp. I'd seen that a solution was in the works here: viewtopic.php?f=2&t=3369 but this doesn't seem to have made it over to the 1.50.4000-Beta3B release yet. I tried following the patch tutorial, but the Source Code would not build after I tried it. Is there any way to completely flatten the AcroFields at this time?

Alternatively I had another idea to solve the problem in the meantime. I could rename all of the fields present in the PDF to some randomly generated 16 character name, like "ALVDrrLAWUawTxUh" or "ZDJrQdfwGLL3DDz5". This would mean that any PDF saved by my program would be extremely unlikely to ever have the same Field names, meaning that they would not overwrite each other. Is it possible to rename an AcroField?

Thanks, RBrNx


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group