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

Exclude Rotated Margin Text from PDF Extraction

See more PDF Text Extraction Examples

Demonstrates the "rotatedText" filter. Text that is not aligned with the page, such as a vertical "CONFIDENTIAL" label in the margin, is included by default (after the upright text) and flagged in the quality report; "exclude" leaves it out.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loPdf
LOCAL loJson
LOCAL loJsonOut

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 rotated_margin.pdf

loPdf = CreateObject('Chilkat.Pdf')
lnSuccess = loPdf.LoadFile("qa_data/pdf/rotated_margin.pdf")
IF (lnSuccess = 0) THEN
    ? loPdf.LastErrorText
    RELEASE loPdf
    CANCEL
ENDIF

loJson = CreateObject('Chilkat.JsonObject')
loJsonOut = CreateObject('Chilkat.JsonObject')

*  The page has a paragraph and, rotated 90 degrees along the left margin, "CONFIDENTIAL - DRAFT - NOT FOR DISTRIBUTION".
lnSuccess = loPdf.ExtractText("text",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
    ? loPdf.LastErrorText
    RELEASE loPdf
    RELEASE loJson
    RELEASE loJsonOut
    CANCEL
ENDIF

? "---- default (rotated text included) ----"
? loJsonOut.StringOf("text")
? "issue: " + loJsonOut.StringOf("quality.pages[0].issues[0].code")

loJson.UpdateString("rotatedText","exclude")
lnSuccess = loPdf.ExtractText("text",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
    ? loPdf.LastErrorText
    RELEASE loPdf
    RELEASE loJson
    RELEASE loJsonOut
    CANCEL
ENDIF

? "---- rotatedText: exclude ----"
? loJsonOut.StringOf("text")

*  Sample output:

*  ---- default (rotated text included) ----
*  Restoration Budget Summary
*  
*  Spending for the season came in slightly under the approved budget, largely because the parapet work took less time than expected. The lens loan carries no fee, but the society is responsible for insurance and for the specialist cleaning.
*  
*  CONFIDENTIAL - DRAFT - NOT FOR DISTRIBUTION
*  issue: rotatedText
*  ---- rotatedText: exclude ----
*  Restoration Budget Summary
*  
*  Spending for the season came in slightly under the approved budget, largely because the parapet work took less time than expected. The lens loan carries no fee, but the society is responsible for insurance and for the specialist cleaning.

RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut