PDFDocumentRenderToTextureExample.cs 810 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. namespace Paroxe.PdfRenderer.Examples
  3. {
  4. public class PDFDocumentRenderToTextureExample : MonoBehaviour
  5. {
  6. public int m_Page = 0;
  7. #if !UNITY_WEBGL
  8. void Start()
  9. {
  10. PDFDocument pdfDocument = new PDFDocument(PDFBytesSupplierExample.PDFSampleByteArray, "");
  11. if (pdfDocument.IsValid)
  12. {
  13. int pageCount = pdfDocument.GetPageCount();
  14. PDFRenderer renderer = new PDFRenderer();
  15. Texture2D tex = renderer.RenderPageToTexture(pdfDocument.GetPage(m_Page % pageCount), 1024, 1024);
  16. tex.filterMode = FilterMode.Bilinear;
  17. tex.anisoLevel = 8;
  18. GetComponent<MeshRenderer>().material.mainTexture = tex;
  19. }
  20. }
  21. #endif
  22. }
  23. }