Page 1 of 1

Missing form field content after merging PDF documents

Posted: Mon Jun 06, 2016 11:32 am
by msie
Hi,

after merging two PDF documents by using MergeDocuments(GDPicturePDF[]) the form field contents of the second PDF document were missing in the output file.
When merging three documents the form field contents of the last two documents were missing.
The contents of the first page's form fields where always retained in the output file.

Applying SetFormFieldVisibility() to every field in each document didn't change anything.

Thanks for your support!

Code: Select all

        public GdPicturePDF Merge(GdPicturePDF[] inputFiles, string outputFile)
        {
            GdPicturePDF mergedFile = new GdPicturePDF();
            var output = mergedFile.MergeDocuments(inputFiles);
          
            int i = 0;
            int formFieldId = output.GetFormFieldId(i);
            while (i < output.GetFormFieldsCount())
            {                               
                output.SetFormFieldVisibility(formFieldId, PdfFormFieldVisibility.PdfFormFieldVisible);
                formFieldId = output.GetFormFieldId(i++);
            }

            output.SaveToFile(outputFile);
            output.CloseDocument();

            return output;
        }

Re: Missing form field content after merging PDF documents

Posted: Wed Jun 08, 2016 12:10 pm
by delbeke
Hi Msie

I can not reproduce the problem on our side.
The code you show can not be run as this.

Look at this sample code to control your own

GdPicturePDF[] pdfImports = new GdPicturePDF[3] ;

pdfImports[0] = new GdPicturePDF();
pdfImports[1] = new GdPicturePDF();
pdfImports[2] = new GdPicturePDF();
pdfImports[0].LoadFromFile(@"D:\PDFs\FormFields\1.pdf", true);
pdfImports[1].LoadFromFile(@"D:\PDFs\FormFields\2.pdf", true);
pdfImports[2].LoadFromFile(@"D:\PDFs\FormFields\3.pdf", true);
GdPicturePDF outPdf = new GdPicturePDF().MergeDocuments(pdfImports);
var lStatus = outPdf.GetStat();
outPdf.SaveToFile(@"D:\PDFs\FormFields\testMerge.pdf");
MessageBox.Show("Done " + lStatus.ToString());

Hoping this help

Jean-Luc