Url Data Provider
A data provider that downloads a PDF from a given remote URL.
Can be used directly with
PdfActivityIntentBuilder.fromDataProvider
/PdfActivityIntentBuilder.fromImageProvider
for loading and displaying documents.If you just want to load a document you can wrap the data provider into a
DocumentSource
and pass it toPdfDocumentLoader.openDocument
/ImageDocumentLoader.openDocument
. You must not do this on the main thread, as the operation would block it until the download is finished. A DownloadException.DownloadOnMainThreadException will be thrown if you try it nonetheless.
We provide 2 options for the download
If you pass
null
for targetFile, the file is downloaded into the a sub folder of the app's cache directory. The cached file will not be reused the next time you open the same URL, but the file will be downloaded again. The OS cleans an app's cache directory when the device is running low on storage, but you can also manually delete the cached files by calling deleteCachedFileForUrl or deleteCachedFiles.If you pass a targetFile, the file referenced by url is downloaded into the given file. This file will be reused the next time you open the same URL. It can be any path that the app has write access to. It's your responsibility to delete this files when they are not needed anymore.
Functions
Return the actual file size of the PDF document which is provided by this data provider. If the data provider can't determine the correct file size (e.g. in case of an error) this method has to return FILE_SIZE_UNKNOWN.
Returns an Flowable that emits values from 0 to 1 indicating the current loading progress of this document. You can return ProgressDataProvider.COMPLETE if you don't want to provide progress updates.