PDF Renderer
Support
dave.paroxe@gmail.com
Table of Contents
1. PDFRenderer API..................................................................................................................................3
1.1 PDFDocument......................................................................................................................................3
1.1.1 Constructors......................................................................................................................................3
1.1.2 Properties..........................................................................................................................................3
1.1.3 Methods.............................................................................................................................................3
1.1.4 Example of use..................................................................................................................................5
2. PDFViewer.............................................................................................................................................6
2.1 PDFViewer inspector...........................................................................................................................8
2.1.1 Loading options.................................................................................................................................9
2.1.2 Viewer settings................................................................................................................................11
2.1.3 Rendering options...........................................................................................................................12
1. PDFRenderer API
1.1 PDFDocument
This class represents a pdf document. It allows to render a page in a new 2DTexture, in an already
existing 2DTexture, and to get information on the documents and pages.
1.1.1 Constructors
PDFDocument(byte[] buffer, string password)
PDFDocument(string filePath, string password)
Pdf document class constructors. The pasword field can be null even if the document is not
protected.
1.1.2 Properties
bool IsValid
This property indicate if the document is in fact valid. It can be invalid when the buffer or the
path is invalid. It can also be invalidif the document is protected of itf the specified password is
invalid.
1.1.3 Methods
int GetPageCount()
Get the page number in the document.
int GetPageWidth(int pageIndex)
int GetPageHeight(int pageIndex)
Vector2 GetPageSize(int pageIndex)
These methods allow to have the size of the page specified in parameter.
Texture2D RenderPageToTexture(int pageIndex, RenderSettings renderSettings)
Texture2D RenderPageToTexture(int pageIndex, int width, int height, RenderSettings renderSettings)
Creates the page render in a new texture according to the rendering options specified in
parameter. Do not forget to release this texture when not any more needed. Here is how to
release the texture which does not serve any more
DestroyImmediate(tex);
Resources.UnloadAsset(tex);
void RenderPageToExistingTexture(int pageIndex, Texture2D texture, RenderSettings renderSettings)
Allows to render in an already existing texture. For a faster render, the texture should be in the
RGBA32 format and does not contain MipMap. Should the opposite occur, PDFRenderer do the
render using another method supporting more formats but a lot slower. Here is the instanciation
of an ideal texture for PDFRenderer:
Texture2D tex = new Texture2D(width, height, TextureFormat.RGBA32, false);
评论0