
Optimizing a PDF using automation with VB.
Ok, I've sorted it out.
Thanks to Aandi Inston, who "provoked" me to look at the documentation just
a bit harder! I overlooked the fact you could combine several of the
settings while using the save function.
By combining Linearize and SaveFull, you get an optimized document.
I also add in EmptyGarbage - not sure it has much effect.
See code below:
______________________________________________________
Private Sub Tif2PDF(FileName As String)
Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim PDDoc As CAcroPDDoc
Dim IsSuccess As Boolean
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Call AVDoc.Open(FileName, "")
Set AVDoc = AcroApp.GetActiveDoc
If AVDoc.IsValid Then
Set PDDoc = AVDoc.GetPDDoc
If PDDoc.Save(1 Or 4 Or 32, App.Path & "\docfile.pdf") <> True Then
MsgBox "Failed to Save " & FileName
End If
PDDoc.Close
End If
'Close the PDF
AVDoc.Close True
AcroApp.Exit
'Cleanup
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing
End Sub
Quote:
> Hi Everyone,
> Have a look at the following code. It opens a TIF/PDF/etc. and saves it
out
> as a PDF.
> I want to "optimize" the PDF (the check box on acrobat's save as dialog)
so
> it can be "byteserved" from a web server.
> I have been experimenting with the SetFlags() function - one of the
> PDDocFlags is PDDocIsOptimized, but that doesn't seem to work. Does
anyone
> have any ideas?
> Thanks,
> Alastair.