Product: Pdftron android Sdk
Product Version: Demo
Please give a brief summary of your issue: PDFViewCtrl caching customization
(Think of this as an email subject)
Please describe your issue and provide steps to reproduce it:
I am using pdfViewCtrl.openPDFUri(Uri.parse …
How do I customize the cache location
how to config so that it picks the cached file when no internet
(The more descriptive your answer, the faster we are able to help you)
Please provide a link to a minimal sample where the issue is reproducible:
Hello, I’m Ron, an automated tech support bot
While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:
Thanks for contacting us. Could you describe in detail how you’re opening documents? Are you opening documents via URL?
Also, would it be possible if you could send us some complete sample snippets or a sample project? It would be very helpful for our investigation.
Apologies for the multiple messages. In this case, could you could try calling the following PDFViewCtrl API:
public PDFDoc openPDFUri (Uri, String, String, PDFViewCtrl.HTTPRequestOptions) ?
Using this version of openPDFUri, you can specify the cache location (third parameter) for URL links.
Thanks for the reply. I will try & update to you.
hi, can show me code to can use feature stream pdf for android ?
It is possible to open and stream a PDF using our SDK.
We have a full guide on how to open and stream a PDF which you can find here.
Please let us know if this solution works for you.
Because I use react native framework and I don’t know deeply about java code, can give some example git repo to help me?
I had read code from the android native of pdftron SDK but I don’t know where the file to apply code above.
Our react native library uses streaming by default when passing in HTTP/HTTPS files into the pdf viewer.
Can you ensure the PDF is linearized as mentioned in the guide.
Are you currently encountering any issues with streaming a document using react native?
How to know it working? Because with document is must be use function
mPdfViewCtrl.openUrlAsync but in my code just use
Uri fileUri = ReactUtils.getUri(getContext(), path, false); mPdfDoc = openPDFUri(fileUri, "");
What different with 2 method?
Just to further clarify, streaming in this case refers to showing partial PDF content while downloading online PDFs as described here. Is this what you’re looking for? If not could you describe your use case?
In React Native you can load and view a document using the following code :
If you enter a file location as a URL this will automatically stream a file assuming your server side client is setup to handle byte ranges and your document is linearized. You do not need to modify Java code to get streaming to work by default in our React Native viewer.
As for your specific question, openUrlAsync opens URL documents and openPDFUri will open any PDF (i.e. local file path, or URL). Internally, openPDFUri will call openUrlAsync if the Uri points to a URL. You can test that this is working by viewing a large document. If streaming is working properly then you should be able to see the document in the viewer very quickly even before the entire document has finished downloading.
I had understood, so can explain me how to handle server side client is setup to handle byte ranges and your document is linearized.
Server side you need two things.
- The PDF files need to be linearized (also known as Fast Web View). You can check this using the Document Properties dialog in Adobe for instance.
If they are not linearized you would have to pre-process them using a server side SDK such as ours.
- Your file server needs to support byte range requests.