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

Rendering a PDF/Mime Type in cfDIV

New Here ,
Jul 19, 2009 Jul 19, 2009

Hi there

I have a cfform that looks at files in a directory. The template is meant to allow users to select a document and and view it on the page.

The relevant code is:

Main Page:

<cfform name = "name">

...

<cfinput name="displayName"  id="displayName" value="#URLEncodedFormat(displayName)#" type="text">

...

  <cfdiv bind="url:/_admin/utilities/viewer/viewer.cfm?displayName={displayName}" />

</cfform>

--------------------------

viewer.cfm

...

<cfset mimeType = getPageContext().getServletContext().getMimeType(displayName)>

<cfheader name="Content-Disposition" value="inline; filename=#displayName#">

<cfcontent type="#mimeType#" file="#displayName#">

---------------------------

Problem is, the text in the cfDiv appears literally as:

"

%PDF-1.4 %äüöß 2 0 obj <> stream x��� 5 }���� ����� ����wVI (���*�T٫��J�&#127;!��W�����u]� � N���J>  �w1������Lek� ���d�\W����dR%3- ��d{@�ȅ��4��G\8!�'��.�� o����� �9ܴ �� ��  �����X�������V����ִ�i>��*Y| �͋�"���=o�� .<��7 ��D�ϸ� uӊ��p�-� m�c ����o�i��j���7$TG�M E P�  P���QB���A 1�` ��; cS! : c2ċ9�c���.(6�Ċ� ΰ���i7

"

Is anyone able to make any suggestions?  For instance, can this event be done using AJAX tags?

Thanks in advance

Boon

TOPICS
Advanced techniques
976
Translate
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
Valorous Hero ,
Jul 20, 2009 Jul 20, 2009
LATEST

A cfdiv is not a separate browser window. So I do not think you can change the content type mid-stream that way.  You might try embedding the pdf with <object>. I think that would work.  (Of course that is assuming the user's browser is actually configured to display pdf's within the browser .. )

Translate
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