PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Sep 18, 2019 3:05 am

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Sep 06, 2016 10:02 am 

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:

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

Reply with quote  
PostPosted: Tue Apr 09, 2019 11:32 am 

Joined: Tue Apr 09, 2019 11:17 am
Posts: 1
the original post is 2,5 years old, but I have the same problem. I want to concat two or more PDF files of the same type (same form, same fields, same field names, different values in the fields). The fields in the second or later file just become blank in the merged document. The result doesn't need to be a form anymore - just the values have to be at the right place. Is there any solution? Did the trick with renaming the fields work? Any other workaround?

Thanks in advance,

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 136 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group