This topic contains 7 replies, has 4 voices, and was last updated by frazcat 9 years, 2 months ago.
HL7 to .pdf file
-
Hello, I am trying to get an HL7 message from LLP channel and write the content of the HL7 file into a .PDF file. It works fine for .txt files but for some reason it does not work for .pdf.
It creates the .pdf file but when I try to open it in Ubuntu it says “Unable to open document”
function WriteToFile(Msg) --This function creates a file using os.date and the length as a name. --and then opens it for write, wrties the message, and then closes it. --it returns the created filename. --filter local C = filter.base64.enc(Msg) C = filter.base64.dec© if Msg then FileName = os.date('%Y%m%d%H%M%S'..'.pdf') local F = io.open(Source..FileName, "wb") F:write(Msg) F:close() return FileName end end
Iguana is not a PDF printer. It will not convert text to PDF. For this you will have to use external program converting text to PDF. To launch external program you can call os.execute(). The encoding into base64 has different purpose, and is not applicable in context of your goal.
Hello, I am trying to get an HL7 message from LLP channel and write the content of the HL7 file into a .PDF file. It works fine for .txt files but for some reason it does not work for .pdf.
It creates the .pdf file but when I try to open it in Ubuntu it says “Unable to open document”I have achieved the above by using a program from google code called htmltopdf and i use a filter translator to convert the HL7 coming in into a HTML format which then pushes it into a PDF. its very useful and did not take to much work to setup.
I’ve had some recent experience working with PDF documents embedded within HL7 messages, and would like to make sure I understand what you’re trying to do.
Is the requirement to convert human-readable plain text found within an HL7 message to a PDF document, or does the message you wish to process actually contain a base64-encoded PDF document? If the former, the suggestions posted above are what you need. If the latter (not uncommon these days), you’ll actually need to use filter.base64.dec to convert the encoded data to its binary form, then write that out to a file.
A base64 encoded PDF found within, for example, an OBX segment from GI procedure impression would look something like this:
OBX|41|ED|GI^Colonoscopy^Unknown|41|PROVATION^Colonoscopy^PDF^BASE64^JVBERi0xLjYNCjEgMC ... (many kilobytes of data elided)
The string of apparent gibberish in OBX-5.5 is actually a base64-encoded PDF. It would need to be decoded and written to a file to be readable in a PDF viewer.
Jeff Drumm ◊ VP and COO ◊ HICG, LLC. ◊ http://www.hicgrp.com
Thanks Jeff.
I was trying to create a .pdf file from an HL7 V2 message. HL7 message does not contain a base64-encoded PDF document. I will use an external program to convert text to pdf as Lev suggested.
Thanks frazcat,
Excellent. I have tried this and it works. HTML works well with the translator. We used a bash file in Ubuntu to convert the HTML to PDF.
<div class=”d4p-bbt-quote-title”>Can wrote:</div>Hello, I am trying to get an HL7 message from LLP channel and write the content of the HL7 file into a .PDF file. It works fine for .txt files but for some reason it does not work for .pdf.<br> It creates the .pdf file but when I try to open it in Ubuntu it says “Unable to open document”
I have achieved the above by using a program from google code called htmltopdf and i use a filter translator to convert the HL7 coming in into a HTML format which then pushes it into a PDF. its very useful and did not take to much work to setup.
You must be logged in to reply to this topic.