LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Embed a PDF in a DICOM dataset file as an EncapsulatedDocument using C
#1
Posted
:
Friday, March 1, 2019 4:11:56 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 54
Thanks: 2 times
Was thanked: 10 time(s) in 10 post(s)
To embed a document, such as a PDF, within a DICOM file, you will need to call the
L_DicomSetEncapsulatedDocument method passing in the dataset you wish to add to, and
DICOMENCAPSULATEDDOCUMENT and
DICOMCODESEQUENCEITEM structures with relevant metadata. Here, I have created a project that adds the common Leadtools.pdf to the image2.dcm file, both from the LEADTOOLS Images folder, along with some sample metadata and saves to the same directory.
A simplified approach is as follows:
Code:
#define IMAGE_PATH _T("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")
#define INPUT_DICOM_FILE IMAGE_PATH _T("image2.dcm")
#define INPUT_DOCUMENT_FILE IMAGE_PATH _T("Leadtools.pdf")
#define OUTPUT_DICOM_FILE IMAGE_PATH _T("Encapsulated.dcm")
// 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);
// TODO: Populate encapsulatedDocument and conceptNameCodeSequence
// Add the encapsulated document element
pElement = L_DicomFindFirstElement(hDS, NULL, TAG_ENCAPSULATED_DOCUMENT, L_TRUE);
if (pElement != NULL)
pElement = L_DicomInsertElement(hDS, NULL, L_FALSE, TAG_ENCAPSULATED_DOCUMENT,
VR_UN, L_FALSE, 0);
// Add the encapsulated document container to the DICOM dataset
L_DicomSetEncapsulatedDocument(hDS, pElement, L_FALSE, INPUT_DOCUMENT_FILE,
&encapsulatedDocument, &conceptNameCodeSequence);
// Save the Dataset to a new file
L_DicomSaveDS(hDS, OUTPUT_DICOM_FILE, 0);
// Cleanup
L_DicomFreeDS(hDS);
L_DicomShutDown();
To retrieve an encapsulated document from a DICOM dataset, or to read the metadata associated with one, please refer to
this forum post.Edited by user Monday, March 4, 2019 10:30:41 AM(UTC)
| Reason: updated code and added link
Josh Clark
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Medical
Medical SDK Examples
HOW TO: Embed a PDF in a DICOM dataset file as an EncapsulatedDocument 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.