Skip to main content
Participant
June 25, 2020
Question

Giving margin while converting HTML to PDF

  • June 25, 2020
  • 1 reply
  • 947 views

How can we set margins in the PDF during conversion from HTML file>

This topic has been closed for replies.

1 reply

Participating Frequently
October 6, 2020

Thanks for reaching out. As of now we do not support setting custom margins in the PDF document through our SDKs. At the moment you can only provide custom height and width while converting your HTML to PDF document ( refer this sample for the same :- https://github.com/adobe/pdftools-java-sdk-samples/blob/master/src/main/java/com/adobe/platform/operation/samples/createpdf/CreatePDFFromStaticHTML.java#L79)

Participant
June 1, 2024

We are using html to pdf to create business cards which are 3.5in x 2in. The hard corded margins are something like .5 inches and so we have very little room for the content on the business card. Can we please have an update that allows us to specify a custom margin size? Or, if that is too much to ask, can we please have an automatic margin size that adjusts down to something like .25 inch if the page size is smaller than 3in x 5in?

Participant
June 21, 2024

Okay kids, we solved this problem by creating our PDF with width and height that is 4 times the true size, which winds up giving us the equivalent of 1/8 inch margins. This is because our PDFs are business cards and when you load them into a print job they get shrunk to 1/4 the size to fit onto a standard business card. So there you go - just hack it!