pdf embedded too large? Can't recreate it
Hello fellow comrades.
I have a little issue concerning the creation of an embedded PDF sent by hl7. When I Extract it, the pdf is not completed (Seen by opening it with notepad++) compared to the one I created with a Base 64 converter.
The one I got from the Base 64 converter contains 7XXX contains lines and mine after my program contains 5900. The 5900 lines are the same that 5900 firsts of the others so my converting code is ok. The problem must be in the recuperation of the data. I think it's too long and the GetFieldStreamRaw can't contain everything. Could you help, what are the upgradres I need to do to overcome my issue?
Info: Req is the hl7 message, Segment is the path and is correct, linkAndFileName where to copy it. The loop is correct, the problem is concerning the first line.
Method getPdfBase64FromED(req As EnsLib.HL7.Message, segment As %String, linkAndFileName As %String) As %Status { do req.GetFieldStreamRaw(.base64, segment) set stream1=##class(%Stream.FileCharacter).%New() set stream2=##class(%Stream.FileCharacter).%New() set sc = stream2.LinkToFile(linkAndFileName) $$$TRACE(segment) while 'base64.AtEnd { set temp=base64.Read() set temp=$translate(temp, $c(13,10)) $$$TRACE(temp) do stream1.Write(temp) } $$$TRACE(" ") do stream1.Rewind() while 'stream1.AtEnd { set temp=stream1.Read(4000) set temp=$system.Encryption.Base64Decode(temp) $$$TRACE(temp) do stream2.Write(temp) } s sc = stream2.%Save() return $$$OK }
Thanks in advance,
Thomas