Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.7.0+

Why a PDF Optimization Was Skipped

See more PDF Optimization Examples

Demonstrates the "skipped" array, which lists the options that were asked for but not applied, each with a reason and, where it is page-specific, the pages. An option is skipped when it is reserved for a later release (mergeFontSubsets, compactType1Fonts), when the rules of the file forbid it (objectStreams in a PDF/A-1 file), or when the content could not be parsed safely (tidyContent and coalesceContent on a page whose content stream the parser does not understand). Nothing is ever changed on a guess: an option that cannot be applied safely is skipped and reported.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  This example requires the Chilkat API to have been previously unlocked.
;  See Global Unlock Sample for sample code.

;  The PDF used in this example is available at grand_canyon_hiking_guide.pdf

$oPdf = ObjCreate("Chilkat.Pdf")
$bSuccess = $oPdf.LoadFile("qa_data/pdf/grand_canyon_hiking_guide.pdf")
If ($bSuccess = False) Then
    ConsoleWrite($oPdf.LastErrorText & @CRLF)
    Exit
EndIf

;  Ask for the two options that are reserved for a later release.
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateBool("mergeFontSubsets",True)
$oJson.UpdateBool("compactType1Fonts",True)

$oJsonOut = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oPdf.Optimize("audit",$oJson,$oJsonOut)
If ($bSuccess = False) Then
    ConsoleWrite($oPdf.LastErrorText & @CRLF)
    Exit
EndIf

Local $i = 0
Local $iNumSkipped = $oJsonOut.SizeOfArray("skipped")
ConsoleWrite("skipped: " & $iNumSkipped & @CRLF)
While $i < $iNumSkipped
    $oJsonOut.I = $i
    ConsoleWrite("   " & $oJsonOut.StringOf("skipped[i].option") & " - " & $oJsonOut.StringOf("skipped[i].reason") & @CRLF)
    $i = $i + 1
Wend

;  A skipped option is not a failure: Optimize returns true, the other options are applied, and the
;  report says exactly what was left undone.