Discussion:
[iText-questions] What is the maximum page size for PDF in iText?
Estepp, Dan
2007-04-11 10:04:33 UTC
Permalink
I am trying to create a PDF page larger than 200 inches height or 200
inches wide, and it does not fail, but the resulting PDF is always 200
inches wide/height?

Inserting a TIF that is 280 inches by 88 inches, and the resulting page
is only 200 inches wide and no image is displayed because the page is
not wide enough. The resulting PDF file is 1.2 meg, so it is in there
just not visible.

As long as the TIF images are smaller than 200 inches my code works
fine.
Paulo Soares
2007-04-11 10:15:18 UTC
Permalink
This has nothing to do with iText but rather with Acrobat limitations. From the Pdf Reference:

The minimum allowed page size is 3 by 3 units in default user space; the maximum
is 14,400 by 14,400 units. In versions of PDF earlier than 1.6 (Acrobat 7.0), the size of the default user space unit was fixed at 1 ⁄ 72 inch, yielding a minimum of approximately 0.04 by 0.04 inch and a maximum of 200 by 200 inches. Beginning with PDF 1.6, the size of the unit may be set on a page-by-page basis; the default remains at 1/72 inch.


Paulo
-----Original Message-----
Behalf Of Estepp, Dan
Sent: Wednesday, April 11, 2007 11:05 AM
Subject: [iText-questions] What is the maximum page size for
PDF in iText?
I am trying to create a PDF page larger than 200 inches
height or 200 inches wide, and it does not fail, but the
resulting PDF is always 200 inches wide/height?
Inserting a TIF that is 280 inches by 88 inches, and the
resulting page is only 200 inches wide and no image is
displayed because the page is not wide enough. The resulting
PDF file is 1.2 meg, so it is in there just not visible.
As long as the TIF images are smaller than 200 inches my code
works fine.
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this me
Estepp, Dan
2007-04-11 11:29:06 UTC
Permalink
Thank you.

I now set the Userunit to 200 and x/y to 8800/6800, thus should be 44 inches by 34 inches.

debug("actual writer.getPageNumber() " + nPdfWriter.getPageNumber());
Trace 40(2007-04-11 07:10:34.939): actual writer.getPageNumber() 1
...
debug("UserUnit " + nPdfWriter.getUserunit());
Trace 40(2007-04-11 07:10:34.939): UserUnit 200.0
...
debug("pagesize " + nDocument.getPageSize().toString());
Trace 40(2007-04-11 07:10:34.939): pagesize Rectangle: 8800.0x6800.0 (rot: 0 degrees)
...
debug("pagesize " + nPdfWriter.getPageSize().toString());
Trace 40(2007-04-11 07:10:34.939): pagesize Rectangle: 8800.0x6800.0 (rot: 0 degrees)

But when I view the image using 7.0.9 Adobe Reader, the Document Properties show:
"Page Size: 24,444.45 x 18,888.89 in"

And thus the image is HUGE, and the zoom factor is 0.03%.

Properties:
iText 2.0.1,
PDf Version now 1.6 (Acrobat 7.x)

-----Original Message-----
From: itext-questions-***@lists.sourceforge.net [mailto:itext-questions-***@lists.sourceforge.net] On Behalf Of Paulo Soares
Sent: Wednesday, April 11, 2007 6:15 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] What is the maximum page size for PDF iniText?

This has nothing to do with iText but rather with Acrobat limitations. From the Pdf Reference:

The minimum allowed page size is 3 by 3 units in default user space; the maximum is 14,400 by 14,400 units. In versions of PDF earlier than 1.6 (Acrobat 7.0), the size of the default user space unit was fixed at 1 ⁄ 72 inch, yielding a minimum of approximately 0.04 by 0.04 inch and a maximum of 200 by 200 inches. Beginning with PDF 1.6, the size of the unit may be set on a page-by-page basis; the default remains at 1/72 inch.


Paulo
-----Original Message-----
Estepp, Dan
Sent: Wednesday, April 11, 2007 11:05 AM
Subject: [iText-questions] What is the maximum page size for PDF in
iText?
I am trying to create a PDF page larger than 200 inches height or 200
inches wide, and it does not fail, but the resulting PDF is always 200
inches wide/height?
Inserting a TIF that is 280 inches by 88 inches, and the resulting
page is only 200 inches wide and no image is displayed because the
page is not wide enough. The resulting PDF file is 1.2 meg, so it is
in there just not visible.
As long as the TIF images are smaller than 200 inches my code works
fine.
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in
Bruno Lowagie (iText)
2007-04-11 11:39:17 UTC
Permalink
Post by Estepp, Dan
Thank you.
I now set the Userunit to 200 and x/y to 8800/6800,
thus should be 44 inches by 34 inches.
What kind of math are you using?

200 * 8800 = 1,760,000
1,760,000 / 72 = 24444,45

200 * 6800 = 1,360,000
1,360,000 / 72 = 18,888,89
Post by Estepp, Dan
"Page Size: 24,444.45 x 18,888.89 in"
Why, this is correct.
There still are certainties in life!
br,
Bruno
Estepp, Dan
2007-04-11 12:10:53 UTC
Permalink
The TIF image is 44x34.

Trace 40(2007-04-11 08:06:18.574): img.scaledWidth() 8800.0
Trace 40(2007-04-11 08:06:18.574): img.scaledHeight() 6800.0
Trace 40(2007-04-11 08:06:18.590): img.width() 8800.0
Trace 40(2007-04-11 08:06:18.590): img.height() 6800.0
Trace 40(2007-04-11 08:06:18.590): img.getDpiX() 200
Trace 40(2007-04-11 08:06:18.590): img.getDpiY() 200
Trace 40(2007-04-11 08:06:18.590): img.scaledWidth()/img.getDpiX() 44.0
Trace 40(2007-04-11 08:06:18.590): img.scaledHeight()/img.getDpiY() 34.0

I was using:
float iWidth = img.scaledWidth();
(float) ( (img.scaledWidth() /
( ( (img.getDpiX() == 0) ? 200 :
img.getDpiX())))
* 72);
And this worked fine.

Then I was trying to solve the issue where this value is larger than 200
inches (not this particular image), so tried setting the UserUnit to 200
and that is when I got into trouble.

So setting the UserUnit has no effect on the viewable PDF page?
And if it should, what should I set the UserUnit to in this case?

Thanks again in advance.

-----Original Message-----
From: itext-questions-***@lists.sourceforge.net
[mailto:itext-questions-***@lists.sourceforge.net] On Behalf Of
Bruno Lowagie (iText)
Sent: Wednesday, April 11, 2007 7:39 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] What is the maximum page size for PDF
iniText?
Post by Estepp, Dan
Thank you.
I now set the Userunit to 200 and x/y to 8800/6800,
thus should be 44 inches by 34 inches.
What kind of math are you using?

200 * 8800 = 1,760,000
1,760,000 / 72 = 24444,45

200 * 6800 = 1,360,000
1,360,000 / 72 = 18,888,89
Post by Estepp, Dan
"Page Size: 24,444.45 x 18,888.89 in"
Why, this is correct.
There still are certainties in life!
br,
Bruno

------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT Join
SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
Bruno Lowagie (iText)
2007-04-11 12:22:24 UTC
Permalink
Post by Estepp, Dan
The TIF image is 44x34.
I'm sorry, I think you missed the irony of my answer.
The page size given by Adobe Reader was CORRECT.
The page size you expected was WRONG.
The reason: you used a division instead of a multiplication.
Please redo your math.

By the way: the code snippet you show doesn't make
sense to me. I have no idea why you are fixated on
a user value of 200.
Maybe you should read the user unit explanation once more.

br,
Bruno
Estepp, Dan
2007-04-11 12:38:38 UTC
Permalink
My math works perfectly fine when I do not set UserUnit.

The 200 is a default in case the TIF does not have this set, as it
should, it may be irrelevant.

float iWidth =
(float) ( (aImg.scaledWidth() /
( ( (aImg.getDpiX() == 0) ? 200 : aImg.getDpiX())))
* 72);
float iHeight =
(float) ( (aImg.scaledHeight() /
( ( (aImg.getDpiY() == 0) ? 200 : aImg.getDpiY())))
* 72);

nDocument = new Document(new Rectangle(iWidth, iHeight),
0, // left
0, // right
0, // top
0); // bottom
nPdfWriter =
PdfWriter.getInstance(nDocument,
new FileOutputStream(nPdfFile));

// nPdfWriter.setUserunit(( (img.getDpiX() == 0) ? 200 :
img.getDpiX()));

aImg.scaleToFit(iWidth, iHeight);
nDocument.add(aImg);

So this has been working until I ran across an image that was bigger
than 200 inches.

Does this help you to understand my dilemma?

Thanks again in advanced.

-----Original Message-----
From: itext-questions-***@lists.sourceforge.net
[mailto:itext-questions-***@lists.sourceforge.net] On Behalf Of
Bruno Lowagie (iText)
Sent: Wednesday, April 11, 2007 8:22 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] What is the maximum page size for PDF
iniText?
Post by Estepp, Dan
The TIF image is 44x34.
I'm sorry, I think you missed the irony of my answer.
The page size given by Adobe Reader was CORRECT.
The page size you expected was WRONG.
The reason: you used a division instead of a multiplication.
Please redo your math.

By the way: the code snippet you show doesn't make sense to me. I have
no idea why you are fixated on a user value of 200.
Maybe you should read the user unit explanation once more.

br,
Bruno

------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT Join
SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
Bruno Lowagie (iText)
2007-04-11 12:52:11 UTC
Permalink
Post by Estepp, Dan
Does this help you to understand my dilemma?
Where in a chicken/egg situation here.
You don't understand me because I don't understand you.
Or is it vice versa? I don't know.

To me this is not an iText issue. It's just simple math.
I think I understand what you're trying to achieve,
but I don't see the relation between your goal and the
code you're writing to achieve that goal.

Please simplify your code and redo the math
(haven't I said that before?).
br,
Bruno
Estepp, Dan
2007-04-11 13:28:09 UTC
Permalink
Your correct, no one is blaming iText. The first response gave me that.

Yes, it is a math problem on my side, agreed.

I am trying to understand the use of UserUnit. No I do not have the
book. But I do understand that chapter may be available on line (just
saw your other message), I will look.

Trial and error has told me that the default value is 1. My math was
assuming 72, my bad.

Thanks for all your help.


-----Original Message-----
From: itext-questions-***@lists.sourceforge.net
[mailto:itext-questions-***@lists.sourceforge.net] On Behalf Of
Bruno Lowagie (iText)
Sent: Wednesday, April 11, 2007 8:52 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] What is the maximum page size for PDF
iniText?
Post by Estepp, Dan
Does this help you to understand my dilemma?
Where in a chicken/egg situation here.
You don't understand me because I don't understand you.
Or is it vice versa? I don't know.

To me this is not an iText issue. It's just simple math.
I think I understand what you're trying to achieve, but I don't see the
relation between your goal and the code you're writing to achieve that
goal.

Please simplify your code and redo the math (haven't I said that
before?).
br,
Bruno

------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT Join
SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V

Bruno Lowagie (iText)
2007-04-11 13:20:59 UTC
Permalink
Post by Estepp, Dan
float iWidth =
(float) ( (aImg.scaledWidth() /
( ( (aImg.getDpiX() == 0) ? 200 : aImg.getDpiX())))
* 72);
float iHeight =
(float) ( (aImg.scaledHeight() /
( ( (aImg.getDpiY() == 0) ? 200 : aImg.getDpiY())))
* 72);
OK, here you have a width and a height expressed in pt.
However: this value can be > 14,400
Post by Estepp, Dan
nDocument = new Document(new Rectangle(iWidth, iHeight),
0, // left
0, // right
0, // top
0); // bottom
I mean: we have explained that iText takes values higher than
the ones that are allowed in PDF, that you should check yourself
if the PDF limitation are respected. Then why do you still create
a document using an width and height that might be wrong?
That's the first thing I don't understand about your code.

You should test if iWidth and/or iHeight > 14,400 before creating
the document object. For instance, if iWidth = 15,000 and iHeight
= 10,000, you should create a document with iWidth = 14,400 and
iHeight = 9,600. Then set the user unit to 1.0467 so that the
actual dimension of the documents are:
width = 14,400 * 1.0467 = 15,072.48
height = 9,600 * 1.0467 = 10,048.32
which is approximately the size we were looking for
(15,000 by 10,000). You can get a more correct result
if you don't round the number but use a more precise
value for 15,000 / 14,400. It's just some Math.
Post by Estepp, Dan
nPdfWriter =
PdfWriter.getInstance(nDocument,
new FileOutputStream(nPdfFile));
img.getDpiX()));
What do you expect to happen? Please explain.
Have you read the explanation in chapter 3 of the book?
Incidentally that chapter is available for free.
Post by Estepp, Dan
aImg.scaleToFit(iWidth, iHeight);
nDocument.add(aImg);
I haven't tested my answer, but I wrote this extra mail because
you got me all confused. Maybe you think that's frustrating for
you, but it is at least as frustrating for me. You must realize
that it's impossible to have a dialog with people who keep on
repeating the same question without clarifying why they don't
follow the advice that is given.
Please adapt your code according to what I write here; if it
doesn't work, we can continue talking. If you don't want to
follow the advice, you're on your own.

br,
Bruno
Bruno Lowagie (iText)
2007-04-11 10:14:53 UTC
Permalink
It's not an iText limitation; it's a PDF limitation.

Let me quote the book on iText (p33):

Theoretically, you could create pages of any size, but the PDF
specification imposes limits depending on the PDF version of the
document that contains those pages. For PDF 1.3 or earlier, the minimum
page size is 72 x 72 units (1 x 1 in); the maximum is 3,240 x 3,240
units (45 x 45 in). Later versions have a minimum size of 3 x 3 units
(approximately 0.04 x 0.04 in) and a maximum of 14,400 x 14,400 units
(200 x 200 in).

However, in chapter 3 I create a page of 15,000,000 by 15,000,000
inches. I can do this by changing the user unit (see p 86).

br,
Bruno
Loading...