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

addWaterMarkFromText embed same font multiple times

New Here ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Hi, I am trying to use Excel VBA to add some text to the bottom of some PDF files. Everything works great, except that the file size is extremely large after calling addWaterMarkFromText multiple times.

            'Confidentiality
            Call jso.addWaterMarkFromText(Replace(oSetting.Confidentiality, "\r", vbCrLf), jso.app.Constants.Align.Left, _
                jso.Font.Helv, 11, _
                jso.Color.Black, 0, intPgCount - 1, True, True, True, _
                jso.app.Constants.Align.Left, jso.app.Constants.Align.Bottom, _
                5, 5, False, 1, False, 0, 1)
          

'

            For i = 0 To intPgCount

                'Bates Number
                strBatesNumber = strPrefix + Format(i, "00000")
                Call jso.addWaterMarkFromText(strBatesNumber, jso.app.Constants.Align.Right, _
                    jso.Font.Helv, 11, _
                    jso.Color.Black, i, i, True, True, True, _
                    jso.app.Constants.Align.Right, jso.app.Constants.Align.Bottom, _
                    -5, 5, False, 1, False, 0, 1)
              
            Next

The script will add the same text to the bottom left, and different page number to the bottom right of each page.

The code that add the same text to the bottom left only increase the file size by maybe 500k, which is totally fine. But the code to add different page number inside the for loop will increase the file size by about 500K every time it is called. So a 28 page file will come out to be 15MB (original size is 200K).

Is there a way to do it so that Adobe will reuse the existing font and not embedding the same font for each addWaterMarkFromText call?  I am using font.Helv, which I assume is built in and don't even need to be embedded.

If I open the PDF in Adobe and save as another PDF, the file size will shrink significanly to about 1MB, so it seemed to consolidate the same font at that. But I don't know how to do that VBA.

Any help is greatly appreciated!

Thanks,

Sean

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.5K

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

correct answers 1 Correct answer

Community Expert , Jan 15, 2018 Jan 15, 2018

Watermarks tend to have a lot of overhead. Page numbers are very simple, so as you've seen a watermark is not the best solution. And unfortunately there isn't a bates numbering tool available to JavaScript. So you'll need a different solution.

I would suggest adding form fields to every page with the bates number, then flattening them all out, and performing a saveAs, which will clean up an residue from adding the form fields. 

I'd further suggest developing this scheme in JavaScript and then put

...

Votes

Translate

Translate
Community Expert ,
Jan 15, 2018 Jan 15, 2018

Copy link to clipboard

Copied

Watermarks tend to have a lot of overhead. Page numbers are very simple, so as you've seen a watermark is not the best solution. And unfortunately there isn't a bates numbering tool available to JavaScript. So you'll need a different solution.

I would suggest adding form fields to every page with the bates number, then flattening them all out, and performing a saveAs, which will clean up an residue from adding the form fields. 

I'd further suggest developing this scheme in JavaScript and then putting that script into a folder level function, which you can call from the VBA.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
New Here ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

Thanks Thom!

I was going to go with addField option, then I saw that the font didn't get embedded multiple time if I used Font.CourB, or Font.Cour and the file size didn't get blown up like Font.Helv. So I am ok for now (until I need to use a different font )

Interesting idea that I can develop the scheme in Javascript and add as folder level function. Never tried that before, and I will definitely look into 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 Expert ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

Type 1 fonts are all built-in. So in a way they are always pre-embedded

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

Thom: I think you mean the base 16, not Type 1.

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

Ahh! I missed it   But you are only partially correct. I believe they are the Base 14 fonts, because there are 14 of them

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jan 16, 2018 Jan 16, 2018

Copy link to clipboard

Copied

LATEST

Right... 16.

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