public DocumentConverterResult ConvertTo(
OutputOptions outputOptions,
DocumentEngine? engine = null
)
Public Function ConvertTo (
outputOptions As OutputOptions,
Optional engine As DocumentEngine? = Nothing
) As DocumentConverterResult
Create an instance of DocumentConverter class with an input document and call instance methods ConvertTo and CanConvertTo. This is useful especially when you want to convert the same input document to several output formats:
var documentConverter = new DocumentConverter(@"c:\SomeFolder\InputFile.docx");
// Convert "c:\SomeFolder\InputFile.docx" to "c:\SomeFolder\InputFile.pdf"
documentConverter.ConvertTo(DocumentFormat.Pdf);
// Convert "c:\SomeFolder\InputFile.docx" to "c:\SomeFolder\OutputFile.pdf"
documentConverter.ConvertTo(@"c:\SomeFolder\OutputFile.pdf");
Dim documentConverter As New DocumentConverter("c:\SomeFolder\InputFile.docx")
' Convert "c:\SomeFolder\InputFile.docx" to "c:\SomeFolder\InputFile.pdf"
documentConverter.ConvertTo(DocumentFormat.Pdf)
' Convert "c:\SomeFolder\InputFile.docx" to "c:\SomeFolder\OutputFile.pdf"
documentConverter.ConvertTo("c:\SomeFolder\OutputFile.pdf")
Convert and ConvertTo methods also returns an instance of DocumentConverterResult class which has some useful properties:
var result = DocumentConverter.Convert(@"c:\SomeFolder\InputFile.docx", DocumentFormat.Jpg);
// result.ElapsedTime: Total elapsed time for the document conversion
Console.WriteLine("Conversion took {0} milliseconds.", result.ElapsedTime.TotalMilliseconds);
// result.OutputFiles: A string array for the paths of the converted (output) document files.
// When there is only one output file, the value will be a single item array.
// If the output is a directory (e.g. for DocumentFormat.Web format),
// the string will have a trailing backslash (\).
Console.WriteLine("Conversion generated {0} output files:", result.OutputFiles.Length);
for (var i = 0; i < result.OutputFiles.Length; i++)
{
Console.WriteLine("OutputFiles[{0}] -> {1}", i, result.OutputFiles[i]);
}
/*
Conversion generated 3 output files:
OutputFiles[0] -> InputFile-1.jpg
OutputFiles[1] -> InputFile-2.jpg
OutputFiles[2] -> InputFile-3.jpg
**/
Dim result As Object = DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Jpg)
' result.ElapsedTime: Total elapsed time for the document conversion
Console.WriteLine("Conversion took {0} milliseconds.", result.ElapsedTime.TotalMilliseconds)
' result.OutputFiles: A string array for the paths of the converted (output) document files.
' When there is only one output file, the value will be a single item array.
' If the output is a directory (e.g. for DocumentFormat.Web format),
' the string will have a trailing backslash (\).
Console.WriteLine("Conversion generated {0} output files:", result.OutputFiles.Length)
Dim i As Object = 0
While i < result.OutputFiles.Length
Console.WriteLine("OutputFiles[{0}] -> {1}", i, result.OutputFiles(i))
i += 1
End While
'
' Conversion generated 3 output files:
' OutputFiles[0] -> InputFile-1.jpg
' OutputFiles[1] -> InputFile-2.jpg
' OutputFiles[2] -> InputFile-3.jpg
'