Android™ Requires Chilkat v11.7.0+
Android™
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 Android™ Downloads
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;
import android.app.Activity;
import com.chilkatsoft.*;
import android.widget.TextView;
import android.os.Bundle;
public class SimpleActivity extends Activity {
private static final String TAG = "Chilkat";
// Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean success = 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 rotated_margin.pdf
CkPdf pdf = new CkPdf();
success = pdf.LoadFile("qa_data/pdf/rotated_margin.pdf");
if (success == false) {
Log.i(TAG, pdf.lastErrorText());
return;
}
CkJsonObject json = new CkJsonObject();
CkJsonObject jsonOut = new CkJsonObject();
// The page has a paragraph and, rotated 90 degrees along the left margin, "CONFIDENTIAL - DRAFT - NOT FOR DISTRIBUTION".
success = pdf.ExtractText("text",json,jsonOut);
if (success == false) {
Log.i(TAG, pdf.lastErrorText());
return;
}
Log.i(TAG, "---- default (rotated text included) ----");
Log.i(TAG, jsonOut.stringOf("text"));
Log.i(TAG, "issue: " + jsonOut.stringOf("quality.pages[0].issues[0].code"));
json.UpdateString("rotatedText","exclude");
success = pdf.ExtractText("text",json,jsonOut);
if (success == false) {
Log.i(TAG, pdf.lastErrorText());
return;
}
Log.i(TAG, "---- rotatedText: exclude ----");
Log.i(TAG, jsonOut.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.
}
static {
System.loadLibrary("chilkat");
// Note: If the incorrect library name is passed to System.loadLibrary,
// then you will see the following error message at application startup:
//"The application <your-application-name> has stopped unexpectedly. Please try again."
}
}