Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 964531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:50:38+00:00 2026-05-16T01:50:38+00:00

I’m using a custom truetype font in a pdf generated by flying saucer xhtmlrenderer.

  • 0

I’m using a custom truetype font in a pdf generated by flying saucer xhtmlrenderer.

ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("myfont.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
renderer.setDocument(XMLResource.load(in).getDocument(), url);
renderer.layout();
renderer.createPDF(out);

and within the html being rendered, i have the following (for example)

<html>
<head>
<style type="text/css">
*{font-family:myfont;} /* <-- this works, trust me */
</style>
</head>
<body>
<p>some plain text<b>some bold text</b> <span style="font-weight:bold;">more bold</span></p>
</body>
</html>

but even with the <b> and the font-weight:bold I can’t get the text to come out bold.

Now, i know this should work because i have a similar (legacy) project which uses the same font, and plain old itext (ie no xhtmlrenderer) and it does produce pdfs with bold text via:

myFont = BaseFont.createFont("myfont.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
Font boldFont = new Font(myFont);
boldFont.setStyle(Font.BOLD);

com.lowagie.text.Document document = ...;
document.add(new Paragraph("plain", myFont));
document.add(new Paragraph("bold", boldFont));

can anyone explain why i can’t use bold with xhtmlrenderer, and maybe a way to overcome this issue?

thanks, p.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:50:39+00:00Added an answer on May 16, 2026 at 1:50 am

    I’m no expert, but if your font doesn’t have a bold variant, then Flying Saucer may simply “not make it bold”. When you programmatically make the font bold, you’re using a font class that could be (behind the scenes) making the font “bolder” on its own using some kind of internal mechanism. A good example of this in the real world is Photoshop: if you have a font that doesn’t have a bold variety, you can’t make it bold, but Photoshop has a “simulated bold” option that will go in and thicken up the symbols without really using a “true” bold face.

    A good means of diagnosing this for sure would be to switch which font you’re using in Flying Saucer but keep the same document. If the new font is also not bold, then the problem is less topical. If it does become bold, then it is because there is no bold version of your font.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
In order to apply a triggered animation to all ToolTip s in my app,
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.