Share

gnujpdf

Tracker: Bugs

5 problem to generate pdf with tomcat - ID: 1834361
Last Update: Comment added ( pdeville )

Since The class PDFGraphics instanciate JFrame in getFontMetrics method
there is a problem to use gnujpdf on a web server.

On linux I got message:
X11 display not available

On windows it works a moment but After severals use of the lib I got :
Out of memory no more window handle.

Here is my suggestion for getFontMetrics :

Line 1435 :
public FontMetrics getFontMetrics(Font font) {
BufferedImage image = new
BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
// Frame dummy = new Frame();
// dummy.addNotify();
// Image image = dummy.createImage(100, 100);
if (image == null) {
System.err.println("getFontMetrics: image is null");
}
Graphics graphics = image.getGraphics();
return graphics.getFontMetrics(font);

}


I tested this and it works well.


pdeville ( pdeville ) - 2007-11-19 05:51

5

Open

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2007-11-23 09:26
Sender: pdeville


The code takes more times to hangs (arround 50 request to return
OutOfMemoryError)

This last change works since 3 days without problem (1000 access per
hour).

/**
* Returns the FontMetrics for a font.
* <p>This doesn't work correctly. Perhaps having some way of mapping
* the base 14 fonts to our own FontMetrics implementation?
* @param font The java.awt.Font to return the metrics for
* @return FontMetrics for a font
*/
public FontMetrics getFontMetrics(Font font) {


return Toolkit.getDefaultToolkit().getFontMetrics(font);

}

}



File Added: PDFGraphics.java


Log in to comment.

Attached File ( 1 )

Filename Description Download
PDFGraphics.java Final version that works Download

Changes ( 3 )

Field Old Value Date By
File Added 255538: PDFGraphics.java 2007-11-23 09:26 pdeville
File Deleted 254906: 2007-11-23 09:26 pdeville
File Added 254906: PDFGraphics.java 2007-11-19 05:51 pdeville