Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, March 1, 2019 6:11:28 PM(UTC)
Josh Clark

Groups: Registered, Tech Support, Administrators
Posts: 54

Thanks: 2 times
Was thanked: 10 time(s) in 10 post(s)

To extract a encapsulated document, such as a PDF, from a DICOM dataset, you will need to call the L_DicomGetEncapsulatedDocument method passing in the dataset you wish to extract from, and empty DICOMENCAPSULATEDDOCUMENT and DICOMCODESEQUENCEITEM structures to hold relevant metadata. Here, I have created a project that extracts the encapsulated document, if present, from a DICOM file saving the document to C:\temp and displaying all metadata properties present in the console.

A simplified example is as follows:
Code:

#define IMAGE_PATH _T("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")
#define INPUT_DICOM_FILE IMAGE_PATH _T("Encapsulated.dcm")
#define OUTPUT_DOCUMENT_FILE IMAGE_PATH _T("Output.pdf")

// Declare a DICOM dataset handle, encapsulatedDocument, and conceptNameCodeSequence
HDICOMDS hDS = NULL;
DICOMENCAPSULATEDDOCUMENT encapsulatedDocument = { 0 };
DICOMCODESEQUENCEITEM conceptNameCodeSequence = { 0 };
pDICOMELEMENT pElement = NULL;

// Start the DICOM engine
L_DicomStartUp();

// Open the existing DICOM Dataset
hDS = L_DicomCreateDS(NULL);
L_DicomLoadDS(hDS, INPUT_DICOM_FILE, 0);

// Find the encapsulated document element
pElement = L_DicomFindFirstElement(hDS, NULL, TAG_ENCAPSULATED_DOCUMENT, L_TRUE);

// Retrieve the encapsulated document container to a file and metadata to
// encapsulated document and code sequence item structures
L_DicomGetEncapsulatedDocument(hDS, pElement, L_FALSE, OUTPUT_DOCUMENT_FILE,
   &encapsulatedDocument, &conceptNameCodeSequence);

// Cleanup
L_DicomFreeDS(hDS);
L_DicomShutDown();


To add a document to a DICOM dataset in C, please refer to this forum post. For a sample file created by adding the Leadtools.pdf to the image2.dcm dataset, both available in the LEADTOOLS Images folder, download the file below:
File Attachment(s):
Encapsulated.zip (287kb) downloaded 181 time(s).

The sample project can be downloaded below:
File Attachment(s):
DICOM extract encapsulated PDF example.zip (5kb) downloaded 173 time(s).

Edited by user Monday, March 4, 2019 10:38:56 AM(UTC)  | Reason: Not specified

Josh Clark
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.040 seconds.