簡體   English   中英

從Windows Phone 8.1的首頁pdf文件獲取圖像封面

[英]Get image cover from first page pdf file on windows phone 8.1

如何從Windows Phone 8.1的首頁pdf文件獲取圖像封面。

在Windowsrt(Windows 8.1)中,我使用以下代碼:

private PdfDocument _pdfDocument;
private async Task RenderCoverBuku(string pdfFileName, uint PDF_PAGE_INDEX)
        {
            try
            {
                StorageFolder koleksibuku = await installedLocation.CreateFolderAsync("koleksibuku", CreationCollisionOption.OpenIfExists);

                StorageFile pdfFile = await koleksibuku.GetFileAsync(pdfFileName);
                //Load Pdf File

                _pdfDocument = await PdfDocument.LoadFromFileAsync(pdfFile); ;

                if (_pdfDocument != null && _pdfDocument.PageCount > 0)
                {
                    //Get Pdf page
                    var pdfPage = _pdfDocument.GetPage(PDF_PAGE_INDEX);

                    if (pdfPage != null)
                    {
                        // next, generate a bitmap of the page
                        StorageFolder thumbfolder = await installedLocation.CreateFolderAsync("thumb", CreationCollisionOption.OpenIfExists);

                        StorageFile jpgFile = await thumbfolder.CreateFileAsync(pdfFileName + ".png", CreationCollisionOption.ReplaceExisting);

                        if (jpgFile != null)
                        {
                            IRandomAccessStream randomStream = await jpgFile.OpenAsync(FileAccessMode.ReadWrite);
 await pdfPage.RenderToStreamAsync(randomStream);
 await randomStream.FlushAsync();

                            randomStream.Dispose();
                            pdfPage.Dispose();
                            //await this.resfreshcontent();
                        }
                    }
                }
            }
            catch (Exception err)
            {
                //rootPage.NotifyUser("Error: " + err.Message, NotifyType.ErrorMessage);

            }
        }

但是在Windows Phone中:

private PdfDocument _pdfDocument (using Windows.Data.Pdf)

無法識別。 是否有其他替代代碼?

Windows Phone 8.1不支持Windows.Data.PDF。 最好的選擇是使用第三方庫為您解析文件。

您可能要查看是否存在可以使用的第三方庫,或者是否可以在服務器上進行提取

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM