LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Extract an encapsulated PDF document from a DICOM dataset file using C
#1
Posted
:
Friday, March 1, 2019 6:11:28 PM(UTC)
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:
The sample project can be downloaded below:
Edited by user Monday, March 4, 2019 10:38:56 AM(UTC)
| 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.