Hi all.

There is a requirement in our system where PDF and TIFF output must have the same content on every page. Because of this, we need to use identical font metrics for these two renderers.

By default, the two render differently. The widths of the fonts are slightly different, so they wrap slightly differently, and once you have one word wrapping to the next page, it cascades.

Anyway, I was thinking, why can't I just do this?

  private class MyPDFRenderer extends PDFRenderer {
    public void setupFontInfo(FontInfo inFontInfo) {
      // Code copied from Java2DRenderer
      fontInfo = inFontInfo;
      BufferedImage fontImage = new BufferedImage(100, 100,
                                       BufferedImage.TYPE_INT_RGB);
      Graphics2D g = fontImage.createGraphics();
      g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                         RenderingHints.VALUE_FRACTIONALMETRICS_ON);
      FontSetup.setup(fontInfo, g);
    }
  }

If I substitute this renderer in, then the PDF and TIFF outputs look identical, and I can't see any noticeable problems with the PDF. As an added bonus, it means I don't even need the XML files hanging around, which have been a pain to manage.

So what I want to know is, is there a drawback for performing this hack?

Daniel



--
Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://nuix.com/                               Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to