You need to sign in to do that
Don't have an account?
nickfs92840
PDF and Print Function on VF page
I have a java print function on my VF page, however, I want to add a PDF renderer button of some sort where the user can either print a hard copy or save the VF page as a pdf file.
I used the renderas='pdf" in my current VF page, but it defaults to creating a pdf instead.
Any ideas would be greately appreciated!
<apex:page standardController="Highlight_Sheet__c" standardStylesheets="false" showHeader="false" > <apex:stylesheet value="{!URLFOR($Resource.advancedpdfsource, 'qstyles.css')}" /> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>INTERNAL USE ONLY</title> </head> <body class="oneColElsCtr"> <div id="container"> <div id="mainContent"> <p> <table width="855" border="0"> <tr> <td width="173"><apex:image value="https://c.na6.content.force.com/servlet/servlet.ImageServer?id=01580000000vjOP&oid=00D300000000aSY&lastMod=1332533543000" width="150" height="51"/></td> <td width="505"><h1 class="red">HIGHLIGHT SHEET</h1></td> <td width="161"><table width="99%" border="0" cellpadding="0" cellspacing="0"> <td align="center"><a href="javascript:window.print();">Print Highlight Sheet</a></td>
>>>>>>>>>>>>>>>>>>>
I've had to create separate versions of my VF pages for HTML and PDF. The PDF renderer is pretty basic so I had to code it separately to look right.
However, in your case you could use a URL parameter to dynamically specify whether to render as PDF. For example:
/apex/myvisualforcepage?pdf=true
Then in the VF do RenderAs="{!getUrlParamValue}"
In your controller you can just look at the param and return "PDF" or "HTML"
Then what you can do is open the PDF document in a new window and use javascript to print the child window contents, and then close it.
Gabriel Alack
Contact Us - We Can Help!
Salesforce Superheroes
------------------------------
help@salesforcesuperheroes.com
www.salesforcesuperheroes.com
1-888-407-9578 x122