Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Open and Encode PDF into OBX.5 Field
All,
I need to load a PDF and encode it into the HL7 OBX.5 format. Can I just read the file in like I would any file and pass that value to the base-64 encode package?
Thanks,
Jerry
Just be sure to read it in the binary mode.
Here is some tcl code that will encode/decode pdf documents.
package require base64
set file test.pdf
# base64 encode the .pdf file set fi [open $file r] fconfigure $fi -translation binary set pdf [base64::encode [read -nonewline $fi]] close $fi
# Insert $pdf into the HL7 message
# base64 decode the .pdf file set fo [open test_out.pdf w] fconfigure $fo -translation binary puts $fo [base64::decode $pdf] close $fo
-- Max Drown (Infor)
I find I have to add -nonewline to the read or else the PDF when decoded is not usable by acrobat.
email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.
That’s a good tip, Jim.
Thanks for the responses! They have been very helpful!