John Davidson

php - is there a way to add margins or scaling in dompdf?

0 comments
Message:


i have generated a pdf using dompdf and set the paper size as A6. now when i try to print the pdf in A4 and letter paper size, the left and top borders are getting cut. is there a way to generate the pdf so that it can be compatible with A4, A6, letter and legal paper sizes? it should start from the top right corner of the page.



My Answer:
Yes, you can add margins or scaling in dompdf to ensure that your PDF is compatible with different paper sizes.

To add margins, you can use the following CSS code in your HTML file before generating the PDF:

css
@page {
margin: 10mm;
}


This will add a 10mm margin to all sides of the page. You can adjust the margin size as needed.

To scale the content to fit different paper sizes, you can use the following CSS code:

css
@page {
size: A4;
}


This will set the page size to A4. You can change the size to A6, letter, or legal as needed.

By adding margins and setting the page size in your CSS, you can ensure that your PDF will be compatible with different paper sizes and start from the top right corner of the page.

Rate this post

4 of 5 based on 7255 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us