I want to do Text branding on PDF in UpperLeft, UpperMiddle, UpperRight, LowerLeft, LowerMiddle and LowerRight. I also need to calculate upper and bottom margin, based on content that goes to branding to resizePdf accordingly. How do i calculate the upper and bottom margin, so that the content of branding doesn’t overlay with PDF contents
The margin settings are specified at the time of PDF generation only. Furthermore, you can surely resize the PDF content and margins by using the below code snippet as per your desire:
Document pdfDocument = new Document(dataDir + "to_resize.pdf"); com.aspose.pdf.facades.PdfFileEditor.ContentsResizeParameters parameters = new com.aspose.pdf.facades.PdfFileEditor.ContentsResizeParameters( com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(0), com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(PageSize.getA4().getWidth()), com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(0), com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(0), com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(PageSize.getA4().getHeight()), com.aspose.pdf.facades.PdfFileEditor.ContentsResizeValue.units(0) ); com.aspose.pdf.facades.PdfFileEditor editor = new com.aspose.pdf.facades.PdfFileEditor(); editor.resizeContents(pdfDocument, parameters); // Save output as PDF format pdfDocument.save(dataDir + "resized.pdf");
Once the PDF is resized, you can use TextStamp or ImageStamp in order to add branding in it. Please check the below documentation articles:
Thanks for the response.
As per your inputs, i can resize pdf and proceed with stamping. But if i have good amount of text that needs to be branded , like the one below,
Aspose.png (83.4 KB)
I need to calculate Lower and upper margins based on the text contents, before resizing the pdf, otherwise branding content will overlay on pdf content.
Do we have any support from Aspose, to handle such scenerios ?
We need to investigate your this requirement. For the purpose, would you please share the sample PDF with us as well so that we can log a ticket in our issue tracking system and share the ID with you.
Attached original Pdf and branded pdf.
Based on stamp size, I have calculated Top and Bottom Margins and accordingly resized before stamping the content.
If aspose can provide feasibility to get the pdf resized based on stamping content, it would be beneficial.
We have logged an investigation ticket as PDFJAVA-40534 in our issue tracking system to further analyze your requirements. We will look into details of the ticket and keep you posted with the status of its resolution. Please be patient and spare us some time.
We are sorry for the inconvenience.