Hi,

I use itext to export Graphics2D to PDF. The problem is that the image
(scene) is not printed completely in the pdf. Some of it is cut. I guess it
has to do with the width and height i'm indicating. I'm not really sure what
how big should the width and height if i get the image form a scroll pane,
so actually i don't know the dimensions! the code is as follows:
 public void ExportPDF() {
        int w = 400;
        int h = 600;
        Document document = new Document();
        String path = "H:\\erd.pdf";

        try {
            PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(path));
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(w, h);
            Graphics2D graphics = tp.createGraphics(w, h);
            scene.paint(graphics);
            graphics.dispose();
            cb.addTemplate(tp, 0, 0);
        } catch (DocumentException ex) {
            Exceptions.printStackTrace(ex);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
        document.close();
    }

Any help would be appreciated

Thanks in advance,
Wessam
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to