7

I'm building out a Bootstrap website in Salesforce and I now have a requirement to allow the users to download some of the pages as PDFs. Unfortunately, when I use renderAs="PDF", I get this error:

Error accessing PDF resource 
Resource url = https://cs22.salesforce.com/resource/1430422148000/Bootstrap_3_1_1/bootstrap-3.1.1-dist/css/../fonts/glyphicons-halflings-regular.eot

The resource does exist. I don't use the glyphicons on this page, but I'd hate to remove them from the static resource when I might use them elsewhere. What can I do?

For reference, this line will cause the error (when renderAs="PDF"):

<apex:stylesheet value="{!URLFOR($Resource.Bootstrap_3_1_1, 'bootstrap-3.1.1-dist/css/bootstrap.min.css')}" />

Update: We ended up dropping PDF support because of the limitations on what Salesforce can turn into a PDF—and look good.

  • How are you linking to the resource on your page? Notice the resource is timestamped: .../resource/1430422148000/.... – Adrian Larson May 15 '15 at 21:22
  • It's a Static Resource, so I'm using $Resource to link the Bootstrap CSS, and that relatively includes the glyphicons. – ricksmt May 15 '15 at 21:37
  • can you share the portion of code that errors out ? – Mohith Shrivastava May 15 '15 at 21:50
  • I don't get that error when I change a Bootstrap page to renderAs="PDF". (The PDF rendering of Bootstrap is not surprisingly pretty poor though.) I presume you have double checked that the font files are present at "css/../fonts"? – Keith C May 15 '15 at 22:46
  • @Keith Correct. The files do exist. – ricksmt May 15 '15 at 22:47
3

In the bootstrap css file change the relative paths to the glyphicons fonts to some CDN e.g. change

../fonts/glyphicons-halflings-regular.eot

to

https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/fonts/glyphicons-halflings-regular.eot

| improve this answer | |
  • 1
    The Salesforce server doesn't handle external requests well. Seems there might be a workaround using Documents, but I haven't tried it as we dropped this feature. – ricksmt Aug 28 '15 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.