Open and Encode PDF into OBX.5 Field

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Open and Encode PDF into OBX.5 Field

  • Creator
    Topic
  • #54404
    Jerry Tilsley
    Participant

      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

    Viewing 4 reply threads
    • Author
      Replies
      • #81334
        Charlie Bursell
        Participant

          Just be sure to read it in the binary mode.

        • #81335

          Here is some tcl code that will encode/decode pdf documents.

          Code:

          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)

        • #81336
          Jim Kosloskey
          Participant

            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.

          • #81337

            That’s a good tip, Jim.

            -- Max Drown (Infor)

          • #81338
            Jerry Tilsley
            Participant

              Thanks for the responses!  They have been very helpful!

          Viewing 4 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.