自定义文档查看功能
IEnumerator LoadPdfBytes( string _path)
{
WWW request = new WWW(_path);
yield return request;
if (request.isDone)
{
PDFDocument document = new PDFDocument(request.bytes, "");
int pageCount = document.GetPageCount();
for (int i = 0; i < contentFather.childCount; i++)
{
Destroy(contentFather.GetChild(i).gameObject);
}
for (int i = 0; i < pageCount; i++)
{
PDFPage pdf = document.GetPage(i);
PDFRenderer render = new PDFRenderer();
Texture2D texture = render.RenderPageToTexture(pdf, 598 * 3, 842 * 3);
GameObject raw = Instantiate((GameObject)Resources.Load("Item/itemPDF"));
raw.transform.SetParent(contentFather);
raw.GetComponent<RawImage>().texture = texture;
raw.transform.localScale = Vector3.one;
}
}
else
{
Debug.Log(request.error);
}
}