You need to sign in to do that
Don't have an account?
using Jquery with Visualforce page renderas PDF
Hi All,
I'm using jquery to toggle a logo static resource - all works fine, but as soon as I add renderas="PDF" the logo does not load...
<script src="{!URLFOR($Resource.jquery)}" type="text/javascript"></script> </head> <body> <table width="100%" border="0" class="addressheader"> <tr> <td> <img src='' Height="51" Width="204" title="logo" id='divisionImage' /> <input type='hidden' id='divisionCode' value='UK' /> <br/> <br/> <script> $(document).ready(function() { // The minute the page loads, perform this action. // get the value used to determine which image to display whichCode = $('#divisionCode').val(); if(whichCode == 'IE') $('#divisionImage').attr('src','{!URLFOR($Resource.WRLogo)}'); else $('#divisionImage').attr('src','{!URLFOR($Resource.WRLogo)}'); }); </script>
Any ideas?
Thanks
This is because when the content is rendered as PDF it doesn't go through the browser's javascript engine. Rather the browser will use an appropriate plugin etc to display the content. I've hit this a few time with javascript charting - I've got around this by opening the page in Google chrome, opening the print dialog and choosing save as PDF.
All Answers
Ok, I think this approach is wrong as renderas PDF happens server side and therefore no javaScript is executed????
This is because when the content is rendered as PDF it doesn't go through the browser's javascript engine. Rather the browser will use an appropriate plugin etc to display the content. I've hit this a few time with javascript charting - I've got around this by opening the page in Google chrome, opening the print dialog and choosing save as PDF.
Cross post!
The penny dropped, was getting carried away. So no javascript!
Using the browser print is probably not going to fly with the client.
I was trying to escape having three buttons and pages i.e. UK, IE & NI.
Think I'm going to go with something like this - Onclick javascript button which opens the relevent visualforce page - what do you think?
Do you know the details server side, or in a way that you can use to conditionally render one of the three logos?
Hi Bob,
Did this in the end.
x3 Visualpages
x1 Custom forumula field with case statement wrapped around division and outputs the url /apex/PDF_UK for example
x1 Custom button - display in new window content source url {!URLFOR( Opportunity.Url__c )}{!Opportunity.Id}
I tried to call the static resource in the formula field., but couldn't crack it.