display PDF in Windows store App RRS feed

  • Question

  • I am trying to display pdfs on my app (I can't use the PDF App, it has to be within my app), I am using the pdf API and it works fine, but the quality of the of the images is not that good, you can feel the difference, is there a way to improve the quality?

    here is a sample of my code:

            private async Task<BitmapImage> RenderPDFPage(string pdfFileName)
                    StorageFile pdfFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.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 tempFolder = ApplicationData.Current.TemporaryFolder;
                            StorageFile jpgFile = await tempFolder.CreateFileAsync(Guid.NewGuid().ToString() + ".jpeg", CreationCollisionOption.ReplaceExisting);
                            if (jpgFile != null)
                                IRandomAccessStream randomStream = await jpgFile.OpenAsync(FileAccessMode.ReadWrite);
                                PdfPageRenderOptions pdfPageRenderOptions = new PdfPageRenderOptions { DestinationWidth = (uint)Math.Ceiling(pdfPage.Size.Width), DestinationHeight = (uint)pdfPage.Size.Height }; 
                                await pdfPage.RenderToStreamAsync(randomStream);
                                await randomStream.FlushAsync();
                                BitmapImage src = new BitmapImage();
                                src.SetSource(await jpgFile.OpenAsync(FileAccessMode.Read));
                                return src;
                    return null;
                catch (Exception err)
                    return null;


    Tuesday, February 10, 2015 3:17 PM

All replies

  • If need better performance, you should post your wish to UserVoice.https://wpdev.uservoice.com/forums/110705-dev-platform
    Wednesday, February 11, 2015 2:50 PM