c++ : pdf to dicom

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
w.bahadoer
Posts: 27
Joined: Mon, 2020-01-20, 11:36

c++ : pdf to dicom

#1 Post by w.bahadoer »

Hi there,

Is there a way to encapsulate a pdf in a dicom object using one of the libraries instead of using pdf2dcm?
I know of 2 options but they don't fulfill the requirements mentioned in my question
1. save the pdf as .jpg/.bmp
2. use createProcess ( winapi ) and call pdf2dcm in my code

J. Riesmeier
DCMTK Developer
Posts: 2506
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: c++ : pdf to dicom

#2 Post by J. Riesmeier »

3. Would be to use the existing class DcmEncapsulatedDocument.
4. Would be my preferred (and recommended) way: Write your own C++ class/function based on DCMTK's functionality to create DICOM datasets (see dcmdata).

w.bahadoer
Posts: 27
Joined: Mon, 2020-01-20, 11:36

Re: c++ : pdf to dicom

#3 Post by w.bahadoer »

Thanks J.Reismeier,

are there good examples where the dcmencapsulateddocument is used ? The documentation looks good but I'm just wondering if there were code snippets on the net. I tried looking for it here on the forum ....but no luck.

w.bahadoer
Posts: 27
Joined: Mon, 2020-01-20, 11:36

Re: c++ : pdf to dicom

#4 Post by w.bahadoer »

J.Reismeier,

i thought I look at the way pdf2dcm commandline tool is doing it, so I guess I found my example.... or are there more?

J. Riesmeier
DCMTK Developer
Posts: 2506
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: c++ : pdf to dicom

#5 Post by J. Riesmeier »

I think this is the only example (so far). Actually, the class DcmEncapsulatedDocument has been implemented in a way that it mainly supports the command line tools pdf2dcm, cda2dcm and stl2dcm. That's why I recommended the 4th approach (see above).

w.bahadoer
Posts: 27
Joined: Mon, 2020-01-20, 11:36

Re: c++ : pdf to dicom

#6 Post by w.bahadoer »

I have a class that generates the DICOM dataset with the proper ID's and such, but wouldn't I still need the DcmEncapsulatedDocument class to encapsulate the pdf in the dataset ? that is what I'm trying now ..... on a different note I'm not able to view the encapsulated pdf in a viewer on Orthanc so I decided to do the test first with pdf2dcm and see whether I can get a proper pdf view on Orthanc, but this viewing issue is a slightly different problem I have to tackle.... just sharing my M.O. :D

J. Riesmeier
DCMTK Developer
Posts: 2506
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: c++ : pdf to dicom

#7 Post by J. Riesmeier »

I have a class that generates the DICOM dataset with the proper ID's and such, but wouldn't I still need the DcmEncapsulatedDocument class to encapsulate the pdf in the dataset ?
No, you simply need to copy the content of the PDF file to the element value of the Encapsulated Document (0042,0011) attribute (and add the other data elements that are needed for the Encapsulated PDF Document IOD).

w.bahadoer
Posts: 27
Joined: Mon, 2020-01-20, 11:36

Re: c++ : pdf to dicom

#8 Post by w.bahadoer »

Thanks for the advice, it works !!!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest