• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
25

How can I re embed fonts programatically using pdftk (or another software)?

Community Beginner ,
Mar 30, 2024 Mar 30, 2024

Copy link to clipboard

Copied

I have a template pdf that I will progrmatically fill up based on a user input.

My template has a field called name, and I assigned a field font as Noto Thaana Sans to it. I also filled in some random text. My 3.pdf is my template

 

 

Krac36425538h3l5_2-1711836851534.png

 

Krac36425538h3l5_4-1711836910546.png

 

I can see that Thaana is embedded in the document properties (embedded subset) beacuse I added some sample text.

 

I then generate an fdf for this using pdftk, modify the fdf to contain some additional Thaana characters (that user provides), and then generate the final pdf.

 

pdftk 3.pdf fill_form fdf6.txt output 9.pdf need_appearances

 

The final pdf (9.pdfstill has Thaana font embedded, but it is the wrong subset. It does not contain the accurate Thaana embedded subset, since there are now more characters that need to be embedded.

 

So I want to re-embed it somehow, so it will have the entire needed subset I need. I could just open acrobat, save and quit to get the latest chars, but I want to do this programatically. I tried looking into ghostscript, but it does not work for fillable forms like mine.

 

How can I have the latest subset programatically, or using some binary? 

 

This is what it looks like after generation. Once I open in acrobat, it asks me to save it, and then once I do and I refresh on chrome, it shows the updated text (the embedded subset is getting updated), I want to do this programatically

 

Krac36425538h3l5_5-1711840103675.png

Krac36425538h3l5_6-1711840114106.png

 

 

Krac36425538h3l5_7-1711840138551.png

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , Modern Acrobat , PDF , PDF forms , Print and prepress , Standards and accessibility

Views

3.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 30, 2024 Mar 30, 2024

Copy link to clipboard

Copied

my fdf file

 

%FDF-1.2
1 0 obj
<<
/FDF
<<
/Fields [
<<
/V <FEFF07980792>
/T (name)
>>]
>>
>>
endobj
trailer

<<
/Root 1 0 R
>>
%%EOF

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

You need to ask in a forum about pdftk.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

++Adding to the topic,

 

You don't need a third party tool to embedd font types programatically.

 

The Acrobat Distiller or the Adobe PDF creation tool allows you to do that programmatically with a few manual configurations.

 

See slides:

 

1000005716.png

 

See this recent discussion:

 

 

It illustrates how to do that, plus some additional technical consiserations.

 

Note in my first example slide above that I am embedding all fonts that are stored  in Microsoft Windows Fonts folder. And you should embedd all fonts provided by Acrobat too.

 

However, my take on this is that, in order to have the most successful font embedding and subsetting  experience you must manually tweak the following settings and test it as needed until you get the desired results:

 

1000005718.png

 

More importantly also look at the Information Tooltip: "Only fonts with appropriate permission bits will be embedded".

 

Some fonts could be copyrighted or restricted.

 

In which case, the responsibility of paying the author for the desired font foundry, and be able to actually download and install legally an licensed Font foundry in your system will fall on you 100%, regardless of the software that you choose to accomplish this task programmatically.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

Thanks for this, but I'm not sure it accomplishes my goal.

 

The question is how to do it programatically, here is seems like its  manual tasks of changing the setting

 

Not to mention I need to do this on a linux machine

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

Aaahh ! Ok, you should've said so from the get go.

 

Since you posted your question in the support forum for Adobe Acrobat, A better question would be, do you have a susbscription plan of Adobe Acrobat Pro DC?

 

If not, there is not really any support for you with this particular case in these Adobe support  forums.

 

However, I did answer you question as thouroughly as I was under the assumption that you were trying to work around a support limitation of the Dhihevi language in Adobe Acrobat or Microsoft Windows.

 

To re-inforce my answer,  for the sake of  those Windows users that may be needing a solution, Once you setup the Adobe PDF creation tool settings, you set that profile as the default template; and every time that a file is exported to or imported to a PDF using Adobe Acrobat it will employ  those settings programmatically during the PDF creation/conversion process.

 

There is no need of manual configurations thereafter.

 

The issue that most likely you'll be dealing with , regardless of operating system language support, Font Foundry Unicode support, or improper character and ligatures mapping encoding, is the platforms that non-linux users will be using to work with that file.  This is referred to as portability. See next link:

 

 

Conversely, using all open source software, like for example LibreOffice or OpenOffice on a Linux box, it may and will run into issues with font publication rights while embedding subsets:

 

See additional insightful reading to consider if you are a Linux user here:

 

 

From additional readings, I've learned that the fact is that if you have Microsoft Windows users, there is little support for that font type since Windows XP. The support guidance I've came accross are referenced below:

 

 

I am a Linux supporter myself  since 1997, but you'll not get any avid support for Linux in these forums, even though the fact is that Android OS runs on a pretty solid Linux kernel, and the Acrobat Mobile app that integrates with the Adobe Creative Cloud runs very good in my opinion.

 

Aside from that, it also baffles me to come accross many Linux discussions that end up nowhere in these forums, and knowing that both Microsoft and Apple themselves have been introducing support for the Adobe Acrobat extension in web browsers that run on macOS and Linux (i.e. the new Microsoft Edge and Chromium-based engine web browsers).

 

And most recently, there is Linux OS support currently tested and run in Apple computers with M2 and M3 silicon chips as we speak (that is, without the need to run Linux on a separate  virtualized container side-by-side with macOS).

 

Anyway, my recommendation is to try to produce a good solid LibreOffice document first running it on a solid Debian-based (i.e. Ubuntu, Mint, Pop OS from System76) or Red Hat-based Linux distro (i.e Fedora, Cent OS)  ensuring all the necessary font embedding and embedding subsets as possible before it is exported to a PDF.

 

Things to consider:

 

 

 

Then, download and install the Google Chrome, Chromium or Microsoft Edge on Linux and add the Adobe Acrobat PDF extension from the Chrome webstore.  And see if when you export the LibreOffice .docx file using the PDF extension it retains the desired font embeddings.

 

TIP:

Microsoft Office365 web apps are accessible on Microsoft Edge  <<< ==== this is another aproach you may like to try on Linux with the new Edge web browser (like with Acrobat Document Cloud, Google Drive, you need an account subscription though to test things out)

 

Pretty much the new extension relies heavily on Acrobat Online services at this time.

 

But it is expected that sometime, possibly this year and 2025,  that the Adobe Acrobat viewer will replace the native PDF viewer that is shipped with Microsoft Edge web browser.

 

Are you able to share the original document that was produced before it was exported to a PDF?

 

I am curious now.

 

I can take a look at it and try to proof if it can be done from one of my debian-based linux boxes.

 

I do have a subscription plan and I can test how the document will be produced on my end using the Adobe Acrobat PDF extension in a linux-supported web browser.

 

YOU MAY ALSO LIKE :

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

++Update

 

Hi @kopler ,

 

I did a little more research, you may use Ghostscript and ps2pdf for this purpose.

 

Pdftk doesn't seem to accept Acrobat Distiller paramaeters.And I don't think is properly supported or maintained anymore.

 

However, ps2pdf and Ghostscript seem to works in all platforms (Windows, Linux, macOS).

 

I am referencing this solution from several colleges and universities that have published on the web extensive guides on how to do this method.

 

It appears that you may be able to produce higher quality PDFs using this method via script rather than using the Acrobat Distiller by itself. 

 

In which case, embedding all fonts is the way to go that may allow a way to work around the subsetting issue. 

 

The only issue to this method is the size of the file becoming too big, but according to the information that I found you can also reduce or optimize the output PDF file with the Distiller parameters.

 

If you need the references let me know and I'll post back.

 

NOTE: 

The PDFs files that you shared were produced by a free online file converter.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 01, 2024 Apr 01, 2024

Copy link to clipboard

Copied

Hi @ls_rbls , thanks for looking into tis, and please let me know the references

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 08, 2024 Apr 08, 2024

Copy link to clipboard

Copied

Greetings @kopler ,

 

I regret the delay in my response, as I encountered some challenges in addressing your query.

Upon revisiting our discussion, I realized the need for further investigation to provide you with an accurate answer.

 

These are some of the links I owed you:

 

 

 

 

 

 

You need that Distiller Guide with Ghostscript.

 

But please disregard my previous suggestion regarding ps2pdf and Acrobat Distiller parameters, as there is a simpler method to embed fonts in a PDF using the Thaana font script for static content and fillable form fields.

 

I conducted tests on both a debian-based Linux system with LibreOffice Writer and a Microsoft Windows 11 computer, successfully creating fillable forms resembling Microsoft365 Word documents with Noto Sans Thaana font.

 

When the document is finally exported to a PDF using "Export Directly as PDF" on LibreOffice, those fillable text fields will be detected as PDF objects and will retain the embedded font type.

 

The Noto Sans Thaana that you were using with your shared documents is the best font type because, even thought it is an OpenType Font with TrueType Outlines, it allowed me to use different PDF viewers to fill in the produced PDF form fields just by copying and pasting different styles of the Thaana font types that are used with the Vhidevi language on may web sites or text documents.

 

Additionally, the Noto Sans Thaana script that is distributed by Google is actually a universal, Unicode-based, font.:

 

 

Additional important reading and other Thaana OpenType variations:

 

 

The result ?

 

1. The Noto Sans Thaana font embedded in the PDF recognized the text that I copied and pasted from other Thaana font styles that I found in other websites with no issues. However, I did observe a minor exception with some arabic ligatures and glyphs that probably won't render if they are meant to illustrate the phonetics or pronunciation of certain phrases or words.


2. Two important things to consider: First, If you will be distributing this form for users just to fill & sign, the best way to enjoy the benefit of a platform-independent environment (macOS, Linux, Windows) is to instruct your users to use that PDF on a web browser such as, Mozilla Firefox.

 

It renders fine on Firefox.

 

On Microsoft Edge, Google Chorme and Chromium web browsers, the use of the Acrobat extension may be required to render it properly.

 

Besides that, there are a few experimental new PDF features on Chromium-based web browsers that may or may not interfere.

 

Secondly, if you will be distributing the PDF for other users to perform editing, there are certain licensing restrictions that will prevent them from editing the PDF with any PDF editor if they use TrueType (.ttf) or certain OpenType (.otf) with TrueType outlines Thaana foundries.

 

See slide:

 

thaana.png

 

3. If you come across a situation where you need to share a font with someone, they will have to manually install it on their system in order to use it with their PDF editing software. You can provide them with the font by distributing it, and you can find more information about this in the link I included in my test document.

 

It's important to note that simply embedding multiple fonts on a PDF doesn't automatically mean that the user can open the PDF in Adobe Acrobat and have those fonts embedded programmatically. The user must have already installed the fonts on their operating system for them to be available to the applications that require them.

 

Even if the fonts are available at the operating system level, applications like Adobe Acrobat will always prioritize their native or default editing fonts, such as Helvetica. So, until the user manually selects the Thaana font and saves the document, they won't be able to see any changes.

 

See my shared file and see what you can test with it:

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 09, 2024 Apr 09, 2024

Copy link to clipboard

Copied

LATEST

Thank you @ls_rbls

for this message and the detailed description

 

Could you please tell me what change you made however? You provided a test file but I'm not sure how you generated it in the first place? 

 

 

-----

When the document is finally exported to a PDF using "Export Directly as PDF" on LibreOffice, those fillable text fields will be detected as PDF objects and will retain the embedded font type.

-------

Is this the change you made? You generated the PDF by actually creating a word document using Libre / MS Word, using the Thaana font, and then exporting it as PDF?

 

If so, I have a few follow up questions

 

1) Will this embed the entire Thaana font, or a small subset of it? Ie, if pdftk adds in another thaana character, is it guaranteed to show up in the pdf?

 

2) Is there a way to do this only using acrobat? What if all I have is a PDF, how can i embed it through PDF logic only, and not transforming to word and then back to pdf?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines