MishaUliutin / MuPDF.WinRT

Windows 8 and Windows Phone 8 WinRT component - MuPDF wrapper
GNU General Public License v3.0
26 stars 24 forks source link

failed to draw page from a partial PDF #4

Closed WalterShao closed 11 years ago

WalterShao commented 11 years ago

Hi,

I got a PDF file which has required headers and pdf objects for rendering page #1 (but lacking other page objects, total 16 pages). I can use other PDF viewers (such as Adobe reader or Foxit Reader) to open the pdf and read the page #1. I can also mupdf win32 viewer to read page #1. However, when I use the MuPDF.WinRT to draw page #1, it throws an unknown exception. Since the mupdf win32 viewer can read the pdf successfully, I guess MuPDF.WinRT do more checking so that it failed to read the pdf. Would you please help to skip the checking so that it can render the partial pdf file as mupdf win32 viewer can do?

The following is my code in c#:

StorageFile dlFile = await ApplicationData.Current.LocalFolder.GetFileAsync("partial.pdf");

IBuffer pdfBuffer = await FileIO.ReadBufferAsync(dlFile); Document pdfDocHandle = Document.Create(pdfBuffer, // - file DocumentType.PDF, // type 150); // - dpi try { MuPDFWinRT.Point sizeP = pdfDocHandle.GetPageSize(1); WriteableBitmap tmpBmp = new WriteableBitmap(sizeP.X, sizeP.Y); pdfDocHandle.DrawPage(1, tmpBmp.PixelBuffer, 0, 0, sizeP.X, sizeP.Y, false); tmpBmp.Invalidate(); imgPdf.Source = tmpBmp; } catch (Exception ex) { Debug.WriteLine("MuPDF error on showing page:1, ex=" + ex.Message); }

I'd like to upload the partial pdf for reference, but don't know how to do it. Please let me know how to give the partial pdf to you if needed. Thanks.

MishaUliutin commented 11 years ago

Could you send this pdf file to mishacertificate at gmail.com email please?

WalterShao commented 11 years ago

Sent. Let me know if you didn't get it. Thanks.

WalterShao commented 11 years ago

Sorry, please ignore this issue. The failure is due to my code's bug. I have fixed the bug.