Some test text!

Loading...
Guides

VB DICOM to PDF converter

More languages

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 Started Samples Download

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(PDFTronLicense.Key)
            PDFNet.AddResourceSearchPath("../../../../../Lib/")

            If Not AdvancedImagingModule.IsModuleAvailable() Then
                Console.WriteLine()
                Console.WriteLine("Unable to run AdvancedImagingTest: PDFTron SDK AdvancedImaging module not available.")
                Console.WriteLine("---------------------------------------------------------------")
                Console.WriteLine("The AdvancedImaging 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 advancedimaging:")

            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
            PDFNet.Terminate()
        End Sub
    End Class
End Namespace