LEADTOOLS Support
Imaging
Imaging SDK FAQ
How do I convert a file from one format to another?
#1
Posted
:
Friday, March 31, 2017 3:31:46 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 39
Thanks: 2 times
Was thanked: 3 time(s) in 3 post(s)
LEADTOOLS Imaging SDK offers the RasterCodecs class that handles the majority of I/O operations.
https://www.leadtools.co.../dh/co/rastercodecs.htmlConverting from one format to another is a simple matter of loading a file and saving it to the desired format. For this you can leverage the RasterCodecs class's Load and Save methods.
https://www.leadtools.co...o/rastercodecs-load.htmlhttps://www.leadtools.co...o/rastercodecs-save.htmlA very simple example of this format conversion routine below:
Code:using (RasterCodecs codecs = new RasterCodecs())
{
RasterImage image = codecs.Load(@"input file path");
codecs.Save(image, @"output file path ", RasterImageFormat.Tif, 24);
}
The output format can be any of our support file formats, see here:
https://www.leadtools.co...ported-file-formats.htmlIf you are wanting to convert file formats to a Document output, then you would need to utilize the DocumentConverter Class:
https://www.leadtools.co...ument/document-converterQuote:The Document Converter SDK can be used to convert raster and document formats alike, making it ideal for any Enterprise Content Management (ECM), document archival, and document normalization solution.
Convert to and from any document or raster image format
Adobe Acrobat PDF and PDF/A
Microsoft Office DOC/DOCX, XLS/XLSX, PPT/PPTX, PST, EML, MSG, and XPS formats
CAD formats such as DXF, DWG, and DWF
TIFF, JPEG, PNG, EXIF, BMP, and hundreds more raster image formats
Plain Text, RTF, HTML, MOBI, ePUB, and more
IBM AFP, MO:DCA, IOCA, and PTOCA
Here is some sample code on how to achieve this in a C# application:
Code:using (var documentConverter = new DocumentConverter())
{
string inFile = Path.Combine(ImagesPath.Path, @"Leadtools.docx");
string outFile = Path.Combine(ImagesPath.Path, @"output.pdf");
var format = DocumentFormat.Pdf;
var jobData = DocumentConverterJobs.CreateJobData(inFile, outFile, format);
jobData.JobName = "conversion job";
var job = documentConverter.Jobs.CreateJob(jobData);
documentConverter.Jobs.RunJob(job);
}
Edited by moderator Wednesday, December 27, 2023 2:14:27 PM(UTC)
| Reason: Updated
Roberto Rodriguez
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK FAQ
How do I convert a file from one format to another?
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.