DICOM Encapsulated PDF: 25 Projects in 25 Days

Dicom Encapsulated Pdf Screenshot
Dicom Encapsulated Pdf Screenshot

As part of the LEAD Technologies 25th anniversary, we are creating 25 projects in 25 days to celebrate LEAD’s depth of features and ease of use. Today’s project comes from Joe.

What it Does

This project embeds PDF documents inside DICOM Data Sets using LEADTOOLS Version 19.

Features Used

Development Progress Journal

My name is Joe and I am going to create a project that embeds a PDF in a DICOM File as an encapsulated document using the Encapsulated Document tag (0042:0011).

I am using LEADTOOLS Medical Imaging 19.0. I’m developing this application using Visual Studio 2013 using C# .NET 4.5.

After starting up Visual Studio, I selected a Windows Forms Application as this is the simplest to design for this demonstration. I added the Leadtools, Leadtools.Codecs, Leadtools.Dicom, and Leadtools.WinForms DLLs as references to my project.

Now that I have all of the references that I’ll need, I’m going to work on the designer. I’ve added two buttons and a RasterImageViewer to the form.

I’ve linked up the button’s click methods to my main form. The first button, “Create,” will be written to create a DicomDataSet, load a PDF file, insert that PDF into the DicomDataSet and then save out the DicomDataSet. The second button, “Load,” will be written to load the DicomDataSet with the encapsulated PDF that was created and saved out by the “Create” button.

I just wrote the code for the “Create” button. I created a helper method to set all of the properties of the DICOM File when encapsulating a document. The main method used to encapsulate the PDF was DicomDataSet.SetEncapsulatedDocument. Easy enough.
Documentation: SetEncapsulatedDocument function

I just wrote the code for the “Load” button. I again created a helper method to do the extraction of the PDF. This helper method does three things:

  1. Extracts the PDF from the DicomDataSet
  2. Prints out all of the properties of the DicomDataSet
  3. Rasterizes and Displays the PDF in the RasterImageViewer

Now when I run the demo, clicking the “Create” button generates a DicomDataSet, embeds a PDF as an encapsulated document, and then saves out the DICOM File. The “Load” button now loads the generated DICOM File, displays the properties, extracts the PDF, and then rasterizes and displays it in the viewer.

This project took me 3 hours to set up. The main time consumer in creating this application was figuring out which properties to set in the DicomDataSet when creating it. Other than that, all of the methods that needed to be called on the DicomDataSet class were fairly straight forward. Without the high-level LEADTOOLS SDK, it may have taken me days to accomplish this due to the complexity of the DICOM format.

Download the Project

The source code for this sample project can be downloaded from here. To run the project, extract it to the C:\LEADTOOLS 19\Examples\DotNet\CS directory.


LEAD Technologies, Inc.

This entry was posted in Medical Imaging and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *