I use Aspose java pdf version 25.7 and pdf24 printer. I try to print footer (or watermark) on bottom of page. I want to print it on bottom of page (as soon as possible). I use AutoResize mode (it is working very strange on one document I can see extra width and extra height so resize was wrong). I set the same font and position of “Y” as 0. The following file is result of print for 2 files (correct with footer and not correct where no footer (if set “Y” as 50 footer will print):
footer.pdf (548.7 KB)
no_footer.pdf (97.0 KB)
I use following code for print:
PdfViewer viewer = new PdfViewer();
// Set attributes for printing
viewer.setAutoResize(true); // Print the file with adjusted size
viewer.setAutoRotate(true); // Print the file with adjusted rotation
// Create objects for printer and page settings and PrintDocument
PdfPrinterSettings printerSettings = new PdfPrinterSettings();
PrintPageSettings pageSettings = new PrintPageSettings();
// Set PageSize (if required)
pageSettings.setPaperSize(new PrintPaperSize("A4", 794, 1123));
// Set PageMargins (if required)
pageSettings.setMargins(new PrinterMargins(0, 0, 0, 0));
viewer.printLargePdf(locPath, pageSettings,printerSettings);
I use following code for add footer (I checked different codes (for example HeaderFooter class) but always has problem):
FormattedText formattedText = new FormattedText(rText.text,tCol,rText.font.getFamily(),EncodingType.Identity_h, true,rText.font.getSize2D());
WatermarkArtifact artifact = new WatermarkArtifact();
artifact.setText(formattedText);
com.aspose.pdf.Point p = new com.aspose.pdf.Point(50,50);
p.setX(margingX);
p.setY(0);
artifact.setPosition(p);
page.getArtifacts().add(artifact);
@aleksand
It seems you’re experiencing issues with printing footers in your PDF documents using Aspose.PDF for Java. Here are some troubleshooting tips that may help resolve the problem:
-
Check Footer Positioning: Ensure that the footer is positioned correctly on the page. If it’s set too low (like Y = 0
), it might be outside the printable area. Try adjusting the Y
position to a higher value, such as Y = 50
, to see if that resolves the issue.
-
Verify Page Size and Margins: Make sure the page size and margins are set correctly. If the margins are too small, the footer may not print as expected. You can adjust the margins in your page settings.
-
Rendering Settings: Double-check your rendering settings. Ensure that any relevant options are functioning as intended. If the document appears distorted, consider adjusting the rendering settings to see if it improves the output.
-
Update Aspose.PDF: Since you’re using version 25.7, consider updating to the latest version of Aspose.PDF for Java. Newer versions may contain bug fixes that could resolve your printing issues.
-
Sample Code Review: Review the sample code for adding footers in the Aspose.PDF documentation to ensure your implementation aligns with best practices.
If these suggestions do not resolve the issue, you may want to reach out to Aspose support for more specific assistance related to your situation.
- Check Footer Positioning: Ensure that the footer is positioned correctly on the page. If it’s set too low (like
Y = 0
), it might be outside the printable area. Try adjusting the Y
position to a higher value, such as Y = 50
, to see if that resolves the issue.
I want to print this at the bottom of the page (as low as possible). I haven’t found any examples for find this minimum.
- Verify Page Size and Margins: Make sure the page size and margins are set correctly. If the margins are too small, the footer may not print as expected. You can adjust the margins in your page settings.
I use Margins 0. What mean “If the margins are too small, the footer may not print as expected.”? As I said before: “I want to print this at the bottom of the page (as low as possible).”. How I can do it in Aspose for any pdf document?
Another problem: Is it possible in Aspose to print text (watermark) in page even if it outside of PDF page (for case if the document’s proportions do not match the page’s proportions, and white space is added when AutoResize)? In C++ (for use common print dialog (not Aspose) ) I can print text in any position of page (use WINAPI TextOut). Is it possible use PdfViewer class of Aspose?
- Rendering Settings: Double-check your rendering settings. Ensure that any relevant options are functioning as intended. If the document appears distorted, consider adjusting the rendering settings to see if it improves the output.
I do not use any rendering settings for print. I did not see any examples with set of rendering settings for print. Can you give me examples?
- Update Aspose.PDF: Since you’re using version 25.7, consider updating to the latest version of Aspose.PDF for Java. Newer versions may contain bug fixes that could resolve your printing issues.
Okay, I’ll do it, but I don’t think it will lead to a good result (in current moment last is 25.8 so minor changes). I started investigate problem (and try to find all examples in Aspose.PDF) when 25.7 was last.
@aleksand
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-45431
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.