public class

DocumentPreviewCache

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.DocumentPreviewCache

Class Overview

DocumentPreviewCache is a persistent cache that provides thumbnails for browsing in PDFNet. The cache is placed in the sub-directory 'trn_DocumentPreviewCache' of the PDFNet Resources folder, which can be set by calling PDFNet::SetPersistentCachePath. In the case the PersistentCachePath is not set the files will be stored in the system temp path (PDFNet::GetSystemTempPath()). The cache will be used by any PDFNet process that uses the resource path. If more than one PDFNet process is running concurrently, the first process to acquire a lock on the cache will use it. Subsequent processes will not read or modify the cache. DocumentPreviewCache will store references to generated JPG thumbnails and keeps track of the dimensions of the thumbnail and the filesize of the specific pdf documents. Furthermore it takes care that the size constraints (max_cache_bytes, max_disk_percentage) are met and in cleans the oldest (in terms of last request) thumbs from the cache in case of a overflow. If the user requests a file that is already in the cache and the requested thumb dimensions are smaller or equal than the ones of the cache-version the URL of the cached thumb is given back. If the dimensions are bigger the thumb gets rendered again, the old thumb gets replaced and the URL is given back. If the size of the pdf document changes the thumb will be rendered again even when there is a version of that thumbnail in the cache. In case that the user wants to suppress the re-rendering of that specific thumb (e.g. when the change on the pdf document was made on another page than the first page which is used for the thumb), IrrelevantChangeMade has to be called.

Summary

Public Constructors
DocumentPreviewCache()
Public Methods
static void cancelAllRequests()
CancelAllRequests cancels all pending requests.
static void cancelRequest(String filepathOrUuid)
CancelRequest cancels all pending thumbnail requests associated with 'filepathOrUuid'.
static void clearCache()
Remove the cache from the disk completely, deleting any thumbnails.
static void createBitmapWithID(String uuid, Filter filter, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)
createBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'.
static void createBitmapWithID(String uuid, PDFDoc doc, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)
createBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'.
static void getBitmapWithID(String uuid, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)
getBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'.
static void getBitmapWithID(String uuid, Filter filter, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)
getBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'.
static void getBitmapWithPath(String filepath, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)
getBitmapWithPath gets the path to the thumbnail in the DocumentPreviewCache associated with the document at 'filepath'.
static void initialize(long max_cache_bytes, double max_disk_percentage)
Initialize the preview cache.
static void irrelevantChangeMade(String filepath)
IrrelevantChangeMade should be called if the size of the pdf file at 'filepath' was changed but the thumbnail should not be re-generated.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DocumentPreviewCache ()

Public Methods

public static void cancelAllRequests ()

CancelAllRequests cancels all pending requests. The PreviewHandler of each pending request will signal that the preview could not be found.

public static void cancelRequest (String filepathOrUuid)

CancelRequest cancels all pending thumbnail requests associated with 'filepathOrUuid'. If the cancel request is processed earlier than the path of the thumbnail could be retrieved the respective request will be cancelled and the PreviewHandler will signal that the thumb could not be found.

Parameters
filepathOrUuid - URL of pdf file or uuid

public static void clearCache ()

Remove the cache from the disk completely, deleting any thumbnails. You may want to do this if you detect some kind of corruption, or if the user wants to clear out disk space used by your application.

public static void createBitmapWithID (String uuid, Filter filter, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)

createBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'. This method should be used together with getBitmapWithID. The decision if the thumb should be re-rendered is based on two factors. First if the current version fulfills the minimal dimensions 'min_x_size' x 'min_y_size' and second if the size of the pdf document hasn't changed. To signal an edit of the pdf document without a resulting re-rendering of the thumb see IrrelevantChangeMade.

Parameters
uuid - The uuid of the PDFDoc
filter - Input filter for the Doc
min_x_size - Minimal width of the thumbnail.
min_y_size - Minimal height of the thumbnail.
proc - A callback function that will be called after the thumbnail is retrieved, or if that retrieval fails.
custom_data - Custom data to be passed to the PreviewHandler.

public static void createBitmapWithID (String uuid, PDFDoc doc, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)

createBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'. This method should be used together with getBitmapWithID. The decision if the thumb should be re-rendered is based on two factors. First if the current version fulfills the minimal dimensions 'min_x_size' x 'min_y_size' and second if the size of the pdf document hasn't changed. To signal an edit of the pdf document without a resulting re-rendering of the thumb see IrrelevantChangeMade.

Parameters
uuid - The uuid of the PDFDoc
doc - The PDFDoc whose thumbnail to create
min_x_size - Minimal width of the thumbnail.
min_y_size - Minimal height of the thumbnail.
proc - A callback function that will be called after the thumbnail is retrieved, or if that retrieval fails.
custom_data - Custom data to be passed to the PreviewHandler.

public static void getBitmapWithID (String uuid, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)

getBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'. This method should be used together with createBitmapWithID. The decision if the thumb should be re-rendered is based on two factors. First if the current version fulfills the minimal dimensions 'min_x_size' x 'min_y_size' and second if the size of the pdf document hasn't changed. To signal an edit of the pdf document without a resulting re-rendering of the thumb see IrrelevantChangeMade.

Parameters
uuid - The uuid of the PDFDoc added by createBitmapWithID
min_x_size - Minimal width of the thumbnail.
min_y_size - Minimal height of the thumbnail.
proc - A callback function that will be called after the thumbnail is retrieved, or if that retrieval fails.
custom_data - Custom data to be passed to the PreviewHandler.

public static void getBitmapWithID (String uuid, Filter filter, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)

getBitmapWithID gets the path to the thumbnail in the DocumentPreviewCache associated with the document with 'uuid'. This method should be used together with createBitmapWithID. The decision if the thumb should be re-rendered is based on two factors. First if the current version fulfills the minimal dimensions 'min_x_size' x 'min_y_size' and second if the size of the pdf document hasn't changed. To signal an edit of the pdf document without a resulting re-rendering of the thumb see IrrelevantChangeMade.

Parameters
uuid - The uuid of the PDFDoc added by createBitmapWithID
min_x_size - Minimal width of the thumbnail.
min_y_size - Minimal height of the thumbnail.
proc - A callback function that will be called after the thumbnail is retrieved, or if that retrieval fails.
custom_data - Custom data to be passed to the PreviewHandler.

public static void getBitmapWithPath (String filepath, int min_x_size, int min_y_size, PreviewHandler proc, Object custom_data)

getBitmapWithPath gets the path to the thumbnail in the DocumentPreviewCache associated with the document at 'filepath'. The decision if the thumb should be re-rendered is based on two factors. First if the current version fulfills the minimal dimensions 'min_x_size' x 'min_y_size' and second if the size of the pdf document hasn't changed. To signal an edit of the pdf document without a resulting re-rendering of the thumb see IrrelevantChangeMade.

Parameters
filepath - The URL of the pdf file.
min_x_size - Minimal width of the thumbnail.
min_y_size - Minimal height of the thumbnail.
proc - A callback function that will be called after the thumbnail is retrieved, or if that retrieval fails.
custom_data - Custom data to be passed to the PreviewHandler.

public static void initialize (long max_cache_bytes, double max_disk_percentage)

Initialize the preview cache. If the cache already exists, it will shrink to conform to these limits immediately.

Parameters
max_cache_bytes The absolute maximum size on disk for the temporary preview cache in bytes.
max_disk_percentage The maximum percentage of free disk space that the cache can take up (0 - 1.0).

public static void irrelevantChangeMade (String filepath)

IrrelevantChangeMade should be called if the size of the pdf file at 'filepath' was changed but the thumbnail should not be re-generated. This should be done when no editing was done on the first page of the document. This method does not work on bitmaps associated with uuids

Parameters
filepath - URL of pdf file