VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
В этом разделе
    Кодеки: Как cконвертировать DOCX/DOC в PDF?
    В этом разделе
    SDK может конвертировать DOCX/DOC-документ в векторный PDF- или PDF/A-документ с текстом, ссылками и навигацией.

    Вот C#/VB.NET код, который демонстрирует, как преобразовать DOCX/DOC-документ в PDF документ:
    /// <summary>
    /// Converts DOCX document to a PDF document using ImageCollection and PdfEncoder classes.
    /// </summary>
    public static void ConvertDocxToPdf(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();
        }
    }
    
    ''' <summary>
    ''' Converts DOCX document to a PDF document using ImageCollection and PdfEncoder classes.
    ''' </summary>
    Public Shared Sub ConvertDocxToPdf(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
    


    Вот C#/VB.NET код, который демонстрирует, как конвертировать DOCX/DOC-документ в PDF/A-1b документ:
    /// <summary>
    /// Converts DOCX document to a PDF/A-1b document using ImageCollection and PdfEncoder classes.
    /// </summary>
    public static void ConvertDocxToPdfA1b(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();
        }
    }
    
    ''' <summary>
    ''' Converts DOCX document to a PDF/A-1b document using ImageCollection and PdfEncoder classes.
    ''' </summary>
    Public Shared Sub ConvertDocxToPdfA1b(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