I want to open the PDF in browser so that i have wriiten the below code but i have occured the error: "file does not begin with %PDF".
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div style="width:358px;height:206px;">
<img src="http://www.pcsamerica.net/mp/images/reloimages/upload/home_home_image_117713.jpg" border="2" width="358" height="206" />
<img src="http://www.pcsamerica.net/mp/images/reloimages/upload/home_mug_image_117713.jpg" border="1" width="68" height="68" style="position:absolute; top:190px; left:25px; z-index:2"/>
<font style="position:absolute; top:15px; left:15px; z-index:2; border:1px; color:FFFFFF;font-family:impact;font-size:14px;">
</font>
</div>
<div style="width:425px;height:206px;padding-top:5px; padding-left:75px; text-align:center; border:1px;font-family:Arial;font-size:9px;">
</div>
</body>
</html>
<cfheader name="Content-Disposition" value="inline; filename=Test.pdf">
<cfcontent type="application/pdf">
<!--- TAKES YOUR HTML AND SAVES IT TO A LOCAL VARIABLE --->
<cfsavecontent variable="PDFhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div style="width:358px;height:206px;">
<img src="http://www.pcsamerica.net/mp/images/reloimages/upload/home_home_image_117713.jpg" border="2" width="358" height="206" />
<img src="http://www.pcsamerica.net/mp/images/reloimages/upload/home_mug_image_117713.jpg" border="1" width="68" height="68" style="position:absolute; top:190px; left:25px; z-index:2"/>
<font style="position:absolute; top:15px; left:15px; z-index:2; border:1px; color:FFFFFF;font-family:impact;font-size:14px;">
</font>
</div>
<div style="width:425px;height:206px;padding-top:5px; padding-left:75px; text-align:center; border:1px;font-family:Arial;font-size:9px;">
</div>
</body>
</html>
</cfsavecontent>
<!--- USES THE VARIABLE DEFINED ABOVE TO CREATE THE PDF USING CF TAGS --->
<cfheader name="Content-Disposition" value="inline; filename=Test.pdf">
<cfdocument format="pdf">
<cfoutput>
#variables.PDFhtml#
</cfoutput>
</cfdocument>
Just a little side not, you can't make the PDF display in browser from Coldfusion; you’re just generating the PDF with Colfusion. Where the PDF opens up is a option of your default reader, most commonly Adobe Reader. If the PDF isn’t opening up in the browser, you might have “Display PDF in browser” turned off. To Fix that open Adobe Reader and go to Edit->Preference, under "Categories:" click “Internet”. On the right hand side you’ll see a check box, for the “Display PDF in browser” label, make sure it’s clicked.