LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Extract an encapsulated PDF document from a DICOM dataset file using C
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")
HDICOMDS hDS = NULL;
DICOMENCAPSULATEDDOCUMENT encapsulatedDocument = { 0 };
DICOMCODESEQUENCEITEM conceptNameCodeSequence = { 0 };
pDICOMELEMENT pElement = NULL;
L_DicomStartUp();
hDS = L_DicomCreateDS(NULL);
L_DicomLoadDS(hDS, INPUT_DICOM_FILE, 0);
pElement = L_DicomFindFirstElement(hDS, NULL, TAG_ENCAPSULATED_DOCUMENT, L_TRUE);
L_DicomGetEncapsulatedDocument(hDS, pElement, L_FALSE, OUTPUT_DOCUMENT_FILE,
&encapsulatedDocument, &conceptNameCodeSequence);
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:
The sample project can be downloaded below:
Edited by user 6 years ago
| Reason: Not specified
Josh Clark
Developer Support Engineer
LEAD Technologies, Inc.

LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Extract an encapsulated PDF document from a DICOM dataset file using C
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.