Print Page | Close Window

Merge and PDF with 132 form fields

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2177
Printed Date: 26 Jun 25 at 8:11PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Merge and PDF with 132 form fields
Posted By: niklashemdal
Subject: Merge and PDF with 132 form fields
Date Posted: 02 Mar 12 at 12:42PM
I am using 7.x ActiveX with VB6 to merge PDF forms.  i.e.

    Dim d1 As Long
    Dim d2 As Long
    Dim resultCode As Long
    Dim pdfLibL As QuickPDFAX0719.PDFLibrary
    Set pdfLibL = New QuickPDFAX0719.PDFLibrary
    Call pdfLibL.LoadFromFile(fileNameMs$)
    d1 = pdfLibL.SelectedDocument()
    Call pdfLibL.LoadFromFile(newTemplateLs$)
    d2 = pdfLibL.SelectedDocument()
    Call pdfLibL.SelectDocument(d1)
    Call pdfLibL.MergeDocument(d2)
    resultCode = pdfLibL.SaveToFile(newFileNameLs$)

This code is called in a loop, where the file saved (newFileNameLs$) becomes d1 for the next iteration.  I have also tried usnig MergeFiles API, but get the same end result.  MergeFiles had a better result - I was able to add more pages but still crashed.  One PDF has 132 form fields.  I will see what flattening d1  form fields does in the merge process.   MergeFiles dies at about 7524 form fields with "Application-defined or object-defined error"




Replies:
Posted By: niklashemdal
Date Posted: 02 Mar 12 at 1:04PM
Now, if I change code to:
    Dim d1 As Long
    Dim d2 As Long
    Dim resultCode As Long
    Dim FieldIndex As Integer
    Dim FieldCount As Integer
    Dim LoopNumber As Integer
   
    Dim pdfLibL As QuickPDFAX0719.PDFLibrary
    Set pdfLibL = New QuickPDFAX0719.PDFLibrary
    Call pdfLibL.UnlockKey("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
   
    Call pdfLibL.LoadFromFile(fileNameMs$)
    FieldCount = pdfLibL.FormFieldCount()
    FieldIndex = 1
    For LoopNumber = 1 To FieldCount
      If pdfLibL.FlattenFormField(FieldIndex) = 0 Then
        FieldIndex = FieldIndex + 1
      End If
    Next
    d1 = pdfLibL.SelectedDocument()
    Call pdfLibL.LoadFromFile(newTemplateLs$)
    d2 = pdfLibL.SelectedDocument()
    Call pdfLibL.SelectDocument(d1)
    Call pdfLibL.MergeDocument(d2)
    resultCode = pdfLibL.SaveToFile(newFileNameLs$)

I no longer receive the Applicatio-defined or object-defined fatal error; however, my resultant PDF only contains pages 65 to 76.


Posted By: niklashemdal
Date Posted: 02 Mar 12 at 1:09PM
The PDF I am using is here - http://www.box.com/s/m46gv1j67lzrcfixs2h3


Posted By: AndrewC
Date Posted: 06 Mar 12 at 11:31AM

When you flatten form fields you need to flatten them backwards.

For LoopNumber = FieldCount downto 1     ' <<<<<<<<<
      If pdfLibL.FlattenFormField(FieldIndex) = 0 Then
        FieldIndex = FieldIndex + 1
      End If
    Next

Also you may want to try upgrading to the 7.26 release which contains many bug fixes compared to 7.16.  The 7.26 version is a free upgrade for all 7.xx users and can be downloaded from

http://www.quickpdflibrary.com/downloads/binaries/qp/oldversions/0726/quick_pdf_library726.exe

Andrew.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk