VintaSoft Imaging .NET SDK 11.0
In This Topic
    Codecs: How to convert DOCX to PDF?
    In This Topic

    SDK can convert DOCX document to a vector PDF or PDF/A document with text, links and navigation.

    Here is an example that shows how to convert DOCX document to a PDF document:

    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    
    ''' <summary>
    ''' Class shows how to convert DOCX document to PDF document using ImageCollection and PdfEncoder classes.
    ''' </summary>
    Public Class ConvertDocxToPdf
    
        ''' <summary>
        ''' Converts DOCX document to PDF document using ImageCollection and PdfEncoder classes.
        ''' </summary>
        Public Shared Sub Convert(docxFileName As String, pdfFileName As String)
            ' create image collection
            Using imageCollection As New Vintasoft.Imaging.ImageCollection()
                ' add DOCX document to collection
                imageCollection.Add(docxFileName)
    
                ' create pdfEncoder
                Using pdfEncoder As New Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(True)
                    ' set comression for image resources
                    pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg
    
                    ' save images of image collection to PDF document using PdfEncoder
                    imageCollection.SaveSync(pdfFileName, pdfEncoder)
                End Using
    
                ' dispose images
                imageCollection.ClearAndDisposeItems()
            End Using
        End Sub
    
    End Class
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    
    /// <summary>
    /// Class shows how to convert DOCX document to PDF document using ImageCollection and PdfEncoder classes.
    /// </summary>
    public class ConvertDocxToPdf
    {
    
        /// <summary>
        /// Converts DOCX document to PDF document using ImageCollection and PdfEncoder classes.
        /// </summary>
        public static void Convert(string docxFileName, string pdfFileName)
        {
            // create image collection
            using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
            {
                // add DOCX document to collection
                imageCollection.Add(docxFileName);
    
                // create pdfEncoder
                using (Vintasoft.Imaging.Codecs.Encoders.PdfEncoder pdfEncoder = 
                    new Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(true))
                {
                    // set comression for image resources
                    pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg;
    
                    // save images of image collection to PDF document using PdfEncoder
                    imageCollection.SaveSync(pdfFileName, pdfEncoder);
                }
    
                // dispose images
                imageCollection.ClearAndDisposeItems();
            }
        }
    
    }
    


    Here is an example that shows how to convert DOCX document to a PDF/A-1b document:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    
    ''' <summary>
    ''' Class shows how to convert DOCX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
    ''' </summary>
    Public Class ConvertDocxToPdfA1b
    
        ''' <summary>
        ''' Converts DOCX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
        ''' </summary>
        Public Shared Sub Convert(docxFileName As String, pdfFileName As String)
            ' create image collection
            Using imageCollection As New Vintasoft.Imaging.ImageCollection()
                ' add DOCX document to collection
                imageCollection.Add(docxFileName)
    
                ' create pdfEncoder
                Using pdfEncoder As New Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(True)
                    ' set PDF/A-1b (ISO 19005-1, Level B conformance)
                    pdfEncoder.Settings.Conformance = Vintasoft.Imaging.Pdf.PdfDocumentConformance.PdfA_1b
    
                    ' set CMYK ICC profile, which is used by PDF/A converter as a profile in DefaulRGB color space
                    pdfEncoder.Settings.PdfADefaultRgbIccProfileFilename = "DefaultRGB.icc"
    
                    ' set comression for image resources
                    pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg
    
                    ' save images of image collection to PDF/A-1b document using PdfEncoder
                    imageCollection.SaveSync(pdfFileName, pdfEncoder)
                End Using
    
                ' dispose images
                imageCollection.ClearAndDisposeItems()
            End Using
        End Sub
    
    End Class
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    
    /// <summary>
    /// Class shows how to convert DOCX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
    /// </summary>
    public class ConvertDocxToPdfA1b
    {
    
        /// <summary>
        /// Converts DOCX document to PDF/A-1b document using ImageCollection and PdfEncoder classes.
        /// </summary>
        public static void Convert(string docxFileName, string pdfFileName)
        {
            // create image collection
            using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
            {
                // add DOCX document to collection
                imageCollection.Add(docxFileName);
    
                // create pdfEncoder
                using (Vintasoft.Imaging.Codecs.Encoders.PdfEncoder pdfEncoder = 
                    new Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(true))
                {
                    // set PDF/A-1b (ISO 19005-1, Level B conformance)
                    pdfEncoder.Settings.Conformance = Vintasoft.Imaging.Pdf.PdfDocumentConformance.PdfA_1b;
                    
                    // set CMYK ICC profile, which is used by PDF/A converter as a profile in DefaulRGB color space
                    pdfEncoder.Settings.PdfADefaultRgbIccProfileFilename = "DefaultRGB.icc";
    
                    // set comression for image resources
                    pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg;
    
                    // save images of image collection to PDF/A-1b document using PdfEncoder
                    imageCollection.SaveSync(pdfFileName, pdfEncoder);
                }
    
                // dispose images
                imageCollection.ClearAndDisposeItems();
            }
        }
    
    }