Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] How do you convert a PDF Document to
 an  com.lowagie.text.Image

Bruno

2006-07-20

Replies:

Brian Ewers wrote:

> I have the following...
>
>
>
> com.lowagie.text.Document pdfdocument = new com.lowagie.text.Document();
>
>           PdfWriter writer2 = PdfWriter.getInstance(pdfdocument,
> new FileOutputStream("test.pdf"));
>
>           pdfdocument.open();
>
>           PdfContentByte cb = writer2.getDirectContent();
>
>           Graphics2D g2d = cb.createGraphics(PageSize.A4.width(),
> PageSize.A4.height());
>
>           panel.paint(g2d);
>
>           g2d.dispose();
>
>           pdfdocument.close();
>
>
>
> Now, I want to convert this to an Image and insert the
>
> image into another PDF document.
>
>
>
> How do I convert the document to an Image???
>
Note that we are talking about a com.lowagie.text.Image object here;
not an image in the sense of a JPEG, GIF, TIFF, PNG,...

There is an example on how to import a page from a file existing.pdf :
http://itextdocs.lowagie.com/tutorial/general/copystamp/#pdfwriter

A PdfImportedPage object is used. You can add this with the addTemplate
method.
You can also wrap a PdfImportedPage in an Image object and add it to
your new PDF with document.add().
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=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.