【问题标题】:Get image cover from first page pdf file on windows phone 8.1从 Windows Phone 8.1 上的第一页 pdf 文件获取图像封面
【发布时间】:2015-04-16 07:21:33
【问题描述】:

如何从 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)

无法识别。有没有替代代码?

【问题讨论】:

    标签: c# pdf image-processing windows-phone-8.1


    【解决方案1】:

    Windows Phone 8.1 不支持 Windows.Data.PDF。最好的选择是使用 3rd 方库为您解析文件。

    您可能想查看是否有可以使用的第 3 方库,或者可能在服务器上进行提取

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多