0

I generate pdf from xhtml file but font style is differs with XMHTL.

Here is Java Code

ITextRenderer renderer = new ITextRenderer();
         renderer.getFontResolver().addFont("C:/Windows/Fonts/times.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
         renderer.setDocument(urlXhtmlFile);
         renderer.layout();
         renderer.createPDF(os);
         os.close();

enter image description here

How to set font style of pdf and html is same (color). Thanks!!!

sonas sonas
  • 197
  • 1
  • 5
  • 15

1 Answers1

0

You should add CSS into your XHTML, there you can manipulate with font size, color etc (change font properties according to your needs):

<html>
  <head>
    <style type="text/css" media="print">
        body {
          font-family: "Times New Roman", Times;
          font-size: 10pt;
          color: blue;
        }
    </style>
  </head>
  <body>
  </body>
</html>

Also, I suggest you embed font into PDF, as someone opening this PDF without this font installed would not see PDF properly.

Magic Wand
  • 1,572
  • 10
  • 9