Windows Phone 8.1 中的 PDF
Pdf in Windows Phone 8.1
因为 PdfDocument class 仅在 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);
}
您可以试试 MuPDF:https://github.com/MishaUliutin/MuPDF.WinRT .
MuPDF.WinRT is a lightweight PDF, XPS and CBZ viewer and
parser/rendering WinRT component.
如果这不起作用.. 请同时查看此库:
http://www.xfiniumpdf.com/xfinium-pdf-downloads.html
因为 PdfDocument class 仅在 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);
}
您可以试试 MuPDF:https://github.com/MishaUliutin/MuPDF.WinRT .
MuPDF.WinRT is a lightweight PDF, XPS and CBZ viewer and parser/rendering WinRT component.
如果这不起作用.. 请同时查看此库: http://www.xfiniumpdf.com/xfinium-pdf-downloads.html