示例#1
0
    void TextPageAPI(PDFDocument document)
    {
        Debug.Log("TEXTPAGE API-------------------------");

        PDFPage page = document.GetPage(1);

        Debug.Log("Page size: " + page.GetPageSize());

        PDFTextPage textPage   = page.GetTextPage();
        int         countChars = textPage.CountChars();

        Debug.Log("Page chars count: " + countChars);

        string str = textPage.GetText(0, countChars);

        Debug.Log("Page text: " + str);

        int rectCount = textPage.CountRects(0, countChars);

        Debug.Log("Rect count: " + rectCount);

        string boundedText = textPage.GetBoundedText(0, 0, page.GetPageSize().x, page.GetPageSize().y * 0.5f, 2000);

        Debug.Log("Bounded text: " + boundedText);
    }
示例#2
0
    IEnumerator Start()
    {
#if UNITY_WEBGL
        yield break;
#else
        Debug.Log(Application.persistentDataPath);

        m_Viewer.gameObject.SetActive(true);

        m_Viewer.LoadDocumentFromWeb("http://www.pdf995.com/samples/pdf.pdf", "");

        // Wait until the pdf document is loaded.
        while (!m_Viewer.IsLoaded)
        {
            yield return(null);
        }

        PDFDocument document = m_Viewer.Document;
        Debug.Log("Page count: " + document.GetPageCount());

        PDFPage firstPage = document.GetPage(0);
        Debug.Log("First Page Size: " + firstPage.GetPageSize());

        PDFTextPage firstTextPage = firstPage.GetTextPage();
        Debug.Log("First Page Chars Count: " + firstTextPage.CountChars());

        IList <PDFSearchResult> searchResults = firstTextPage.Search("the", PDFSearchHandle.MatchOption.NONE, 0);
        Debug.Log("Search Results Count: " + searchResults.Count);

        // Wait 2 seconds and then load another document
        yield return(new WaitForSeconds(2.0f));

        m_Viewer.LoadDocumentFromAsset(m_PDFAsset);
#endif
    }