Windows Phone 8.1中的Pdf

frenk91

由于PdfDocument类仅在Windows 8.1中可用,因此在Windows Phone 8.1(Windows运行时)中可以使用某些东西在我的应用程序中呈现pdf文件吗?

编辑

MuPdf很棒!但是要使其在Windows Phone项目中工作,我必须手动编辑.csproj

我必须添加此代码:

<Reference Include="MuPDFWinRT, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL" Condition="'$(Platform)'=='x86'">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\MuPDF\x86\MuPDFWinRT.winmd</HintPath>
</Reference>
<Reference Include="MuPDFWinRT, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL" Condition="'$(Platform)'=='ARM' ">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\MuPDF\ARM\MuPDFWinRT.winmd</HintPath>
</Reference>

这是一个用法示例:

IBuffer readBuffer = pdf.AsBuffer();

var pdfDocument = Document.Create(readBuffer, DocumentType.PDF, (int)Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi);

List<WriteableBitmap> imageList = new List<WriteableBitmap>();

for (int i = 0; i < pdfDocument.PageCount; i++)
{
    var size = pdfDocument.GetPageSize(i);
    var width = size.X;
    var height = size.Y;

    var image = new WriteableBitmap(width, height);
    IBuffer buf = new Buffer(image.PixelBuffer.Capacity);
    buf.Length = image.PixelBuffer.Length;

    pdfDocument.DrawPage(i, buf, 0, 0, width, height, false);

    using (var stream = buf.AsStream())
    {
        await stream.CopyToAsync(image.PixelBuffer.AsStream());
    }

    imageList.Add(image);
}
纳赛尔·纳赛尔(Nasser AlNasser)

您可以尝试使用MuPDF:https//github.com/MishaUliutin/MuPDF.WinRT

MuPDF.WinRT是一个轻量级的PDF,XPS和CBZ查看器以及解析器/渲染WinRT组件。

如果这不起作用..请同时访问此库:http : //www.xfiniumpdf.com/xfinium-pdf-downloads.html

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章