Question ARJUN NAGARAJ · Dec 16, 2019

In Cache 2017, I am getting Error while loading a PDF on browser.

Hi All,

I am getting error while opening the PDF report in cache 2017 instance, I am using this below piece of code to open PDF in browser.

                pdf=objResult.FormattedReport  // FormattedReport property is a %GlobalBinaryStream
                pdf.%Save()
                pdf.SetAttribute("ContentType","pdf")
                pdf.SetAttribute("Expires",0)
                pdf.SetAttribute("CONTENT","NO-CACHE")
                oid=pdf.%Oid()
                %session.Data("CacheStreamId")=oid
                StrOid=..Encrypt(oid)
                !,"<script type='text/javascript'>"
                !,"window.location='%25CSP.StreamServer.cls?STREAMOID="_StrOid_"';"
                !,"</script>"

Note: Interestingly the same piece of code is working in 2013 instance of cache for the same report data.

Could you please help me to figure out if there is any compatibility issues in code with respect to 2017 Cache?

Any help is very much appreciated. Thanks in Advance :)

Regards,

Arjun

Comments

Juanito Doolub · Dec 16, 2019

Verify that calling method %Save  is returning 1

Also, that the PDF stream is correctly created in Global ^CacheStream

0
ARJUN NAGARAJ  Dec 17, 2019 to Juanito Doolub

Hi Juanito,

Yes %Save is returning 1. I see PDF Stream is getting saved in Global ^CacheStream but data is not in readable format.

Thank you,

Arjun

0
ARJUN NAGARAJ · Dec 17, 2019

Found the root cause of it, there is no issues with above piece of code. Before that we were trying to Read the data form the stream using Read() without specifying the length. While reading for the first time data is getting truncated leaving PDF file corrupted and truncated.

0