示例#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;
            }
        }
示例#2
0
        private void UpdatePageView()
        {
            Page currentPage   = this.document.Page;
            int  desiredWidth  = (int)currentPage.Width * GlobalScale;
            int  desiredHeight = (int)currentPage.Height * GlobalScale;

            byte[]       image = currentPage.RenderAsBytes(desiredWidth, desiredHeight, new RenderingSettings());
            IList <Link> links = currentPage.Links;

            SetImageSourceDelegate del = this.SetImageSource;                       //gán sự kiện vào hàm delegate

            this.Dispatcher.Invoke(del, image, links, desiredWidth, desiredHeight); //thực hiện hàm
        }
 private void UpdatePageView()
 {
     if (recentLocation != 0)
     {
         document.Document.Navigator.GoToPage(recentLocation);
         recentLocation = -1;
     }
     try
     {
         Page                   currentPage   = this.document.Page;
         int                    desiredWidth  = (int)currentPage.Width * GlobalScale;
         int                    desiredHeight = (int)currentPage.Height * GlobalScale;
         byte[]                 image         = currentPage.RenderAsBytes(desiredWidth, desiredHeight, new RenderingSettings());
         IList <Link>           links         = currentPage.Links;
         SetImageSourceDelegate del           = this.SetImageSource;             //add event into delegate
         this.Dispatcher.Invoke(del, image, links, desiredWidth, desiredHeight); //execute SetImageSource
     }
     catch (Exception)
     {
     }
 }
        /// <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;
            }
        }