Skip to main content

pdf2dcm

PyPI version Supported Python versionsDownloads Downloads License: MITcodecovTest PipelineRelease Pipeline

PDF to DICOM Converter

Convert PDFs into standards-compliant DICOM files for PACS, radiology, and healthcare interoperability workflows.

Features

  • Convert PDFs to Encapsulated DICOM or RGB Secondary Capture DICOM
  • Preserve patient/study metadata from template DICOMs
  • Simple Python API built on pydicom
  • Compatible with PACS workflows

SETUP

Python Package Setup

The python package is available for use on PyPI. It can be setup simply via pip

pip install pdf2dcm

To the check the setup, simply check the version number of the pdf2dcm package by

python -c 'import pdf2dcm; print(pdf2dcm.__version__)'

Poppler Setup

Poppler is a popular project that is used for the creation of Dicom RGB Secondary Capture. You can check if you already have it installed by calling pdftoppm -h in your terminal/cmd. To install poppler these are some of the recommended ways-

Conda

conda install -c conda-forge poppler

Ubuntu

sudo apt-get install poppler-utils

MacOS

brew install poppler

PDF to Encapsulated DCM

Stores the original PDF directly inside a DICOM object. This is useful for:

  • Radiology or pathology or any structured clinical documents
  • PACS archival workflows

Usage

from pdf2dcm import Pdf2EncapsDCM

converter = Pdf2EncapsDCM()
converted_dcm = converter.run(path_pdf='tests/test_data/test_file.pdf', path_template_dcm='tests/test_data/CT_small.dcm', suffix =".dcm")
print(converted_dcm)
# [ 'tests/test_data/test_file.dcm' ]

Parameters converter.run:

  • path_pdf (str): path of the pdf that needs to be encapsulated
  • path_template_dcm (str, optional): Optional template DICOM used for metadata inheritance.
  • suffix (str, optional): suffix of the dicom files. Defaults to ".dcm".

Returns:

  • List[Path]: list of path of the stored encapsulated dcm

PDF to RGB Secondary Capture DCM

Renders PDF pages as RGB images and stores them as Secondary Capture DICOM instances. Useful when:

  • Encapsulated PDFs are unsupported
  • Image-based viewing is preferred
  • Legacy PACS compatibility is required

Usage

from pdf2dcm import Pdf2RgbSC

converter = Pdf2RgbSC()
converted_dcm = converter.run(path_pdf='tests/test_data/test_file.pdf', path_template_dcm='tests/test_data/CT_small.dcm', suffix =".dcm")
print(converted_dcm)
# [ 'tests/test_data/test_file_0.dcm', 'tests/test_data/test_file_1.dcm' ]

Parameters converter.run:

  • path_pdf (str): path of the pdf that needs to be converted
  • path_template_dcm (str, optional): Optional template DICOM used for metadata inheritance.
  • suffix (str, optional): suffix of the dicom files. Defaults to ".dcm".

Returns:

  • List[Path]: list of paths of the stored secondary capture dcm

Notes

  • Output DICOM filenames are derived from the input PDF filename.
  • If no template is provided no repersonalisation takes place
  • It is possible to produce dicoms without a suffix by simply passing suffix="" to the converter.run()

Metadata Inheritance

Metadata can optionally be copied from a template DICOM file to preserve patient and study context. Currently, the fields that is inherited by default are-

  • PatientName
  • PatientID
  • PatientSex
  • StudyInstanceUID

The fields SeriesInstanceUID and SOPInstanceUID have been removed from the inheritance by copying as it violates the DICOM standards.

You can set the fields to repersonalize by passing repersonalisation_fields into Pdf2EncapsDCM(), or Pdf2RgbSC()

Example:

fields = [
    "PatientName",
    "PatientID",
    "PatientSex",
    "StudyInstanceUID",
    "AccessionNumber"
]
converter = Pdf2RgbSC(repersonalisation_fields=fields)

note: this will overwrite the default fields.

The field names must be standard DICOM keywords recognized by pydicom. If a field is missing from the template, pdf2dcm uses its dictionary-defined value representation (VR) and adds an appropriate empty value. Missing UID fields receive a newly generated UID. An unknown keyword raises a ValueError.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf2dcm-0.7.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf2dcm-0.7.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file pdf2dcm-0.7.2.tar.gz.

File metadata

  • Download URL: pdf2dcm-0.7.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pdf2dcm-0.7.2.tar.gz
Algorithm Hash digest
SHA256 9390d9aa8fc3b0888d3720f838c1d217f22710cffa4c2f75e98287ac1065e76a
MD5 4755b431aac616dc82123afc56d0064d
BLAKE2b-256 3fb48b97311baeff3ae044e7e630c3040a1957a1102a4543f4c3f413338cb2c5

See more details on using hashes here.

File details

Details for the file pdf2dcm-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: pdf2dcm-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pdf2dcm-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a360493771999d0c0027eda0fcd8e3250e0b31318ed91b521cb764bcbe3ae7e1
MD5 716943d9115b398e65f388247a465872
BLAKE2b-256 a5f431f4cea13199d5d0ed31043d10169b004cb35396137ec82e50ae5b2e6fdf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 files

0.6.0

2 files

0.5.2

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page