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

  • SEARCH
  • Home
  • 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 6662827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:25:56+00:00 2026-05-26T02:25:56+00:00

I wrote some code in Java using the pdfbox API that splits a pdf

  • 0

I wrote some code in Java using the pdfbox API that splits a pdf document into it’s individual pages, looks through the pages for a specific string, and then makes a new pdf from the page with the string on it. My problem is that when the new page is saved, I lose my font. I just made a quick word document to test it and the default font was calibri, so when I run the program I get an error box that reads: “Cannot extract the embedded font…” So it replaces the font with some other default.

I have seen a lot of example code that shows how to change the font when you are inputting text to be placed in the pdf, but nothing that sets the font for the pdf.

If anyone is familiar with a way to do this, (or can find documentation/examples), I would greatly appreciate it!

Edit: forgot to include some sample code

if (pageContent.indexOf(findThis) >= 0){
                PDPage pageToRip = pages.get(i);
                >>set the font of pageToRip here
                res.importPage(pageToRip); //res is the new document that will be saved
            }

I don’t know if that helps any, but I figured I’d include it.

Also, this is what the change looks like if the pdf is written in calibri and split:

left:calibri, right:what it changes to

Note: This might be a nonissue, it depends on the font used in the files that will need to be processed. I tried some things besides Calibri and it worked out fine.

  • 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-26T02:25:57+00:00Added an answer on May 26, 2026 at 2:25 am

    From How to extract fonts from a PDF:

    You actually cannot extract a font from a PDF, not even if the font is
    fully embedded. There are two reasons why this is not feasible:

    •Most fonts are copyrighted, making it illegal to use an extractor.

    •When a font is embedded in a PDF, not all of the font data are
    included. Obviously the font outline data are included as well as the
    font width tables. Other information, such as data about ligatures,
    are irrelevant within the PDF so those data do not get enclosed in a
    PDF. I am not aware of any font extraction tools but if you come
    across one, the above reasons should make it clear that these
    utilities are to be avoided.

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

Sidebar

Related Questions

I'd like to write some (java) code that takes a PDF document, and creates
I wrote a piece of java code using threads, JDBC, Java Mail API etc.
Having my own Java code I'm using C# to call some unmanaged code that
I wrote some code to read a file in my Java Servlet class. (I'm
I wrote some code with a lot of recursion, that takes quite a bit
I'm very new to C#. My boss asked me to wrote some code using
I wrote some naive code(in the sense that it's synchronous calls) for a tableview
I recently wrote some javascript code that filled a drop down list based on
I am trying to write some test code for my java application using Scalatest.
I've been trying to write some very fast Java code that has to do

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.