• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Return PDF file via webservice

New Here ,
May 23, 2007 May 23, 2007

Copy link to clipboard

Copied

Hi guys,

A customer requested a webservice that, by inputing a SKU code, returns a PDF file with all data on that SKU.
My question is, can I generate and return a PDF file directly from a CFC using binary? I already have the PDF creation part done using cfdocument. Would it be possible to send it back without writing to the disk?
This may be kind of newbie but I'm not that familiar with this area of ColdFusion.

Thanks in advance

Hugo
TOPICS
Advanced techniques

Views

560

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 24, 2007 May 24, 2007

Copy link to clipboard

Copied

LATEST
<cfdocument> allows you to specify a variable (I think the attribute is "Name") in which to store the postscript code for the PDF. You could certainly return that value via a webservice, but the application that consumed the webservice would need to be able to set the correct mime type before displaying the postscript code to the browser.

Something like this (the code is quick and dirty so there might be some errors, but it should give you a general idea):

Your Webservice Component:
------------------------------------------------------
<cffunction name="myTest" returntype="string" access="remote">
<cfdocument name="psText">
<b>This is a test</b>
</cfdocument>

<cfreturn psText>

</cffuncion>


Consume Webservice
----------------------------------------------
<cfsetting enablecfoutputonly="Yes">
<cfset objWS = CreateObject("webservice", " http://www.mysite.com/ws/mywebservice.cfc?wsdl")>
<cfset sPDFText = objWS.myTest()>
<cfcontent type="application/pdf"><cfoutput>#sPDFText #</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation