How to Import PDF to DICOMPDF

From DicomObjectsWiki

Jump to: Navigation, search

Import general PDF files and turn them into DICOM PDF format is not much different to import other file formats, i.e. windows Bitmap and Jpeg images.

Based on the DICOM supplement 104, we made a small VB6 program which demonstrate what attributes are needed for making a valid DICOM PDF file.

Dim g As New DicomGlobal 
Dim pdf As New DicomDataSet
Dim pdfData() As Byte
Dimfile_length As Long
Dimfnum As Integer 
' Read in PDF file as Byte array CommonDialog1.Filter = "*.pdf|*.pdf" CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then file_length = FileLen(CommonDialog1.FileName) fnum = FreeFile ReDim pdfData(1 To file_length) Open CommonDialog1.FileName For Binary As #fnum Get #fnum, 1, pdfData Close fnum Else MsgBox "No file specified." Exit Sub End If
' ==== Patient Module Attributes ==== pdf.Attributes.Add &H10, &H10, "Patient Name 123" ' Patient Name pdf.Attributes.Add &H10, &H20, 123456 ' Patient ID pdf.Attributes.Add &H10, &H30, "" ' Patient DOB pdf.Attributes.Add &H10, &H40, "O" ' Patient Sex
' ==== Study Module Attributes ==== pdf.Attributes.Add &H20, &HD, g.NewUID ' Study Instance UID pdf.Attributes.Add &H8, &H20, "" ' Study Date pdf.Attributes.Add &H8, &H30, "" ' Study Time pdf.Attributes.Add &H8, &H90, "" ' Referring Physician's Name pdf.Attributes.Add &H20, &H10, 1 ' Study ID pdf.Attributes.Add &H8, &H50, "" ' Accession Number
' ==== Encapsulated Document Series Module Attributes ==== pdf.Attributes.Add &H8, &H60, "OT" ' Modality pdf.Attributes.Add &H20, &HE, g.NewUID ' Series Instance UID pdf.Attributes.Add &H20, &H11, 1 ' Series Number
' ==== General Equipment Module Attributes ==== pdf.Attributes.Add &H8, &H70, "" ' Manufacturer
' ==== SC EQUIPMENT MODULE ATTRIBUTES ==== pdf.Attributes.Add &H8, &H64, "SD" ' Conversion Type
' ==== Encapsulated Document Module Attributes ==== pdf.Attributes.Add &H20, &H13, 1 ' Instance Number pdf.Attributes.Add &H8, &H23, "" ' Content Date pdf.Attributes.Add &H8, &H33, "" ' Content Time pdf.Attributes.Add &H8, &H2A, "" ' Acquisition Datetime pdf.Attributes.Add &H28, &H301, "NO" ' Burned In Annotation pdf.Attributes.Add &H42, &H10, "" ' Document Title pdf.Attributes.Add &H40, &HA043, "" ' Concept Name Code Sequence, a coded representation of the document title pdf.Attributes.Add &H42, &H12, "application/pdf" ' MIME Type pf Encapsulated Document
pdf.Attributes.Add &H42, &H11, pdfData ' Encapsulated Document stream, containing a document encoded according to the MIME Type
' ==== SOP Common ==== pdf.Attributes.Add &H8, &H16, "1.2.840.10008.5.1.4.1.1.104.1" ' SOP Class UID pdf.Attributes.Add &H8, &H18, g.NewUID ' SOP Instance UID
'' Write file out pdf.WriteFile "c:\DICOM_PDF.dcm", True, "1.2.840.10008.1.2.1"


NOTE, PDF import will become part of DicomObjects' FileImport method in the COM version and the Import method in the .NET version from any versions dated 18th March 2009 and onwards.

Personal tools