Some test text!

menu

VB DICOM to PDF converter

More languages

chevron_right
More languages
C++
C#
C# (.NET Core)
Java
JS (Node.js)
VB

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

Get StartedSamplesDownload

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

Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
Imports pdftron
Imports pdftron.Common
Imports pdftron.PDF
Imports pdftron.SDF

Namespace AdvancedImagingTestVB
    Class Class1
        Private Shared pdfNetLoader As pdftron.PDFNetLoader = pdftron.PDFNetLoader.Instance()

        Shared Sub Main(ByVal args As String())
            PDFNet.Initialize()
            PDFNet.AddResourceSearchPath("../../../../../Lib/")

            If Not AdvancedImagingModule.IsModuleAvailable() Then
                Console.WriteLine()
                Console.WriteLine("Unable to run AdvancedImagingTest: PDFTron SDK Advanced Imaging module not available.")
                Console.WriteLine("---------------------------------------------------------------")
                Console.WriteLine("The Advanced Imaging module is an optional add-on, available for download")
                Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this")
                Console.WriteLine("module, ensure that the SDK is able to find the required files")
                Console.WriteLine("using the PDFNet::AddResourceSearchPath() function.")
                Console.WriteLine()
            End If

            Dim input_path As String = "../../../../TestFiles/AdvancedImaging/"
            Dim output_path As String = "../../../../TestFiles/Output/"
            Dim input_file_name As String = "xray.dcm"
            Dim output_file_name As String = "xray.dcm.pdf"

            If args.Length <> 0 Then
                input_file_name = args(0)
                output_file_name = input_file_name & ".pdf"
            End If

            Console.WriteLine("Example advanced imaging:")

            Try

                Using pdfdoc As PDFDoc = New PDFDoc()
        
                    Dim opts As AdvancedImagingConvertOptions = New AdvancedImagingConvertOptions()
                    pdftron.PDF.Convert.FromDICOM(pdfdoc, input_path & input_file_name, opts)
            
                    pdfdoc.Save(output_path & output_file_name, SDFDoc.SaveOptions.e_remove_unused)
                End Using

                Console.WriteLine("Done.")
            Catch e As PDFNetException
                Console.WriteLine(e.Message)
            End Try
        End Sub
    End Class
End Namespace
close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.