the Swing Components are saved as PDF Successfullly but there are some borders 
of Tables got hiding in the 100% view in the PDF and only Showing if zoomed 
out...Any Body has any Clue how to render exact image to be in the 100% view 
for an User...the Below Piece of code i have Used to Save the Image As PDF. 

private void createPdfFile(String fileName,final Component creditWorksTabPane) {

                File file = new File(fileName);
                if (file.exists()) {
                        file.delete();
                }

                Component mComponent = (Component)creditWorksTabPane;
                
RepaintManager.currentManager(mComponent).setDoubleBufferingEnabled(false);

                //Rectangle pageSize = new Rectangle(625, 782);
                Document document =  new Document(PageSize.LETTER);

                try {


                Dimension d = mComponent.getSize();
                int panelHeight = d.height;
                int panelWidth = d.width;
                double scale = 0.9172f;


                PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream(file));
                document.open();

                PdfContentByte cb = writer.getDirectContent();
                PdfTemplate tp = cb.createTemplate(panelWidth, panelHeight);
                Graphics2D g2d = tp.createGraphics(panelWidth, panelHeight,new 
DefaultFontMapper());
                g2d.scale(scale,scale);
                mComponent.printAll(g2d);
                g2d.dispose();
                cb.addTemplate(tp,0,0);
                
RepaintManager.currentManager(mComponent).setDoubleBufferingEnabled(true);
                }
                catch(Exception e) {
                MessageUtil.showError(this, "Fail to save to file " + fileName);
                logger.error(e.getMessage());
                }
                document.close();
         }

--
This message was sent on behalf of [email protected] at 
openSubscriber.com
http://www.opensubscriber.com/messages/[email protected]/topic.html

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to