Free Support Forum - aspose.com

PDF file with multiple records

Hi,

I am using evalution version of Aspose.Pdf.

In our requirement we need to print multiple patients record information into one PDF file. headers and footers will change for each patient. And page numbers should also change accordingly.

Can you please tell me what's the best way to acomplish this?

Thanks

Mamatha

Hi Mamatha,

Thanks for your interest in our products.

As per your requirements, you need to have separate Header/Footer and page number information for each user, so I think the appropriate solution would be to create PDF documents for each patient separately using Aspose.Pdf for Java and then combine all these individual documents into a single resultant PDF document using Aspose.Pdf.Kit for Java. In order to create a PDF document, you may consider using an XML template and then fill in respective patients data and then convert that XML file into PDF format.

For more information, I would suggest you to please visit the following links

Besides this, you may also considering using another workaround. You may try using the MailMerge feature of Aspose.Words for Java to create individual documents for each patient, merge all these files into a single Document object and then convert the final merged document into PDF format using Aspose.Words for Java. For your convenience, I will forward this thread to respective forum where I believe my fellow workers taking care of Aspose.Words would be in be better position to explain this scenario in more details.

Hi,

Thanks for your prompt reply. I will try that. On a separate note you said we can generate PDF using Aspose.word right. We already bought Aspose.words license. Can we use that to generate PDF documents also or do we have to buy PDF license too.

Thanks

Mamatha

Hi Mamatha,

Aspose.Words supports the capability to load multiple file formats such as text, image, html and various word document formats (.doc, .docx, OOXML, etc) and provides the feature to save them in PDF format. However if you need to create a PDF document from scratch, please try using Aspose.Pdf for Java.

Aspose.Pdf for Java provides the capability to create PDF document using its API, while converting XML, PCL, Image file and even plain simple text file into PDF format. In case you need further information on how to how to convert Document file into PDF format using Aspose.Words for Java, please visit the following link How-to: Convert a Document to PDF

Hi,

I tried using latest version of Apose.words and it seems working. But we are not planning to upgrade existing Aspose version we have. So I am planning to use PDF.kit.

Is there a way to write contents to MemStream and then use it concatenate the files? Basically I don't want to write individual files to the disc and then concatenate them to a single file. If possible can you please provide an example?

Thanks

Mamatha

Hi Mamatha,

When using Aspose.Pdf for Java, you can save the resultant PDF file into Stream object by using one of the overloaded method of and pass the similar stream objects to PdfFileEditor class and merge the documents into a single resultant PDF. For more information, please visit

save(BasicStream stream)

concatenate(java.io.InputStream[] inputStreams,
java.io.OutputStream outputStream)



For more information, please check out Pdf and PdfFileEditor classes. In case you have any further query, please feel free to contact.

Hi,

How do you convert from BasicStream to InputStream?

Thanks

Mamatha

Hi,

I figured it out.

MemStream ms = new MemStream();

pdf.save(ms);

byte[] b=ms.toArray();

ByteArrayInputStream bufferIn = new ByteArrayInputStream(b2);

InputStream[] ins = new InputStream[] {bufferIn};

Thanks

Mamatha