Copy link to clipboard
Copied
Hi Everyone!
I've been using the debbugger to write a JavaScrip code that makes it easier to add a unique watermark to a document. One issue I'm running into is the file becomes mich larger in size. The test file starts out as 36kb and after I save it with the watermark its 486KB and another code its 492KB Dos anyone have any ideas to fix it?
 
Copy link to clipboard
Copied
In Adobe Acrobat Pro, you have a tool to figure out what featues in a PDF file are using how much space. You can find this "Audit space usage" feature when you select to save the file as an Optimized PDF (File>Save as Other>Optimized PDF). It's very likely that this is caused by an embedded font. Have you tried to use a different font to see if this keeps the file size down?
Copy link to clipboard
Copied
Hi Karl!
I really apprciate the help. I tried saving the file as an Optimized PDF. Here is a screenshot of the embeded fonts. Should I get rid of them?
 
Copy link to clipboard
Copied
It depends on what feature in the PDF uses up the most space. If the subset embedded font is not a big contributor to the total size, then I would not touch it. Subset embedded means that only those glyphs (the drawings of the characters) that are actually used in the file are embedded, so that keeps the size down already. Did you run the space audit function? What did it report?
Copy link to clipboard
Copied
You were right. It looks like 97.5% is taken up by the fonts. Any suggestions to reduce that?
 
Copy link to clipboard
Copied
In general, it's a good idea to leave the subset embedded font in the file. This way, you can display this file regardless of which fonts are installed on a system. If you don't think this is necessary, you can remove the embedded font using the "Save as optimized PDF" function. Give that a try and see what the resulting file size is.
Copy link to clipboard
Copied
I just tried saving it without the font and the file went from 492KB to 486KB, so not a big change.
Copy link to clipboard
Copied
Does the modified file still list this font as embedded? What else do you have in the file? Are there any form fields? That could explain why the font size did not go down: Fonts that are embedded for use in form fields are treated differently, and the only way to get rid of that overhead is to switch to one of the standard PDF fonts (e.g. Helvetica, Times Roman or Courier).
Copy link to clipboard
Copied
Its showing Arial and Calibri as embeded fonts. I do use app.response to prompt the user to enter what they want the watermark to be. Those are the only 2 fonts available when I try saving it as an optimized PDF. Is there a way to add Helvetica, Times Roman or Courier? If I save the file with no embeded fonts then the size goes way down.
 
Copy link to clipboard
Copied
You should be able to remove Arial without a problem, this font (or Helvetica) should be available on any system. If you can change the text set in Calibri to one of the standard fonts, then you need to embed that either.
Copy link to clipboard
Copied
Is there a way to autosave it without the embeded fonts using JavaScript.
Copy link to clipboard
Copied
Change your code to use a different font for the watermark text, preferably one that's available in the application itself (basically everything that can be referred to via the font object by name, such as font.Helv or font.Times).
Copy link to clipboard
Copied
Thank you! That worked.