How to reduce/optimze PDF file size with VBA?
I use this code to add Order# to an existing PDF
Function PDF_Numbering(order As String)
Dim acroApp As Acrobat.acroApp
Dim myDocument As Acrobat.AcroPDDoc
Dim jso As Object
Dim strPath As String
Dim strFileName As String
Dim intPages As Integer
Dim i As Integer
Set acroApp = CreateObject("AcroExch.App")
Set myDocument = CreateObject("AcroExch.PDDOc")
strPath = "C:\Users\Daniel\Downloads\"
strFileName = order & ".pdf"
'Open file and load JSObject
Set myDocument = CreateObject("AcroExch.PDDOc")
myDocument.Open (strPath & strFileName)
Set jso = myDocument.GetJSObject
' get number of pages
intPages = myDocument.GetNumPages
'Write page number
jso.addWatermarkFromText _
cText:=order & " ", _
nFontSize:=14, _
nTextAlign:=1, _
nHorizAlign:=2, _
nVertAlign:=1, _
nVertValue:=-30, _
'Save document
Call myDocument.Save(1, strPath & strFileName)
'Clean up
Set jso = Nothing
Call acroApp.CloseAllDocs
Set myDocument = Nothing
Call acroApp.Exit
Set acroApp = Nothing
However, the modified PDF is 15 times larger in size than the original PDF (original 60kb, modified 800kb)
Why is this happening and how do I correct this?
