Some test text!

Loading...
Guides
Convert from DICOM

Convert DICOM to PDF in .NET Core

The Advanced Imaging Module is an optional add-on which can be used with PDFTron SDK 9.0 or later to convert DICOM and other image formats (such as AAI, ARW, DCR and RAF) to PDF without any external dependencies. It works by enhancing the already existing PDF.Convert.ToPDF method, adding support for all the new formats. Additionally, you can use the PDF.Convert.FromDICOM method to supply DICOM-specific options to the conversion module.

You can find more details about how to install advanced imaging module here .

Supported formats

The module is primarily designed to convert DICOM images to PDF documents. However, conversion of many other advanced imaging formats such as HEIC, ARW, DCR and RAF are also supported; see here for a full list.

Usage

To use the advanced imaging module, you must use the PDFNet.AddResourceSearchPath method with the path to the module's Lib/ folder to include the module files.

Requires the advanced imaging module add-on
PDFNet.Initialize();
PDFNet.AddResourceSearchPath("relative/path/to/Lib/");

If the module has been successfully added, you can use the Convert.FromDICOM method. This method requires that you pass in a PDFDoc object that will append converted pages to the specified PDF document.

using (PDFDoc doc = new PDFDoc()){
    pdftron.PDF.Convert.FromDICOM(doc, input_file_path + intput_file_name, null);
    doc.Save(output_file_path + output_file_name, SDFDoc.SaveOptions.e_remove_unused);
}

Conversion options

You can also optionally provide a AdvancedImagingConvertOptions as an argument to set a DefaultDPI for the image. If no DPI can be deduced from the existing image, then the default DPI provided will be used as the DPI for the final converted document. If this option is not used, a DPI value of 72.0 will be used to create the output. For DICOM images, Pixel Spacing attribute is used to determine the DPI of the image.

AdvancedImagingConvertOptions opts = new AdvancedImagingConvertOptions();
opts.SetDefaultDPI(72.0);

pdftron.PDF.Convert.FromDICOM(doc, input_file_path + input_file_name, opts);

Combinining the above, the module can likely be used in the following way(s).

// Use a try-catch block here to catch PDFNetException
PDFNet.AddResourceSearchPath('relative/path/to/Lib/');
using (PDFDoc pdfdoc = new PDFDoc())
{
	AdvancedImagingConvertOptions opts = new AdvancedImagingConvertOptions();
	opts.SetDefaultDPI(72.0);
	pdftron.PDF.Convert.FromDICOM(pdfdoc, input_path + input_file_name, opts);
	pdfdoc.Save(output_path + output_file_name, SDFDoc.SaveOptions.e_remove_unused);
}

Sample

The module ships with the fully working AdvancedImagingTest sample code which can be used to test the conversion functionality using provided test files or your own documents. The sample first initializes PDFNet, which is required for all PDFTron SDK functionality, then uses PDFNet.AddResourceSearchPath to include the advanced imaging Module. The same lines of code can be used to integrate the module in your application or project.

Get the answers you need: Support

Upcoming Webinar: PDFTron SDK Tech Review | Nov 29, 2022 at 2 pm ET

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use