intersystems-cacheobjectscript

ObjectScript file create from stream


how can I create file (PDF file for example) from binary stream I have stored in global? I have stream stored in caché global and I need to create and save the file created by the stream using ObjectScript.

Thanks :)


Solution

  • It is not so easy. There is only one official way to create pdf in Cache, and it is ZEN reports. With ZEN reports you could create not only pdf, also possible to make html, xlsx. ZEN Reports used Apache FOP for generating it, any other ways also possible, but you should do it only by yourself.

    Or maybe I misunderstood you, and you mean that your binary stream already contains PDF, and you just want to save it to some file. If so, you just have to copy your globalstream to filestream, with code like this:

    set fs=##class(%Stream.FileBinary).%New()
    set fs.Filename="c:\temp.pdf"
    set tSC=fs.CopyFrom(yourStream)
    set tSC=fs.%Save()