Free Support Forum -

Merged PDF Output Without AutoFiller Class

I need to fill one PDF form many times, then concatenate the forms together as one merged PDF document. I see that you’re doing this within the AutoFiller class, but I’m wondering if there’s a way to do this without?

You might create a class called “FormMerger” that accepts an array of Form objects and provides a method to save the merged PDF document.

Dear cohenn,

Thanks for considering Aspose.

1)About merging many pdf files into one file, I implement the function through another product of Aspose.Pdf.Kit and optimize the use of its API. Without that, you couldn’t merge them just simply concatenating the many output streams.

2)The “AutoFiller” class is based on the case of one pdf template and many data with the same structure and fill these data into the form repeatedly. The output can be a large merged pdf or many small pdfs. In the demo after you setup, there is a classic example of how to use this class to merge email in Maybe it is helpful to you.

3)I have not clearly understand your application requirement, Could you give me a more detailed case? Then I can adjust the existed API.

Best regards.

Thanks for the quick response. We looked at the AutoFiller class but decided to implement our solution using only the Form class.

I would need a class (or something) that can accept multiple output streams and generate a merged document. Essentially, the same mechanism you're using within AutoFiller to achieve the same result.

Dear cohenn,

To merge multiple stream into one stream is not the function of Aspose.Pdf.Form. I just “borrow” it from the Aspose.Pdf.Kit.
Maybe it should be implemeted in Aspose.Pdf.Kit. I will the discuss this with the developer of Aspose.Pdf.Kit and give you an answer.

Best regards.

Thanks. If I pass a MemoryStream object to the Form constructor, fill in the fields and call Form.Save( ), will it write to the MemoryStream object?

Dear cohenn,

Thanks for considering Aspose.

If you just operate on only one pdf, it is ok. And after you save it, you should not change it, you could just copy it.

Best regards.

I’m trying out Pdf.Kit and I get the following error when concatenating two streams together:

“PDF header signature not found.”

Here’s how I’m filling the objects:

For Each xmlDataRow In xmlChildNodes memPdfForms(nIndex) = New MemoryStream() pdfForm = New Form(sPdfInput, memPdfForms(nIndex)) Call subFillForm(xmlDataRow) pdfForm.Save() nIndex += 1 Next

Here’s how I’m creating the new file (it’s just doing the first two for now):

Dim strPdfFile As New FileStream(sPdfOutput, FileMode.Create) Dim pdfEditor As New PdfFileEditor() pdfEditor.Concatenate(memPdfForms(0), memPdfForms(1), strPdfFile) strPdfFile.Close()

If Pdf.Kit does the job, we’ll purchase both components. Thanks.

Dear cohenn,

You are welcome.

1) If you only want to merge two streams, you could use the Pdf.Kit directly. But you must note one thing: before you merge them as one, you should set the pointer of the input stream at the start just like the following:

memPdfForms(0).Position = 0
memPdfForms(1).Position = 0

pdfEditor.Concatenate(memPdfForms(0), memPdfForms(1), strPdfFile) strPdfFile.Close()

2) If you want to merge many streams (more than two) into one stream, it is a little complex to reach a optimized way. In “AutoFiller”, I implement this function with a recursive function. So I suggest you wait for a day or two, I will ask the Pdf.Kit developers to provide a new interface.

Best regards.

Thanks. Resetting the pointer fixed my problem.

As soon as the new interface is ready, we’ll go ahead and purchase both components. Thanks again.