Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPanel to be set to A4 size

I'm creating a text editor in Java that will have output to PDF. In order to sync data that appears in my program and the output PDF as close as I can, I'd have to have a JPanel which has the same size as an A4 paper (or at least to be in scale). I have tried converting its mm dimension (297x210) to pixels, but opening a regular size A4 document in PDF results in a bigger page than my JPanel.

Would certain size in pixels match the size of every document (.doc,.pdf,etc) created in A4 size (displaying it at 100%), or are there variations from program to program?

I'm trying to make sense of the whole conversion deal... Do I have to visually match the size in the Adobe reader, or is there some kind of factor that you multply with page size in inches or milimeters? Is there anyone who knows how does the whole page size format deal works?

like image 612
Karlovsky120 Avatar asked Feb 19 '23 05:02

Karlovsky120


1 Answers

In my experience, there is no such thing as a printer standard. The behavior of printers or software like Adobe Acrobat Reader vary dramatically. Some might automatically shrink your A4-sized panel to fit in a single page with margins while others might print off 4 pages with a single pixel column on page two and a single pixel row on page 3.

Unfortunately you must go about it by trial and error. Make it work for Acrobat Reader and then try printing it out and seeing if it comes out the same. It helps to provide any and all hints as to how to format the page. Lacking these hints, much of this software tends to guess about what your intentions are.

like image 147
Neil Avatar answered Mar 04 '23 08:03

Neil