Hi 1T3XT,
Thanks for the reply. How do I clip the imported page? I need to clip this based on the size of the cropbox. This is why I wanted to get the content of the cropbox from the start rather than the PageSize? Surly this is not an unusual task? Any Ideas? Thanks -----Original Message----- From: 1T3XT info [mailto:i...@1t3xt.info] Sent: 09 January 2010 8:14 PM To: Post all your questions about iText here Subject: Re: [iText-questions] Get the content from only within the cropbox? Ric Clarke wrote: > Thinking this would work, but it does not see too. I think I'm starting > to go round in circles now. Does anyone have any suggestions? I don't understand what you did and even less why you did it, but... why don't you just clip the imported page before adding it? -- This answer is provided by 1T3XT BVBA From: Ric Clarke [mailto:r...@webkeg.com] Sent: 09 January 2010 7:09 PM To: itext-questions@lists.sourceforge.net Subject: [iText-questions] Get the content from only within the cropbox? Hi, I'm copying pages from one document into another. My script can take a A3 pdf and scale it down to a A4 by using the following: iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(inPDF); iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc, new FileStream(outPDF, FileMode.Create)); for (int i = 1; i <= reader.NumberOfPages; i++) { iTextSharp.text.pdf.PdfImportedPage oriPage = writer.GetImportedPage(reader, i); image = iTextSharp.text.Image.GetInstance(oriPage); image.ScaleToFit(iTextSharp.text.PageSize.A4.Width, iTextSharp.text.PageSize.A4.Height); image.SetAbsolutePosition(0, 0); image.Border = iTextSharp.text.Rectangle.BOX; image.BorderColor = iTextSharp.text.BaseColor.GREEN; image.BorderWidth = 1f; directcontent.AddImage(image); pdfDoc.NewPage(); } This is works great on most of my pdfs. However there are some pdf's where I want to only use the content within the cropbox. When I use the above script it done not use the crop box for the size, therefore any trim marking and anything else outside the cropbox are shown. I've been trying for hours now to try and get it to use the dimensions of the cropbox. After a lot of digging around I thought I had found a solution: In the itextsharp source file "itextsharp-5.0.0\iTextSharp\text\pdf\PdfImportedPage.cs" and in the class " PdfImportedPage" I changed: "bBox = readerInstance.Reader.GetPageSize(pageNumber)" To "bBox = readerInstance.Reader.GetCropBox(pageNumber);" Thinking this would work, but it does not see too. I think I'm starting to go round in circles now. Does anyone have any suggestions? Many thanks Ric No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.432 / Virus Database: 270.14.131/2609 - Release Date: 01/09/10 07:35:00
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/