VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Processing Namespace / PdfDocumentConverter Class / Convert Methods / Convert(String,String) Method
Syntax Remarks Example Requirements SeeAlso
In This Topic
    Convert(String,String) Method (PdfDocumentConverter)
    In This Topic
    Converts the specified PDF document.
    Syntax
    'Declaration
    
    Public Overloads Function Convert( _
    ByVal inFilename
    The input filename of PDF document.
    As System.String, _
    ByVal outFilename
    The output filename of PDF document.
    As System.String _
    ) As Boolean
    public bool Convert(
    System.String inFilename,
    System.String outFilename
    )
    public: bool Convert(
    System.String inFilename,
    System.String outFilename
    )
    public:
    bool Convert(
    System.String inFilename,
    System.String outFilename
    )

    Parameters

    inFilename
    The input filename of PDF document.
    outFilename
    The output filename of PDF document.

    Return Value

    True if conversion is successful; otherwise, false.
    Remarks

    The conversion interrupts if an unsolved problem is found.

    Example

    Here is an example that shows how to convert a PDF document to conformance with PDF/A-1b specification:

    
    ''' <summary>
    ''' Converts a PDF document to conformance with PDF/A-1b specification.
    ''' </summary>
    ''' <param name="pdfFilename">The filename of source PDF document.</param>
    ''' <param name="outputPdfFilename">The filename of output PDF document.</param>
    Public Shared Sub ConvertDocumentToPdfA1b(pdfFilename As String, outputPdfFilename As String)
        ' determine that file must converted to the PDF/A-1b and saved back to the source file
        Dim sameFile As Boolean = pdfFilename.ToUpperInvariant() = outputPdfFilename.ToUpperInvariant()
    
        ' create the PDF/A-1b converter
        Dim converter As New Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter()
        converter.LzwFixupCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip
        ' converter.OutputIntentDestIccProfile = ...
    
        ' execute the conversion
        System.Console.WriteLine("Conversion...")
        Dim result As Vintasoft.Imaging.Processing.ConversionProfileResult = converter.Convert(pdfFilename, outputPdfFilename, New Vintasoft.Imaging.Processing.ProcessingState())
    
        ' if PDF document is converted successfully
        If result.IsSuccessful Then
            System.Console.WriteLine("Document converted to PDF/A-1b.")
        Else
            ' if PDF document is NOT converted
            If Not sameFile Then
                System.IO.File.Delete(outputPdfFilename)
            End If
    
            Throw result.CreateConversionException()
        End If
    End Sub
    
    
    
    /// <summary>
    /// Converts a PDF document to conformance with PDF/A-1b specification.
    /// </summary>
    /// <param name="pdfFilename">The filename of source PDF document.</param>
    /// <param name="outputPdfFilename">The filename of output PDF document.</param>
    public static void ConvertDocumentToPdfA1b(string pdfFilename, string outputPdfFilename)
    {
        // determine that file must converted to the PDF/A-1b and saved back to the source file
        bool sameFile = pdfFilename.ToUpperInvariant() == outputPdfFilename.ToUpperInvariant();
        
        // create the PDF/A-1b converter
        Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter converter = 
            new Vintasoft.Imaging.Pdf.Processing.PdfA.PdfA1bConverter();
        converter.LzwFixupCompression = Vintasoft.Imaging.Pdf.PdfCompression.Zip;
        // converter.OutputIntentDestIccProfile = ...
        
        // execute the conversion
        System.Console.WriteLine("Conversion...");
        Vintasoft.Imaging.Processing.ConversionProfileResult result = 
            converter.Convert(pdfFilename, outputPdfFilename, new Vintasoft.Imaging.Processing.ProcessingState());
    
        // if PDF document is converted successfully
        if (result.IsSuccessful)
        {
            System.Console.WriteLine("Document converted to PDF/A-1b.");
        }
        // if PDF document is NOT converted
        else
        {
            if (!sameFile)
                System.IO.File.Delete(outputPdfFilename);
    
            throw result.CreateConversionException();
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also