Hi,

I have produced a PDF file with iText, for the most part containg GUI
parts like JFrames.
When browsing the file with Acrobate Reader, all GUI frames are
displayed as they look on screen.
However, when printing the PDF file I got some errors. 

I have printed a JTree, but it does not show up in the JFrame containing
it. 

Instead of the rest of JFrames I got the following error message: 


ERROR: limitcheck
OFFENDING COMMAND: gsave

STACK:

-savelevel-


What does this mean?

Code:

........

       // step 1: creation of a document-object
      Document document = new Document();      
      try {
          
          // step 2: creation of the writer
          PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("file.pdf"));
          // step 3: we open the document
          document.open();
          // step 4: we grab the ContentByte and do some stuff with it
          
          // we create a fontMapper and read all the fonts in the font
directory
          DefaultFontMapper mapper = new DefaultFontMapper();
          FontFactory.registerDirectories();
          mapper.insertDirectory("c:\\windows\\fonts");
          // we create a template and a Graphics2D object that
corresponds with it
          PdfContentByte cb = writer.getDirectContent();
          .....

public void print(JFrame frame, PdfContentByte cb, DefaultFontMapper
mapper, int type, int height) throws PrinterException {
          int frameHeight = frame.getHeight();
          int frameWidth = frame.getWidth();
          PdfTemplate tp = cb.createTemplate(frameWidth, frameHeight);
          Graphics2D g2 = tp.createGraphics(frameWidth, frameHeight,
mapper);
          int xPos = 0;
          int yPos = 0;
          switch (type) {
                case MAP_FRAME:
                        xPos = 10;
                        yPos = 650 - frameHeight;
                        g2.scale(0.5, 0.5);
                        break;
                case TREE_FRAME:
                        xPos = 200;
                        yPos = 650 - frameHeight;
                        g2.scale(0.5, 0.5);
                        break;
                case OTHER_FRAME:
                        xPos = 10;
                        yPos = 550 - height;
                        g2.scale(0.4, 0.5);
          } 
          frame.printAll(g2);
          g2.dispose();
          cb.addTemplate(tp, xPos, yPos);
  }

Is there any principal errors in this code?

Best Regards

---- Mikael Cedergren

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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