How can I re embed fonts programatically using pdftk (or another software)?
- March 30, 2024
- 4 replies
- 13539 views
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


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.pdf) still 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



