Thanks for all the tips! 1T3XT wrote: ---------------------------------------------------------------------------------------- Yes, option 2 was what I meant. You can increase the page size. It's done more or less like this: http://1t3xt.be/?X0003df But instead of the PdfName.CROPBOX, you change the PdfName.MEDIABOX. Also you can use negative values for the rectangle. For instance: new PdfRectangle(0, -52, 612, 720); -----------------------------------------------------------------------------------------
I dont' think i want to run with this because a) the content will still be in the bottom left corner of the page. I want flexibility where i add the text: bottom left, bottom centre, bottom right, top left, top centre, top right. So, to add the text to the bottom of the page I'd have to translate the content anyway, using a template or appending a cm. I don't see how shrinking the rectangle is going to help me at this stage. 1T3XT wrote: -------------------------------------------------------------------------------------------------- > That's dangerous, because you'll only change the "printed" content. > All the interactive content won't change (because it's not part of > the content stream). All your links will have an offset. > That's not what you want. > I'm not going comment on it. > If you go that way, you're on your own. > (Meaning: it's possible for a PDF expert, but it's not something > that can be explained or done for free. You'll cost us too much > time on the list if you pursue this path.) --------------------------------------------------------------------------------------------------- I think that is actually what I want. None of the pdfs I'll be dealing with will have any interactive content. If I do actually come across such pdfs I can write code to move all of the interactive content. Also, I would like to change the content as little as possible in this resizing process. I'm happy to do this on my own but do you have any useful references in the pdf reference? The section on content streams and resource dictionaries is pretty bare. 1T3XT wrote: ----------------------------------------------------------------------------- You're probably removing the XObject with the content. I should see an example to know for sure. ------------------------------------------------------------------------------ It would be great if you could help me with the disappearing page content problem. My workaround for this issue creates 3 pdfs in total. This makes a fair performance hit when processing very large pdfs. This is my code: Private Function StampPages() As Boolean Dim dictDestPage As PdfDictionary Dim dimens As Hashtable = New Hashtable(4) For Each page As PDFStamperSettings.PageSetting In StampSettings.PageSettings Dim current As Integer = NumberOfPages + page.IndexInParent page.Size = newPDFReader.GetPageSize(page.Number) page.Rotate = newPDFReader.GetPageRotation(page.Number) 'Add a page to the new pdf newPDFStamper.InsertPage(current, page.Size) Dim srcPage As PdfImportedPage = newPDFStamper.GetImportedPage(newPDFReader, page.Number) 'Get the content of the PDF under the current content Dim destUnderContent As PdfContentByte = newPDFStamper.GetUnderContent(current) 'Set the boundaries of the stamps page.SetBounds() 'Determine the dimensions of the new template dimens = generate_dimensions(page, page.Width, page.Height) 'Add the extracted page as a template destUnderContent.AddTemplate(srcPage, dimens("xScale"), 0, 0, _ dimens("yScale"), dimens("xDiff"), dimens("yDiff")) For i As Integer = 0 To (page.Stamps.Count - 1) If TypeOf page.Stamps(i) Is StampText Then Dim stamp As StampText = page.Stamps(i) 'Start adding text destUnderContent.BeginText() 'Set the font fize, set the position (matrix) and add the text (showtext) destUnderContent.SetFontAndSize(stamp.Font, stamp.FontSize) set_text_position(stamp, destUnderContent, page.Width, page.Height) destUnderContent.ShowText(stamp.Text) 'Stop adding text destUnderContent.EndText() ElseIf TypeOf page.Stamps(i) Is StampLine Then Dim stamp As StampLine = page.Stamps(i) 'Set the start and end point of the line set_line_position(stamp, destUnderContent, page.Width, page.Height) 'Draw the line destUnderContent.Stroke() End If Next 'Extract the PDFDictionary of the destination page and 'add a Rotate PDFName for rotating the document dictDestPage = newPDFReader.GetPageN(current) dictDestPage.Put(PdfName.ROTATE, New PdfNumber(page.Rotate)) 'Stop the document from auto-correcting the rotation newPDFStamper.RotateContents = False Next Return True End Function Private Function RemoveAndReplacePages() As Boolean 'Remove/replace unwanted pages If NumberOfPages = StampSettings.PageSettings.Length Then 'All old pages removed 'Create a pageRange in the format of "1-9,15,23-45" 'Selects a range from the old number of pages plus 1 (where the new pages start) to the end of the pdf pageRange = (NumberOfPages + 1).ToString() + "-" + (NumberOfPages * 2).ToString() 'Keep only those pages within the selected page range newPDFReader.SelectPages(pageRange) Else 'Select pages to replace Dim newPDFReader2 As PdfReader = New PdfReader(PDFFile + ".tmp") For Each page As PdfStamperSettings.PageSetting In StampSettings.PageSettings newPDFStamper.ReplacePage(newPDFReader2, NumberOfPages + page.IndexInParent, page.Number) Next newPDFReader.SelectPages("1-" + NumberOfPages.ToString()) newPDFReader2.Close() End If 'close and clear the streams Close() Return True End Function Thanks heaps. Cheers, Billy ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ 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