You can clip the template by changing its matrix or by applying a clipping path to the content where the template will go to.
Best Regards, Paulo Soares > -----Original Message----- > From: Steve Fyfe [SMTP:[EMAIL PROTECTED]] > Sent: Monday, July 01, 2002 18:39 > To: [EMAIL PROTECTED] > Subject: [iText-questions] Cropping an Imported PDF page > > I am using iText to create a PDF that has my own text at the top followed > by a reduced size image of another PDF. I currently have a problem because > when my code adds the imported PDF to the output PDF, some of the text > above the imported PDF is obscured. > > My program starts at the top adding text and some graphic elements to the > output PDF. I do not know in advance how much space will be needed for > this part. When that part is done I calculate the scale factor needed to > put the reduced size imported image in the remaining space on the page. If > I comment out the one line that adds the imported PDF, the text is fine. > But when that line is included in the program, part of the text above the > image is covered. > > The problem only happens when the CropBox of the imported PDF is smaller > than the MediaBox. Apparently, the addTemplate method ignores the CropBox > and "shows" some of the imported PDF that is outside the CropBox. If I > test with a PDF that has been cropped so only a portion of the visible > elements fall within the CropBox , when the PDF is added to my output PDF > the whole imported page is visible, not just the cropped section. > > Is there any way to limit an imported page to just the CropBox? Is there > any way to add a portion of a template? Is there any way to do this? > > I am using itext-paulo-100.jar, because the latest official release had a > problem with getting the CropBox size and I had trouble getting any CVS > client to be able to access the latest source. > > ====here is a code snippit===== > > PdfReader reader = new PdfReader( ... ); > > Rectangle psize = reader.getCropBox(1); // get the crop of the first page > Rectangle msize = reader.getPageSize(1); // get the size of the first page > // Compute the appropriate scale > ... > scale = ... > > PdfContentByte cb = writer.getDirectContent(); > > PdfImportedPage page1 = writer.getImportedPage(reader, 1); //get page 1 > cb.addTemplate(page1, scale, 0, 0, scale, xPos-lImg, marginBottom-bImg+2); > > =======end snippit========== > > If I use getDirectContent, as shown here, the image outside the CropBox > obscures the text I added before the image. If I use > getDirectContentUnder, the image appears underneath the text. > > TIA > Steve > > Steve Fyfe > CNI Corporation > 394 Elm Street > Milford NH 03055 > > [EMAIL PROTECTED] > (603) 673-6600 x242 > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions