Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri May 11, 2018 9:59 pm

Hi, I'm using this below code to duplicate a page, however form fields are not being copied over. Is it possible to copy the form fields as well?

Code: Select all
doc.AllowCreateForm = (doc.Form == null) ? true : false;
SizeF size = page.Size;
PdfTemplate template = page.CreateTemplate();
page = doc.Pages.Add(size, new PdfMargins(0));
page.Canvas.DrawTemplate(template, new PointF(0, 0));

jumper4000
 
Posts: 12
Joined: Thu Mar 01, 2018 11:46 pm

Mon May 14, 2018 6:27 am

Hello,

Thanks for your post.
Sorry to tell that Spire.PDF would flatten the form fields by default when duplicating a page. I have added a new feature for keeping the original form fields. Once the feature is implemented, I will let you know.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Jun 06, 2018 12:17 am

Hi, do you have any news on this yet? If this is not implemented yet, what would be the best way to duplicate a page, and then edit some of the fields on the second page?

jumper4000
 
Posts: 12
Joined: Thu Mar 01, 2018 11:46 pm

Wed Jun 06, 2018 3:18 am

Hi jumper4000,

Sorry to tell there's no progress and the issue could not be resolved in a short time due to the complexity.
As a workaround, you could first delete the other pages except the page you need, then save it to a new pdf document.
After that, merge it with other pdfs. If needed, you could also modify the page orders using"PdfDocument .Rearrange(int[] orderArray)"to acheive your target.
Code: Select all
PdfDocument doc = new PdfDocument(@"original.pdf")
doc.Pages.RemoveAt(1);
doc.Pages.RemoveAt(2);
doc.SaveToFile("thePage.pdf");
string[] files = new string[] {"sample.pdf", "thePage.pdf" };
PdfDocumentBase page = PdfDocument.MergeFiles(files);
page.Save("13799.pdf");


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue Oct 27, 2020 10:34 am

Hello,

Sorry for the long silence.
We just released Spire.PDF Pack(Hot Fix) Version:6.10.9 that supports keeping the original form fields when duplicating a page. Please download it and refer to the following code for testing.
Code: Select all
 PdfDocument pdf = new PdfDocument("FormField.pdf");
 pdf.InsertPage(pdf, 0, pdf.Pages.Count) ;
 pdf.SaveToFile("Result.pdf");

Download links:
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/6.10.9

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF