Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AbcPdf - document not applying CSS

Tags:

abcpdf

This may be more of a tech support issue, but I'm wondering if any other developers have come across this:

I'm using Abcpdf in my ASP.NET code to generate a PDF from HTML. It works fine, but one user is generating PDFs that don't have the CSS applied (IE8, Adobe Acrobat latest version - same as everyone else). Since this is the only user complaining, I'm sure it's a local setting, but I can't figure out what would prevent the css from loading - a browser setting? An Acrobat setting?

Does anyone have any suggestions?

like image 624
Barryman9000 Avatar asked Jan 20 '10 20:01

Barryman9000


3 Answers

Perhaps an issue with different versions of Acrobat reader? I'd look into this.

This doesn't make a lot of sense because AbcPdf uses service side logic to create the PDF based on what methods you are using to create the document (ex. AddImageUrl vs drawing out the document manually, etc.).

For what it's worth the staff at WebSuperGoo (the vendor of AbcPdf) is great with replying to support questions such as this. I've run across a few edge cases with their product that they've always followed up with workarounds or alternatives to address in a timely manner.

like image 164
Jakkwylde Avatar answered Sep 28 '22 05:09

Jakkwylde


make sure you have media="print" for the CSS style sheet! Just spent ages looking at this pulling my hair out and was about to email WebSuperGoo then that thought came to me. just about to back out all the changes I've made to my code and test again but it looks like with EngineType.Gecko it needs to be media="print" where as with EngineType.MSHtml it can be media="screen".....

very odd but hope that helps someone!

like image 35
Daniel Gent Avatar answered Sep 28 '22 06:09

Daniel Gent


Make sure that the CSS is an absolute URL rather than relative, or add a base tag to the header of the HTML

For example, rather than

<style type="text/css" href="/styles/somecss.css" rel="stylesheet" />

use

<style type="text/css" href="http://myserver.com/styles/somecss.css" rel="stylesheet" />

Also if you site is SSL or authenticated then you will have to either make the area with the stylesheet un-authenticated, or, set the password and username attributes of the PDF object so that ABCPdf can authenticate

like image 35
Feuerwehrmann Avatar answered Sep 28 '22 04:09

Feuerwehrmann