Hi,
We are in the process of evaluating aspose as PDF converter for one of our esteemed client, and working with POCs as of now.
I am trying to add the header/footer images to the pdf generated(i.e. existing pdf) using aspose.pdf for java platform, observed that, its taking much time(apporx 10secs) to put the header/footer images in place.
Please find the below code snippet I am using for the same, review it once and let me know if there is any better way to achieve this with less time consumed.
ImageStamp footerImg = null;
ImageStamp headerImg = null;
//set footer image props
if (pdfInfo.getFooterinputStream() != null) {
footerImg = new ImageStamp(pdfInfo.getFooterinputStream());
footerImg.setBackground(true);
footerImg.setXIndent(2);
footerImg.setYIndent(0);
footerImg.setHeight(60);
footerImg.setWidth(593);
//imageStamp.setRotate(com.aspose.pdf.Rotation.on270);
footerImg.setOpacity(1);
}
//set header imagea props.
if (pdfInfo.getHeaderInputStream() != null) {
headerImg = new ImageStamp(pdfInfo.getHeaderInputStream());
headerImg.setBackground(true);
headerImg.setXIndent(2);
headerImg.setYIndent(778);
headerImg.setHeight(60);
headerImg.setWidth(593);
headerImg.setOpacity(1);
}
//add images in all pages.
for (int i = 1; i <= pdfDocument.getPages().size(); i++) {
if (footerImg != null)
pdfDocument.getPages().get_Item(i).addStamp(footerImg);
if (headerImg != null)
pdfDocument.getPages().get_Item(i).addStamp(headerImg);
}
Hi Shivaji,
Hi,
Thank you for looking in to the concern.
Please find the attached pdf generated with aspose.pdf
In page#4, I am adding the images, its in the format of image and text followed in table format.
after pdf generated, at the end am trying to add headers and footers using the above code provided.
Please review once and suggest me if any better way to achieve this.
Thanks,
Shivaji
Hi Shivaji,
Hi,
Thank you for looking in to this issue.
I am attaching here with the code and the analysis I have done.
Found that during creation of imagestamp from inputstream is consuming time.
Please find attached txt file, it contains java code and the output with time displayed in ms.
Please let me know if more details required.
Thanks again!
Shivaji
Hi Shivaji,
Hi,
Thank you for the update.
I am using temporary license using the below code.
license.setLicense(new java.io.FileInputStream(“D:\GMU\POCs\AsposeTotalJava\Aspose.Total.Java.lic”));
I am attaching here the images which i am using for the header and footer to render in the pdf file.
Please let me know if more details required on this.
Thanks,
Hi Shivaji,