Example #1
0
        public static PDFJS_Promise <Texture2D> RenderPageToTextureAsync(PDFPage page, Vector2 size)
        {
            PDFJS_Promise <Texture2D> renderPromise = new PDFJS_Promise <Texture2D>();

#if !UNITY_WEBGL || UNITY_EDITOR
            using (PDFRenderer renderer = new PDFRenderer())
            {
                renderPromise.HasFinished           = true;
                renderPromise.HasSucceeded          = true;
                renderPromise.HasReceivedJSResponse = true;
                renderPromise.Result = renderer.RenderPageToTexture(page, (int)size.x, (int)size.y);
            }
#else
            RenderPageParameters parameters = new RenderPageParameters(page.NativePointer, null, size);

            PDFJS_Library.Instance.PreparePromiseCoroutine(RenderPageCoroutine, renderPromise, parameters).Start();
#endif
            return(renderPromise);
        }
Example #2
0
        public static PDFJS_Promise <Texture2D> RenderPageToExistingTextureAsync(PDFPage page, Texture2D tex)
        {
            PDFJS_Promise <Texture2D> renderPromise = new PDFJS_Promise <Texture2D>();

#if !UNITY_WEBGL || UNITY_EDITOR
            using (PDFRenderer renderer = new PDFRenderer())
            {
                renderPromise.HasFinished           = true;
                renderPromise.HasSucceeded          = true;
                renderPromise.HasReceivedJSResponse = true;
                renderer.RenderPageToExistingTexture(page, tex);
                renderPromise.Result = tex;
            }
#else
            RenderPageParameters parameters = new RenderPageParameters(page.NativePointer, tex, new Vector2(tex.width, tex.height));

            PDFJS_Library.Instance.PreparePromiseCoroutine(RenderPageCoroutine, renderPromise, parameters).Start();
#endif

            return(renderPromise);
        }