steven0lisa / flying-saucer

Automatically exported from code.google.com/p/flying-saucer
0 stars 0 forks source link

Preferred width too narrow #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
*** This issue was imported from http://java.net/jira/browse/XHTMLRENDERER-288

It was reported by wdonne on 26.08.2009 19:09:43 +0200 and last updated in the 
previous bug tracker on 26.08.2009 19:13:10 +0200

Found in
Operating System: All
Platform: Macintosh

The priority for this issue at migration was Major.
The original issue had attachments to it; see comments below.

Original description: 
I use the following code to generate thumbnails and previews of XHTML pages:

    BufferedImage       image =
      new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_RGB);
    Graphics2D          gr = image.createGraphics();
    XHTMLPanel          panel = new XHTMLPanel();

    panel.setDocument(parse(url), url);
    panel.setSize(-1, -1); // Force width calculation.
    panel.doDocumentLayout(gr);
    gr.dispose();

    ImageIO.write
    (
      Graphics2DRenderer.renderToImageAutoSize
      (
        url,
        (int) panel.getPreferredSize().getWidth()
      ),
      "png",
      out
    );

    out.flush();

When a block-level element has text-align set to "center" and if it contains an 
image, the preferred 
width return by the panel is too narrow. This is also the case when text-indent 
is set to a percentage, 
but the error is much smaller. In other cases the result is perfect.

Original issue reported on code.google.com by pdoubl...@gmail.com on 16 Feb 2011 at 9:47

GoogleCodeExporter commented 9 years ago
Attachment by wdonne on 26.08.2009 19:13:09 +0200:  t.zip, size 40636 bytes
Download: http://java.net/jira/secure/attachment/27400/t.zip

Original comment by pdoubl...@gmail.com on 16 Feb 2011 at 9:47

GoogleCodeExporter commented 9 years ago
wdonne wrote on 26.08.2009 19:13:10 +0200:
Created an attachment (id=97)
An example

Original comment by pdoubl...@gmail.com on 16 Feb 2011 at 9:47