Thanks for the reply, but nothing changes from the "size" point of view
if I use the GetPageSize instead of GetPageSizeWithRotation.
Still I get the A4 size and I don't know why.
Would it be useful if I attach the PDF that generates the problem?
Thanks
Massimo
Da: Mark Storer [mailto:msto...@autonomy.com]
Inviato: 26 July 2011 18:10
A: Post all your questions about iText here
Oggetto: Re: [iText-questions] Problems detecting page sizes of PDF
documents
You've assumed that 0,0 is always going to be one of the corners of the
page. Don't.
Particularly with N-up printing, pages can be no where near 0,0. If the
page you're dealing with was intended to be in the 3rd column, 4th row
of a 6x6 "page" page, it's corners could be just about anywhere,
depending on page rotation.
I tend to avoid getPageSizeWithRotation. I get the page's rectangle,
and I get the page's rotation. Much more control that way.
--Mark Storer
Senior Software Engineer
Cardiff.com
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
________________________________
From: Bassini Massimo [mailto:m.bass...@crif.com]
Sent: Tuesday, July 26, 2011 7:27 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] Problems detecting page sizes of PDF
documents
Hi everyone, this is my first question.
I'm sorry but I've to skip presentation 'cause I'm pressed ...
The problem I have is the following: I'm trying to manipulate
PDF files (ex. Adding images, adding barcodes etc.).
Usually I don't have big problems but in this case ...
When I read the document page size via code
reader = new
PdfReader(lOriginalFileName);
r = reader.GetPageSizeWithRotation(1);
I read a size corresponding to an A4.
The problem arises because when I read the page size in File -
Properties within Adobe Reader I see 177.8 mm x 228.6 that looks like a
custom size.
What happens is that when I append a barcode based on page size
it's attached outside the page ...
I tried to "save as" the original document using, for example,
this code
Document doc = new Document(new
iTextSharp.text.Rectangle(A4POINTSWIDTH, A4POINTSHEIGHT), 0, 0, 0, 0);
PdfCopy c = new PdfCopy(doc, new
FileStream(lWorkFileName, FileMode.Create));
doc.Open();
PdfReader reader = new
PdfReader(lOriginalFileName);
for (int i = 1; i <=
reader.NumberOfPages; i++)
{
reader.GetPageN(i).Put(PdfName.PAGE,
new PdfRectangle(A4POINTSWIDTH, A4POINTSHEIGHT));
c.AddPage(c.GetImportedPage(reader,
i));
}
doc.Close();
c.Close();
But the resulting document still has the same problem: looks
like an A4 within code, but it's something else, though.
May anybody help me please?
Thanks.
Regards
Massimo
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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