Accusoft.PdfXpress5.Net
Pass Image Data between Accusoft Components
Send Feedback
PDF Xpress 5 for .NET - User Guide > How To > Pass Image Data between Accusoft Components

Glossary Item Box

Traditionally, transferring image data between Accusoft components has required passing the image data in a DIB format. But, with the release of PDF Xpress 5, we are adding a new method which allows you to easily copy image data from PDF Xpress to other Accusoft objects with just a single method call.

The CopyPageTo method makes a complete copy of the image data. When called, the destination object will contain its own separate copy of identical image data.

How to Transfer Image Data from PDF Xpress to ImagXpress

In the following example, we create a small, 24-bit red image object and save its image data to disk as "original.bmp". If you open this file, you will see a small red image. Then, we copy the rendering of the first page of the PDF document to the image object and then save the image again, this time as "copied.bmp". Since the image data inside of the rendering was completely copied to the image object, if you open this second file you will see the rendered PDF page.

C# Copy Code
using Accusoft.ImagXpressSdk;
using Accusoft.PdfXpressSdk;
using System.Drawing;
namespace CopyImageData
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ImagXpress ix = new ImagXpress())
            {
                using (ImageX image = new ImageX(ix, 400, 400, 24, Color.Red))
                {
                    using (PdfXpress pdf = new PdfXpress())
                    {
                        pdf.Initialize();
                        using (Document doc = new Document(pdf, "document.pdf"))
                        {
                            RenderOptions ro = new RenderOptions();
                            image.Save("original.bmp");
                            doc.CopyPageTo(image, 0, ro);
                            image.Save("copied.bmp");
                        }
                    }
                }
            }
        }
    }
}
©2012. Accusoft Corporation. All Rights Reserved.