You need to sign in to do that
Don't have an account?
CSS not rendering when using renderas="pdf"
Hi,
We have create a visualforce page attached to a button so users can print pdf with fields on object. The problem I am having is that when I use renderas="pdf", for some reason the stylesheet indicated is not rendering properly.
I have tried using the css in two forms, by url and by uploading it as a static resource, as you can see on lines 13 and 14 on the below code. Also I have tried using the tag "applyHtmlTag" with value false to see if this helps, also I have tried changing the api version and duplicating the vf page and nothing seems to work.
Any ideas on how I can make the css work? If I remove the renderas="pdf" tag the css shows properly. Thanks!
We have create a visualforce page attached to a button so users can print pdf with fields on object. The problem I am having is that when I use renderas="pdf", for some reason the stylesheet indicated is not rendering properly.
I have tried using the css in two forms, by url and by uploading it as a static resource, as you can see on lines 13 and 14 on the below code. Also I have tried using the tag "applyHtmlTag" with value false to see if this helps, also I have tried changing the api version and duplicating the vf page and nothing seems to work.
Any ideas on how I can make the css work? If I remove the renderas="pdf" tag the css shows properly. Thanks!
<apex:page standardController="Boleta_Manual__c" renderAs="pdf"> <html lang="en"> <head> <style type="text/css"> @page { size: 13in 21in ; } <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>factura</title> <apex:stylesheet value="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/> <!--<apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'css/bootstrap.min.css')}"/>--> </style> </head> <body> <div class="container" id="page"> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <apex:image value="{!$Resource.setelHeader}"/> </div> <table id="table-2" class="table table-straped table-bordered"> <thead> <tr> <th>Boleta Setel</th> <th>Distribuidor</th> <th>Espeficique Otro</th> <th>Boleta Cliente</th> </tr> </thead> <tbody> <tr> <td><apex:outputField value="{!Boleta_Manual__c.name}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Distribuidor__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Espeficique_Otro__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.BoletaCliente__c}"/></td> </tr> </tbody> </table> </div> <div class="panel panel-default"> <table class="table table-straped table-bordered"> <thead> <tr> <th>Modelo</th> <th>IMEI</th> <th>Falla reportada</th> <th>Accesorios</th> </tr> </thead> <tbody> <tr> <td><apex:outputField value="{!Boleta_Manual__c.Modelo__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.IMEI__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Falla_reportada__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Accesorios__c}"/></td> </tr> </tbody> </table> </div> <div class="panel panel-default"> <table class="table table-straped table-bordered"> <thead> <tr> <th>Estado</th> <th>Razón</th> <th>Técnico</th> <th>Cliente</th> </tr> </thead> <tbody> <tr> <td><apex:outputField value="{!Boleta_Manual__c.Estado__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Raz_n__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.T_cnico__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Cliente__c}"/></td> </tr> </tbody> </table> </div> <div class="panel panel-default"> <table class="table table-straped table-bordered"> <thead> <tr> <th>Observaciones</th> <th>Descripción de la reparación</th> <th>Producto Recibido</th> <th>Fecha de salida</th> <th>Owner</th> <th>Last Modified By</th> </tr> </thead> <tbody> <tr> <td><apex:outputField value="{!Boleta_Manual__c.OBSERVACIONES__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Descripci_n_de_la_reparaci_n__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.ProductoRecibido__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Fecha_de_salida__c}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.Owner.name}"/></td> <td><apex:outputField value="{!Boleta_Manual__c.name}"/></td> </tr> </tbody> </table> </div> <div class="panel panel-default"> <table class="table table-straped table-bordered"> <thead> <tr> <th>Codigo de Pieza</th> <th>Descripción del Producto</th> <th>Precio Costo Unidad</th> <th>Estado</th> </tr> </thead> <tbody> <!-- Aqui Valores de el Servicio #1 --> <apex:repeat value="{!Boleta_Manual__c.Piezas__r}" var="pr"> <tr> <td><apex:outputField value="{!pr.Name}"/></td> <td><apex:outputField value="{!pr.Producto__r.Descripci_n__c}"/></td> <td><apex:outputField value="{!pr.Producto__r.Precio_de_compra__c}"/></td> <td><apex:outputField value="{!pr.Estado__c}"/></td> </tr> </apex:repeat> </tbody> </table> </div> <div class="panel panel-default"> <table class="table table-straped table-bordered"> <thead> <tr> <th>Diagnostico</th> </tr> </thead> <tbody> <tr> <td><apex:outputField value="{!Boleta_Manual__c.Diagnostico__c}"/></td> </tr> </tbody> </table> </div> </div> </div> </div> </body> </html> </apex:page>
with
Hey Danny
Where you able to make this work? Did bib suggestion work for you?
unfortunately the suggestion doesnt work for me, but I want to confirm with someone else if the issue is mine.
Thanks
Can't remember which project was this, however I found another project where the PDF is rendering correctly, also you may want to check out this documents:
http://blog.terrasky.com/blog/create-a-render-a-visualforce-page-as-pdf-button
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_additional_render_pdf.htm
Here is the VF for the one I just tested and works fine. Hope this helps, thanks!
www.incompany.cr/salesforce
Thank you for your reply. I finally find out what is the issue, it seems when rendering into pdf it doesnt like big css files. On bootstrap i went to customize and took out most of the components, reducing the css file to 1000 lines and the pdf render as expected (the original css is around 8000 lines), then i increased to 1200 lines aprox, and the css broke and pdf just didnt render dislaying some visualforce errors.
This didnt make any difference in using minimize or non minimize versions.
maybe this is way in some other blogs they recommended to put inline css in the page, becuase inline will usually not be a long set of lines (I guess)