This content has been marked as final. Show 3 replies
This should be all you need (note the subtle changes):
<cfheader name="Content-Disposition" value="attachment;filename=my.pdf">
<cfcontent type="application/pdf" reset="Yes" variable=#BinaryDecode (testFN.Filecontent, "Base64")#>
<CFABORT> <!--- Just in case there is any OnRequestEnd code. --->
EXCEPT that it is not entirely clear that the entire filecontent is supposed to be a pdf file.
Please post a link to a page that shows a cfdump of testFN.
Or provide enough information for us to do our own cfhttp call to the service.
You can private message me if need be.
Thanks for the reply.
I have had problems using BinaryDecode. It states the input and output are not the same not matter what I use as the binaryencoding. I can get a pdf binary object sent to the browser by using this:
<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=#fileNAME#.#fileEXT#">
<CFCONTENT TYPE="*/*" VARIABLE="#ToBinary(ToBase64(docBINARY))#">
ToBinary nor ToBase64 work on their own (I get an error about ByteArrays), but they seem to work together. However, now I get a 12 page PDF with 1 blank page and all the other pages generate errors in the Adobe Reader. I have confirmed that the document comes up fine in the Java applications that do basically the same thing, but it is like ColdFusion does not understand the data type.
Unfortunately, our DEV and UAT systems are not exposed for me to give you access. The Web Service I am consuming will never be available externally, which is why I am building a CF passthrough to display the documents to public users. The internal system will output private contracts, so there are privacy issues related to opening it up. Our prod deployment is very strict, so I cannot even put up public pages for testing until all involved sign off on functionality.
Obviously, the CFDUMP exceeds the text limit, so I cannot post it either. :(
Edit: Also, I found out that the first byte of object is a status code. I have parsed that off (why you now see docBINARY), but I only see this as a square and have not been able to convert this to the number code I should be getting.
Ok, I think I have it now. When I tell CFHTTP to GETASBINARY I do not have to do any conversions on the file. I just dump FileContent into CFCONTENT and BOOM.
Of course, I loose my error code, but it does not appear to mess up the document. I should be able to dump the thing in a CFTRY and CFCATCH to catch if a document is not sent; I will just not have any idea why the document failed to load. This should not be a show stopper though.
Now I have to handle the other part which is unzipping the XLS files. ICK