Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loPdf
LOCAL loJson
LOCAL loJsonOut
LOCAL i
LOCAL lnNumSkipped
lnSuccess = 0
* 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
loPdf = CreateObject('Chilkat.Pdf')
lnSuccess = loPdf.LoadFile("qa_data/pdf/grand_canyon_hiking_guide.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
CANCEL
ENDIF
* Ask for the two options that are reserved for a later release.
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateBool("mergeFontSubsets",1)
loJson.UpdateBool("compactType1Fonts",1)
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loPdf.Optimize("audit",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut
CANCEL
ENDIF
i = 0
lnNumSkipped = loJsonOut.SizeOfArray("skipped")
? "skipped: " + STR(lnNumSkipped)
DO WHILE i < lnNumSkipped
loJsonOut.I = i
? " " + loJsonOut.StringOf("skipped[i].option") + " - " + loJsonOut.StringOf("skipped[i].reason")
i = i + 1
ENDDO
* A skipped option is not a failure: Optimize returns true, the other options are applied, and the
* report says exactly what was left undone.
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut