|HOWTO: Fill out and stitch together multiple instances of a form |
AspPDF is capable of stitching multiple documents together using the Doc.AppendDocument
method. If a document being appended needs to be modified first (such as, fill out a form or template)
it is necessary to save and then reopen this document, or the changes will not take effect
during the appending phase.
This article describes a technique that should be used when modifying and stitching multiple templates together.
First of all, if a document being appended needs to be modified, it must first be saved, reopened, and only then appended.
This operation can be performed
entirely in memory via the SaveToMemory and OpenDocumentBinary to avoid dealing with temporary files.
Secondly, each document being appended must have its own separate Doc variable. Reusing
a single Doc variable for all documents being appended may corrupt the output document, and is not allowed.
The easiest solution
is to use an array of PdfDocument objects.
The following code snippet demonstrates this technique:
Set Pdf = Server.CreateObject("Persits.Pdf")
Set objDocMain = Pdf.CreateDocument
For i = 0 To 10
Set objDoc = Pdf.OpenDocument("c:\path\invoice.pdf")
Set field = objDoc.Form.FindField("fieldname1")
field.SetFieldValue "test value"&i, objDoc.fonts("Helvetica")
' set other fields
' save and reopen
Set objDocs(i) = Pdf.OpenDocumentBinary(objDoc.SaveToMemory)
' Call AppendDocument to append
objDocMain.Save "c:\path\Out.pdf", False
Created: 2/8/2006 3:30:04 PM
Last Modified: 8/23/2006 3:37:51 PM
Copyright © Persits Software, Inc. 1998 - 2019
For technical support, write to firstname.lastname@example.org.