Some test text!
PDFViewCtrl
has a powerful and seamless conversion system which allows you to stream documents during conversion to PDF. It supports the following file types:
In this tutorial you will be able to display a non-PDF file in PDFViewCtrl
.
Before going forward, please make sure you have finished setting up PDFViewCtrl
as described in Using PDFViewCtrl.
The easiest way to display a non-PDF file in PDFViewCtrl
is through the PDFViewCtrl.openNonPDFUri
API.
To access device storage, add the following permission to AndroidManifest.xml
file in the <manifest>
tag (outside of the <application>
tag):
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Then add the following when you would like to show the document, typically onCreate
or onResume
of your Activity or Fragment:
try {
Uri nonPdfUri = Uri.fromFile(new File("my_file_path"));
DocumentConversion documentConversion = pdfViewCtrl.openNonPDFUri(nonPdfUri, null);
} catch (Exception ex) {
ex.printStackTrace();
}
Add the following when you would like to show the document, typically onCreate
or onResume
of your Activity or Fragment:
try {
Uri nonPdfContentUri = Uri.parse("my_content_uri");
DocumentConversion documentConversion = pdfViewCtrl.openNonPDFUri(nonPdfContentUri, null);
} catch (Exception ex) {
ex.printStackTrace();
}
To monitor the conversion event, do:
pdfViewCtrl.addUniversalDocumentConversionListener(new PDFViewCtrl.UniversalDocumentConversionListener() {
@Override
public void onConversionEvent(PDFViewCtrl.ConversionState state, int totalPagesConverted) {
switch (state) {
case PROGRESS:
// conversion in progress
break;
case FINISHED:
// conversion finished successfully
break;
case FAILED:
// conversion failed
if (documentConversion != null) {
try {
Log.e("MainActivity", "Conversion failed: " + documentConversion.getErrorString());
} catch (Exception ignored) {}
}
break;
}
}
});
Get the answers you need: Support
Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.
Select a platform to get started with your free trial.
Web
Android
iOS
Windows
Linux
Unlimited usage. No email address required.