简体   繁体   中英

Pdf in Windows Phone 8.1

Because the PdfDocument class is only available in Windows 8.1, there is something to use in a Windows phone 8.1 (windows runtime) for render a pdf file inside my app?

Edit

MuPdf Works great! But to make it work in a Windows Phone project i had to manually edit the .csproj

i had to add this code :

<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>

and this is a usage example:

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);
}

You could try MuPDF : https://github.com/MishaUliutin/MuPDF.WinRT .

MuPDF.WinRT is a lightweight PDF, XPS and CBZ viewer and parser/rendering WinRT component.

If that's not working.. please see this library as well : http://www.xfiniumpdf.com/xfinium-pdf-downloads.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM