How to create a PDF with a Cartesian grid?

Could anyone please provide me a sample program that can dynamically create a grid or even dots starting at (0,0) at bottom left corner on a PDF of page size "Letter"? (max X = 8.5 Inches; max Y = 1

Could anyone please provide me a sample program that can dynamically create a grid or even dots starting at (0,0) at bottom left corner on a PDF of page size "Letter"? (max X = 8.5 Inches; max Y = 11 Inches)

Posted on StackOverflow on Jun 10, 2014 by user3727496

Please take a look at the Grid example. Let's write the loops that draw the grid:

PdfCanvas canvas = new PdfCanvas(pdfDoc.addNewPage());
for (float x = 0; x 

Here we use pageSize variable to learn the width and the height of the PDF file and just increment x and y with 72 user units (this means that the distance between the dots will be 1 inch).

Click this link if you want to see how to answer this question in iText 5.


Share this article

Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now