If you have installed our product using the full product installer downloaded from our website then you can find the Document Converter demo at “%USERPROFILE%\Documents\Gnostice\Document Studio .NET\Demos\01. WinForms\C#\02. Document Converter” on your machine.
Steps to create a simple document converter application.
1.Open Visual Studio and create a new console application
2.Use either the GUI or the Package Manager Console and install the Gnostice.DocumentStudio.Converter NuGet package.
3.Below code snippets show how you can convert the documents from one file format to another.
a.Convert DOCX to PDF
// Create DocumentConverter instance
DocumentConverter documentConverter = new DocumentConverter();
// Convert DOCX to PDF
documentConverter.ConvertToFile("input.docx", "output.pdf");
|
|
b.Convert PDF to formatted, flow-based DOCX document
// Create DocumentConveter instance
DocumentConverter documentConverter = new DocumentConverter();
// Convert DOCX to PDF
documentConverter.ConvertToFile("input.pdf", "output.docx");
|
|
c.Convert multiple images to single PDF document
// Create DocumentConveter instance
DocumentConverter documentConverter = new DocumentConverter();
// List of files to be converted
List inputFiles = new List()
{
"1.bmp", "2.png",
"3.jpg", "4.jpeg",
"5.emf", "6.wmf",
"7.tif", "8.tiff"
};
// Base file name for output file
string baseFileName = "Converted";
// Convert to PDF
string outputFileFormat = "pdf";
// Convert list of images to single PDF document
documentConverter.ConvertToFile(inputFiles, outputFileFormat, Environment.CurrentDirectory,
baseFileName, ConversionMode.ConvertToSingleFile);
|
|
d.Convert multiple files to single multipage TIFF file
// Create DocumentConveter instance
DocumentConverter documentConverter = new DocumentConverter();
// List of files to be converted
List inputFiles = new List()
{
"1.pdf", "2.docx",
"3.doc", "4.png",
"5.bmp", "6.jpeg",
"7.txt", "8.xps"
};
// Base file name for output file
string baseFileName = "Converted";
// Convert to TIFF
string outputFileFormat = "tiff";
// Additional settings to create multi-page TIFF file
TIFFEncoderSettings tiffEncoderSettings = new TIFFEncoderSettings()
{
MultiPage = true
};
// Convert list of files to a single multi-page TIFF document
documentConverter.ConvertToFile(inputFiles, outputFileFormat, Environment.CurrentDirectory,
baseFileName, ConversionMode.ConvertToSingleFile, tiffEncoderSettings);
|
|
4.Run application to see converted output file in the application bin directory.