function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
javierjiesjavierjies 

print something with javascript

Hello everyone!!

 

I have a VF Page with this code:

 

 <apex:column headervalue="IDS"><a href="/servlet/servlet.FileDownload?file={!item.Attachment_Id__c});" target="_blank">{!item.Attachment_Name__c}</a></apex:column>                   
 

 

With this I open a PDF attached. Now I want, by doing clic, print this PDF, I've tried this

 

 

<apex:column headervalue="IDS"><a href="javascript:window.print(/servlet/servlet.FileDownload?file={!item.Attachment_Id__c});" target="_blank">{!item.Attachment_Name__c}</a></apex:column>                   
 

 

but it doesn't work!

 

any idea?

 

Thanks in advance!!!

GoodGrooveGoodGroove

Render your PDF in an iFrame and print its content using javaScript

 

<script> 
function iprint(ptarget) 

ptarget.focus(); 
ptarget.print(); 


</script>

<body> 
<apex:iframe id="Frame2Print" width="500" height="200" src="/apex/MyPDFPage"/>

<input type="button" value="Print PDF" onclick="iprint(Frame2Print);" /> 

</body>