Quantcast

[java] A4 page size is wrong in PageSize.A4

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[java] A4 page size is wrong in PageSize.A4

linuxunil
Hello,

I'm creating a pdf using com.itextpdf.text.PageSize.A4.

Document document = new Document(PageSize.A4);

When i open the output file in Adobe Acrobat X v10.1.9 The output file has the size:

595.0 X 842,0 pts (CORRECT)

                BUT

8.26 X 11.69 in (INCORRECT! 8.3 X 11.7 in)

The page size is validated in inches not in points. Because of that all the documents generated are being reproved.

document generation code
--------
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.newPage();
document.close();
writer.close();
outputStream.flush();
outputStream.close();
------
end of code

document validation code
----------------------
//reader is a pdfReader instance and pageNumber is the page in the loop
Rectangle pageSize = reader.getPageSize(pageNumber);
float heightSize = round2(Utilities.pointsToInches(pageSize.getHeight()));
float widthSize = round2(Utilities.pointsToInches(pageSize.getWidth()));
               
//check page is A4
if(heightSize == 11.7f && widthSize == 8.3f){
  isA4Sized = true;
} else {
  isA4Sized = false;
}
return isA4Sized;
-----------------
end of the code

using Itext v5.5.0 and Oracle jdk 1.7u51 32Bits.

mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [java] A4 page size is wrong in PageSize.A4

mkl
linuxunil wrote
8.26 X 11.69 in (INCORRECT! 8.3 X 11.7 in)
Which source tells you 8.3 X 11.7 in is the exact and only A4 size?

First of all, 8.3 X 11.7 in is the 8.26 X 11.69 in rounded to one decimal digit, and even 8.26 X 11.69 in is not exact, merely rounded.

Please be aware that the An formats are defined by some criterion and then rounded to the nearest millimeter. Thus, the size in inches usually has numerous decimal digits. Assuming a single decimal number to be exact, therefore, is presumptuous.

Furthermore, the standard also defines tolerances. If the size differs by nor more than that tolerance from the 'exact' value, the format still is An.
//check page is A4
if(heightSize == 11.7f && widthSize == 8.3f){
  isA4Sized = true;
} else {
  isA4Sized = false;
}
This shows that the person who implemented the validation code not only has not understood ISO 216 (which defines most of the An sizes) but also has not understood floating point numbers. Almost always doing '==' on floats is nonsense.

Regards,   Michael
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [java] A4 page size is wrong in PageSize.A4

linuxunil
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [java] A4 page size is wrong in PageSize.A4

iText mailing list
linuxunil schreef op 26/02/2014 22:18:
> page size source
> http://en.wikipedia.org/wiki/ISO_216

You are saying you want to use the ISO standard for page sizes and
you're measuring in inches???

Surely you must be joking! We're talking about an original DIN standard
from the Deutsches Institut für Normung. Those are serious people and
serious people use the metric system, not some medieval system based on
human body parts ;-)

Please change your Adobe Reader settings to the metric system as soon as
possible, so that you can see the measurements in millimeters. See the
attached screen shot. A page with size 595 x 842 measures 210 x 297 mm
which is the size that is mentioned on the Wiki page you're referring to.

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php

A4.png (62K) Download Attachment
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [java] A4 page size is wrong in PageSize.A4

mkl
In reply to this post by linuxunil
linuxunil wrote
Allow me to quote from that page:

>Tolerances

>The tolerances specified in the standard are:
> * ±1.5 mm for dimensions up to 150 mm,
> * ±2.0 mm for dimensions in the range 150 to 600 mm, and
> * ±3.0 mm for dimensions above 600 mm.

Thus, a person taking that page as a base for the tests would never ever have written the A4 format test you mentioned

>> if(heightSize == 11.7f && widthSize == 8.3f){

because this test allows no tolerances.

Furthermore quoted from the wikipedia page:

> The most frequently used of this series is the size A4 which is 210 mm × 297 mm (8.27 in × 11.7 in).
> ...
> 4    210 × 297    8.3 × 11.7

Thus, if the person designing that test really would have tried to use that wikipedia page as information source, he or she would have noticed that the page provides differing values for the size in question. Thus, he or she would have stopped using the wikipedia page as information source and instead looked into the standard ISO 216 itself (which is the normative source of information here).

Regards,   Michael
Loading...