Compressing and Encrypting Treatment Plan .PDF Files

(to send as email attachments and when ordering rental plaques)


Introduction

The I-125 and similar radiation sources used in eye plaque brachytherapy are fairly short lived and so are often custom ordered and manufactured to deliver a specified dose rate on a specific date. These sources are assembled into a plaque that must be sterilized prior to use. This process requires timely coordination of a treatment planning and delivery team which includes radiation oncologists, ophthalmic surgeons, physicists, dosimetrists, schedulers, a sterile processing department (SPD) and the manufacturer of the radiation sources. A convenient way for this complex team to communicate and coordinate is via email.

Anything that Plaque Simulator (PS) can send to a printer may also be saved to a file in Adobe System's Portable Document Format (PDF). This is a native feature of MacOS. PDF files are recognized by most computer operating systems (OS) if they include the filename extension ".pdf". These files may be distributed amongst the planning team as email attachments. This section of the PS user guide describes Eye Physics recommended methods for preparing .pdf documents for use as email attachments. If you intend to use the IsoAid preloaded, presterilized plaque rental service, you will definitely need to familiarize yourself with these methods.

PS uses native MacOS technology to print treatment plans as .pdf files. These files are neither compressed nor encrypted and become substantial in size when CT, ultrasound and fundus images are included. File sizes in excess of 100 MB are common. Many email systems impose file size limitations of about 10 to 15 MB on attachments, and to meet security requirements, .pdf files must be encrypted prior to transmitting over the internet. Hence, treatment plans printed by PS must be both compressed to a file size under 15 MB and then encrypted with a password before they can be distributed to the treatment team as email attachments.


Sharing treatment plans by email

MacOS includes rudimentary, but adequate, 128-bit RC4 encryption and limited options for compression of images embedded within PDF files. In order to meet the 15 MB file size limitations imposed on email attachments, the large (e.g. >100 MB) treatment plan files printed by PS may require more complex compression technology than is natively provided by MacOS.

The best .pdf file compression results will be obtained using a commercial 3rd party .pdf compression application. One such application for MacOS is NXPowerLite 8 Desktop from https://www.neuxpower.com. There are several competing commercial applications with similar functionality. At the time of this writing, Eye Physics has determined that NXPowerLite does the best job of compression, reducing a >100 MB PDF file to under 5 MB, while maintaining excellent image quality, but it does not support file encryption and it is a 32-bit application which may not be supported by versions of MacOS beyond 10.14 Mojave. Future versions of MacOS will eventually support only 64-bit applications. When 64-bit applications become mandatory, Eye Physics will re-evaluate the available solutions.

Eye Physics recommends that you configure your PDF compression software to appended _for_email to the original file name when you compress a treatment plan PDF file. (e.g. a treatment plan file named OA.pdf should be duplicated, compressed and renamed as OA_for_email.pdf).

A better way to encrypt your compressed .pdf files is using Coherent's PDF Command Line Tools cpdf which may be downloaded from https://community.coherentpdf.com. Eye Physics has created .pdf encryption automators for MacOS that use the cpdf tools to encrypt files using either 128-bit (PDF 1.6) or 256-bit Advanced Encryption Standard (AES) encryption (PDF 2.0). These automators only encrypt .pdf files, they require a 3rd party application such as NXPowerLite to first reduce the .pdf files to a size suitable for emailing. Drag or copy cpdf found in (Email Utilities) or by download into the Library/PDF Services/ folder of your system hard drive (which is where the automator requires it to be located). The cpdf based automators also expect to find the password with which to encrypt the .pdf file in the MacOS system security keychain, a feature introduced in Plaque Simulator version 6.6.7. If a password is not found in the keychain, the default PS password will be substituted.

If you don't want to install cpdf, Eye Physics has also created PDF encryption automators that use the native MacOS 128-bit RC4 encryption. Although RC4 encryption is less secure than AES encryption, it is strong enough for PS treatment plan use and is faster than AES. The MacOS based automators require manual input of any password other than Plaque Simulator's default password and also tend to increase the .pdf file size by several MB.

To simultaneously compress and encrypt .pdf documents you can also use the MacOS Preview application with the Eye Physics quartz compression filter PS Email Size.qfilter. The qfilter must be manually installed , but it produces better image quality compared to using Preview's standard filters to compress and encrypt .pdf files. Preview also uses native MacOS 128-bit RC4 encryption and passwords must be manually entered.

If your compressed .pdf files are still too large for your email system, you will need to print the treatment plan in two or more parts and then separately compress and email the parts. PS6 provides an optional automated service to divide its print jobs into smaller parts if necessary. The Send Email button will send an applescript message to the OSX Mail.app with a summary template addressed to the current professional group for the required number of email parts. Option-click the Send Email button to generate an email list from all presets.

Suggested configuration settings for NXPowerLite 8

NXPowerLitePrefs
PS6ProfileForNXPowerLite
SelectPS6Profile

Eye Physics automators

The optional Eye Physics automators, qfilter and cpdf tools are provided with PS and may be found in: Plaque Simulator Folder/Plaque Simulator Data/(Hidden Support Files)/(Email Utilities)/. To install them, they must be manually copied or moved from Email Utilities to appropriate locations. Once everything is installed, simply drag and drop a PS6 created .pdf treatment plan onto the automator application (or onto an alias in the MacOS system dock).

The Eye Physics PDF encryption automators are to be placed in your MacOS Applications folder. To do this, either drag or copy whichever of the automators you elect to use from Email Utilities into the Applications folder which is found at the root level of your primary system hard drive. Currently, three versions of the automator are provided:

AutomatorApplication

PDF Encrypt Only using cpdf AES256ISO: This automator does not compress PDF files, it is designed to encrypt files that have been previously compressed by another application (e.g. NXPowerLite or similar) to a size suitable for sending as email attachments (e.g. < 15 MB). It looks for an encryption password in the MacOS system security keychain with key PlaqueSimulator.PDFpassword. PS versions 6.6.7 or greater will create this key. You can customize the password and manually synchronize the keychain with the plan's password in the Institution window.

AutomatorApplication

PS will automatically synchronize the keychain to the current treatment plan whenever you print a document. If you are not using the cpdf encryption automators then you can disable all keychain access in PS Preferences's document pane. You can suppress repetetive keychain permission dialogs from the MacOS System utility app Keychain Access by setting Access Control for PlaqueSimulator.PDFpassword to "Allow all applications to access this item" or by setting specific application access permissions to include Plaque Simulator and the encryption automator app(s).

If the key is not found, the default PS password (ma••••) will be substituted. This automator then uses the Coherent cpdf command line tools to encrypt the treatment plan using 256-bit encryption method AES256ISO (Advanced Encryption Standard for PDF 2.0). The PDF file size will not noticably change after encryption. Files created by this automator have _encrypted appended to the original file name (e.g. the compressed file OA_for_email.pdf will be copied, encrypted and saved to the same folder as the original file as OA_for_email_encrypted.pdf).

PDF Encrypt Only using cpdf AES: This automator is the same as PDF Encrypt Only using cpdf AES256ISO above except that it uses the 128-bit encryption method AES for Acrobat 7 (PDF 1.6). Use this version if your PDF reader does not support PDF 2.0.

PDF Encrypt Only using MacOS: This automator does not compress PDF files, it is also designed to encrypt files that have been previously compressed by another application (e.g. NXPowerLite or similar) to a size suitable for sending as email attachments. It uses MacOS's built-in 128-bit RC4 encryption. Although RC4 encryption is less secure than AES encryption, it is adequate and fast. The encryption password will be Plaque Simulator's default, but you will be offered an opportunity to manually customize it. The PDF file size will increase by several MB following encryption. Files created by this automator have _encrypted appended to the original file name (e.g. the compressed file OA_for_email.pdf will be copied, encrypted and saved to the same folder as the original file as OA_for_email_encrypted.pdf).

PDF Compress and Encrypt using MacOS: This automator applies the quartz filter PS email size.qfilter to compress images embedded in the treatment plan .pdf file and then encrypts the file using MacOS's built-in 128-bit RC4 encryption. The encryption password will be Plaque Simulator's default, but you will be offered an opportunity to manually customize it. This automator can still produce fairly large file sizes and is not particularly useful for MacOS versions greater than 10.12 Sierra. Files created by this automator have _for_email_encrypted appended to the original file name (e.g. the file OA.pdf will be copied, compressed, encrypted and saved to the same folder as the original file as OA_for_email_encrypted.pdf).

KeychainAttributes
KeychainAcessControl
AutomatorInstallation

The cpdf tools and the custom quartz filter PS email size.qfilter used by the Preview program and PDF Compress and Encrypt using MacOS are to be placed in the MacOS system library PDF Services folder. To do this, either drag or copy the files from (Email Utilities) into the PDF Services folder of your bootup system drive Library folder as illustrated below.

QfilterFolder

Eye Physics recommends that you create short-cuts (aliases) to whichever PDF compression application and encryption automator you elect to use in your MacOS dock next to the Plaque Simulator alias.

AutomatorAliasInDock


PDF compression and encryption using Preview.app

Apple's Preview.app program is the default PDF viewer in MacOS. Eye Physics reccommends that you use it to view .pdf documents created by Plaque Simulator. You can also use Preview to compress .pdf files by about 50% and to password secure these files using 128-bit RC4 encryption for use as email attachments. Preview's compression results are rudimentary compared to many 3rd party .pdf optimizing applications and tools which can reduce file size by more than 90%, often with negligible loss of image quality. Eye Physics does not recommend using the Preview.app to do file compression and encryption, but it is built-in and entirely free.

If you decide to use Preview to prepare a Plaque Simulator treatment plan that has been printed to a .pdf file for email use:

  • Open the treatment plan .pdf file with the Preview app.
  • Choose Export from the Preview File menu.
FileExport

  • In the file export sheet:
    1. Rename the file in the Export As: field at the top of the sheet. Eye Physics uses a naming convention consisting of the original filename followed by _for_email_encrypted. For example, if the original treatment plan .pdf file was filename.pdf, the new compressed file could be renamed and saved as filename_for_email_encrypted.pdf
    2. Navigate to where you want the new file to be saved (e.g. the Desktop).
    3. Set the quartz filter to PS Email Size.
    4. Enable the encryption checkbox.
    5. Enter and verify the password for the encrypted file.
    6. Click the Save button to exit the sheet and save the new compressed version of the .pdf file.
PreviewExportSheet

Compression and encryption using PDF Compress and Encrypt using macOS

This simplest of the Eye Physics automator applications streamlines the manual process described above using the Preview application. PDF Compress and Encrypt using MacOS also requires the Eye Physics quartz filter PS email size.qfilter mentioned above, and will not function properly without it.

To use this automator, simply drag and drop your treatment plan .pdf file (e.g. XX.pdf) onto the automator or an alias to the automator (e.g. that you may have placed in the OSX dock).

  1. The automator will first duplicate the file, e.g. XX.pdf will be duplicated as XX copy.pdf.
  2. The automator then renames the file, e.g. XX copy.pdf will be renamed as XX_for_email_encrypted.pdf.
  3. The automator next then applies the quartz compression filter PS Email Size.qfilter that you have previously installed in the OSX system library PDF Services folder.
  4. The automator will then prompt you to enter an encryption password. Plaque Simulator's default password is macula. Click Continue to accept the default or enter your own password and then click Continue.
  5. The automator will then encrypt the file and send you an OSX notification that the process is complete. The compressed and encrypted copy of the original file will appear in the same folder as the original. Do not move or open the new XX_for_email_encrypted.pdf file until you receive the ready notification.
  6. Once you have received the ready notification you can verify that the file has been compressed and encrypted by opening it with Preview.app using the appropriate password.
  7. In the PS Institution window you can further automate the process by sending an email message to all the members of your planning team. Simply drag and drop the newly created XX_for_mail_encrypted.pdf file into the designated location in that email message template.
Automator1
Automator2
Automator3

Automators for use with cpdf tools and PS 6.6.7 (or later)

Automators are programs that interweave MacOS automator action functions, AppleScripts and UNIX Shell Scripts to automate repetitive processes that involve MacOS capabilities and underlying UNIX operating system commands. This is an example of an automator that accepts a .pdf file, preferably one that has already been compressed to a size suitable for emailing, and encrypts it using the cpdf command line tools.

This automator uses AppleScripts to first confirm that a .pdf file has been selected. The parent folder of the file is then saved to a variable. A new temporary folder is created in which a copy of the .pdf file to be encrypted will be placed. An AppleScript (illustrated) then calls a UNIX shell script which looks for a .pdf encryption password that Plaque Simulator has previously stored the MacOS system security keychain. If no password is found in the keychain, the user is alerted and the PS default password is used. The .pdf file is then duplicated, the duplicate moved to the temporary folder, its filename edited, and then the renamed duplicate is moved back to the original file's parent folder, replacing any file with the same name (e.g. a previous version of the encrypted treatment plan PDF file). The security password and the renamed file reference are then passed to a shell script that directs the cpdf command line tools to encrypt the file. Depending upon which version of the automator you have selected (AES or AES256ISO), either 128-bit or 256-bit AES encryption will be used. The temporary folder is then deleted, some operating system housekeeping performed, and the user is finally notified that the encrypted copy is available and may be found in the same folder as the original file.

AutomatorCode

Example of a quartz compression filter to use with the Preview.app

There is a nice article on c/net that explains how to modify an existing quartz compression file. Technically, these qfilters are OSX property list (plist) xml files. This is the xml code of the Eye Physics qfilter.

QfilterCode