Some test text!

Discord Logo

Chat with us

PDFTron is now Apryse, learn more here.

JavaScript DICOM to PDF converter

More languages

More languages
C# (.NET Core)
JS (Node.js)

Sample JavaScript code demonstrates how to use the PDFTron Advanced Imaging module for direct, high-quality conversion from DICOM to PDF. Learn more about our JavaScript PDF Library and PDF Conversion Library.

Get Started Samples Download

To run this sample, get started with a free trial of Apryse SDK.

// Copyright (c) 2001-2023 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.

// The following sample illustrates how to convert AdvancedImaging documents to PDF format 
// The AdvancedImaging module is an optional PDFNet Add-on that can be used to convert AdvancedImaging
// documents into PDF documents
// The PDFTron SDK AdvancedImaging module can be downloaded from

const { PDFNet } = require('@pdftron/pdfnet-node');
const PDFTronLicense = require('../LicenseKey/LicenseKey');

((exports) => {
	'use strict';

	exports.runAdvancedImagingTest = () => {

		const main = async () => {

			try {
				await PDFNet.addResourceSearchPath('../../lib/');

				if (!await PDFNet.AdvancedImagingModule.isModuleAvailable()) {
					console.log('\nUnable to run AdvancedImagingTest: PDFTron SDK AdvancedImaging module not available.');
					console.log('The AdvancedImaging module is an optional add-on, available for download');
					console.log('at If you have already downloaded this');
					console.log('module, ensure that the SDK is able to find the required files');
					console.log('using the PDFNet::AddResourceSearchPath() function.\n');


				// Relative path to the folder containing test files.
				const inputPath = '../TestFiles/AdvancedImaging/';
				const outputPath = '../TestFiles/Output/';

				const dicom_input_file = 'xray.dcm';
				const heic_input_file = 'jasper.heic';
				const psd_input_file = 'tiger.psd';
				const output_ext = '.pdf';
				const doc = await PDFNet.PDFDoc.create();

				const opts = new PDFNet.Convert.AdvancedImagingConvertOptions();
				await PDFNet.Convert.fromDICOM(doc, inputPath + dicom_input_file, opts);
				await + dicom_input_file + output_ext, PDFNet.SDFDoc.SaveOptions.e_linearized);

				const doc2 = await PDFNet.PDFDoc.create();

				await PDFNet.Convert.toPdf(doc2, inputPath + heic_input_file);
				await + heic_input_file + output_ext, PDFNet.SDFDoc.SaveOptions.e_linearized);

				const doc3 = await PDFNet.PDFDoc.create();

				await PDFNet.Convert.toPdf(doc3, inputPath + psd_input_file);
				await + psd_input_file + output_ext, PDFNet.SDFDoc.SaveOptions.e_linearized);
			} catch (err) {
		PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
			console.log('Error: ' + JSON.stringify(error));
		}).then(function () { return PDFNet.shutdown(); });
// eslint-disable-next-line spaced-comment
//# sourceURL=AdvancedImagingTest.js