public static final class

DownloadRequest.Builder

extends Object
java.lang.Object
   ↳ com.pspdfkit.document.download.DownloadRequest.Builder

Class Overview

Builder for a DownloadRequest.

Summary

Public Constructors
Builder(Context context)
Create a builder with default settings.
Public Methods
DownloadRequest build()
Create a DownloadRequest from the current settings.
DownloadRequest.Builder outputFile(File outputFile)
Set the outputFile for the download.
DownloadRequest.Builder outputFolder(File outputFolder)
Set the outputFolder for the download.
DownloadRequest.Builder overwriteExisting(boolean overwriteExisting)
If set to true and the outputFile already exists, the download re-download the document.
DownloadRequest.Builder source(DownloadSource source)
Set a DownloadSource from which to download.
DownloadRequest.Builder uri(Uri uri)
Set the download source from a Uri.
DownloadRequest.Builder uri(String uri)
Same as uri(Uri) but parses the given String to a Uri.
DownloadRequest.Builder useTemporaryOutputFile(boolean useTemporaryOutputFile)
If set to true, the download will write to a temporary file with the same path and filename as the output file but append .tmp to it.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Builder (Context context)

Create a builder with default settings.

Parameters
context Context for resolving resources.

Public Methods

public DownloadRequest build ()

Create a DownloadRequest from the current settings.

Returns

public DownloadRequest.Builder outputFile (File outputFile)

Set the outputFile for the download.

Parameters
outputFile Writable output File for the download.

public DownloadRequest.Builder outputFolder (File outputFolder)

Set the outputFolder for the download. When using this method the PDF will use a generated filename derived from the system time. If you want to explicitly specify the output filename use outputFile(File) instead.

Parameters
outputFolder File pointing to the download output directory.

public DownloadRequest.Builder overwriteExisting (boolean overwriteExisting)

If set to true and the outputFile already exists, the download re-download the document. If set to false the download will complete immediately returning the existing file.

Parameters
overwriteExisting true to re-download in case the output file already exists.

public DownloadRequest.Builder source (DownloadSource source)

Set a DownloadSource from which to download.

Parameters
source DownloadSource pointing to the PDF document.

public DownloadRequest.Builder uri (Uri uri)

Set the download source from a Uri.

Valid URI examples:

  • Content provider: content://com.pspdfkit.viewer/documents/demo.pdf
  • Asset paths: file://android_asset/demo.pdf
  • Web URLs: https://www.example.com/demo.pdf

Parameters
uri Uri of the document to download.
Throws
IllegalArgumentException If the given uri was unrecognized or invalid.

public DownloadRequest.Builder uri (String uri)

Same as uri(Uri) but parses the given String to a Uri.

Parameters
uri A string representation of a Uri.

public DownloadRequest.Builder useTemporaryOutputFile (boolean useTemporaryOutputFile)

If set to true, the download will write to a temporary file with the same path and filename as the output file but append .tmp to it. If false the download will be written directly into the output file. Defaults to true.

Parameters
useTemporaryOutputFile true to use a temporary output file while downloading, or false to directly write into the ultimate output file.