Exemplo n.º 1
0
        private void RenderPage(Apitron.PDF.Rasterizer.Page page)
        {
            if (page != null)
            {
                ErrorLogger logger = new ErrorLogger();

                WriteableBitmap bm = page.Render(new Resolution(96, 96), new RenderingSettings(), logger);

                myImage.Source = bm;
            }
        }
        /// <summary>
        /// Handles Render button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnRenderClicked(object sender, RoutedEventArgs e)
        {
            // get the assets folder for the app
            StorageFolder folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");

            // get the file included in app assets
            StorageFile file = await folder.GetFileAsync("testfile.pdf");

            // open the file and render first page
            using (Stream stream = await file.OpenStreamForReadAsync())
            {
                Document doc = new Document(stream);

                Apitron.PDF.Rasterizer.Page page = doc.Pages[0];

                ErrorLogger logger = new ErrorLogger();

                WriteableBitmap bm = page.Render((int)page.Width, (int)page.Height, new RenderingSettings(), logger);

                myImage.Source = bm;
            }
        }