Accusoft.PdfXpress7.Net
View PDF

ImagXpress® can be used in conjunction with PDF Xpress™ to display PDF pages. Assign bitmaps rendered using PDF Xpress to an ImagXpress ImageXView object to leverage its image-viewing features.

To view a PDF document page:

  1. Create a Document for an existing PDF document.
  2. Invoke RenderOptionsToBitmap to produce a System.Drawing.Bitmap for an area on the page, at a target device resolution.
  3. Create an ImageX object with ImageX.FromBitmap using the rendered System.Drawing.Bitmap.
  4. Assign to the ImageXView property Image the new ImageX object.
C# Example
Copy Code
using System;
using System.Windows.Forms;
namespace PdfViewerApplication
{
    public partial class PdfViewerForm : Form
    {
        public PdfViewerForm()
        {
            InitializeComponent();
        }
        Accusoft.ImagXpressSdk.ImagXpress imagXpressInstance = null;
        Accusoft.ImagXpressSdk.ImageXView imageXViewInstance = null;
        private void RenderImageButton_Click(object sender, EventArgs e)
        {
            // This code demonstrates rendering a single page PDF file using the ImageXView control
            Accusoft.PdfXpressSdk.PdfXpress pdfXpressInstance = null;
            Accusoft.PdfXpressSdk.RenderOptions options = null;
            Accusoft.PdfXpressSdk.Document documentOpened = null;
            try
            {
                imagXpressInstance = new Accusoft.ImagXpressSdk.ImagXpress();
                pdfXpressInstance = new Accusoft.PdfXpressSdk.PdfXpress();
                pdfXpressInstance.Initialize();
                imageXViewInstance = new Accusoft.ImagXpressSdk.ImageXView(imagXpressInstance);
                imageXViewInstance.AutoResize = Accusoft.ImagXpressSdk.AutoResizeType.BestFit;
                imageXViewInstance.Location = new System.Drawing.Point(3, 16);
                imageXViewInstance.Size = new System.Drawing.Size(652, 481);
                imageXViewInstance.TabIndex = 1;
                this.Controls.Add(imageXViewInstance);
                //render at 200DPI
                options = new Accusoft.PdfXpressSdk.RenderOptions();
                options.ResolutionX = 200;
                options.ResolutionY = 200;
                documentOpened = new Accusoft.PdfXpressSdk.Document(pdfXpressInstance, "C:\\test.pdf");
                //render first page
                int pageNumber = 0;
                imageXViewInstance.Image = Accusoft.ImagXpressSdk.ImageX.FromBitmap(imagXpressInstance, documentOpened.RenderPageToBitmap(pageNumber, options));
            }
            finally
            {
                if (null != documentOpened)
                {
                    documentOpened.Dispose();
                    documentOpened = null;
                }
                if (null != pdfXpressInstance)
                {
                    pdfXpressInstance.Dispose();
                    pdfXpressInstance = null;
                }
            }
        }
    }
}

 The following code should be called in PdfViewerApplication.PdfViewerForm.Dispose(bool disposing):

C# Example
Copy Code
if (imageXViewInstance != null)
{
      if (imageXViewInstance.Image != null)
      {
            imageXViewInstance.Image.Dispose();
            imageXViewInstance.Image = null;
      }
      imageXViewInstance.Dispose();
      imageXViewInstance = null;
}
if (imagXpressInstance != null)
{
      imagXpressInstance.Dispose();
      imagXpressInstance = null;
}
See Also

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback