Accusoft.PdfXpress7.Net
Convert Image to PDF

To create an image-only PDF, first create a new document object, using the Document Constructor.

PDF Xpress™ does not offer native decompression of image streams used to create PDF pages. ImagXpress® can be used in conjunction with PDF Xpress to provide file decompression and format conversion.
C# Example
Copy Code
            // This code demonstrates converting an image file to a single page PDF file
            PdfXpress pdfXpress = null;
            Document outputDocument = null;
            try
            {
                pdfXpress = new PdfXpress();
                pdfXpress.Initialize();
                outputDocument = new Document(pdfXpress);
                PageOptions pageOptions = new PageOptions();
                pageOptions.MediaWidth = 8.5 * 72.0;
                pageOptions.MediaHeight = 11.0 * 72.0;
                outputDocument.CreatePage(-1, pageOptions);
                String inputFilename = "C:\\pdftest.bmp";
                int pageNumber = 0;
                int SourcepageNumber = 0;
                double destinationX = 0.25 * 72.0;
                double destinationY = 0.25 * 72.0;
                double destinationWidth = pageOptions.MediaWidth - 0.5 * 72.0;
                double destinationHeight = pageOptions.MediaHeight - 0.5 * 72.0;
                ImageFitSettings destinationFit = ImageFitSettings.Shrink;
                outputDocument.AddImage(pageNumber, destinationX, destinationY, destinationWidth, destinationHeight, destinationFit, inputFilename, SourcepageNumber);
            }
            catch (System.Exception)
            {
            }
            finally
            {
                if (null != outputDocument)
                {
                    outputDocument.Dispose();
                }
            }

See Also

 

 


©2015. Accusoft Corporation. All Rights Reserved.

Send Feedback