Welcome Guest Search | Active Topics | Sign In | Register

PDF loses styling when printed from one server but not others Options
KevinM
Posted: Monday, September 16, 2013 4:11:25 AM
Rank: Newbie
Groups: Member

Joined: 9/4/2013
Posts: 8
We have been working successfully with MVC To PDF until now. We tested in our development environments and test servers. Then when we put it on live it lost all its styling.

We think it might be down to differences between servers. They are all IIS so we are trying to find out version information from our IT team. Is MVC to PDF dependent on server issues? The sites are all https.

We also have [RenderAsPDF(AutoConvert = false)].
eo_support
Posted: Monday, September 16, 2013 8:38:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Please check if this is the problem:

http://www.essentialobjects.com/doc/4/web/troubleshoot.aspx

When the PDF file loses style, it means the converter can not get the CSS file. If you have a DNS problem on the server as described above, then the converter would not be able to get the CSS files.

Thanks!
KevinM
Posted: Monday, September 16, 2013 9:10:17 AM
Rank: Newbie
Groups: Member

Joined: 9/4/2013
Posts: 8
Our server guy is investigating. It turns out we are using a load balancer and one of its effects is as described in your link so we are configuring it. I will report back if/when it all gets resolved.
KevinM
Posted: Monday, September 16, 2013 9:53:58 AM
Rank: Newbie
Groups: Member

Joined: 9/4/2013
Posts: 8
Yes, we are having the DNS problem as described.
How do we go about fixing it when we are using a custom port instead of port 80? It is not possible to add a custom port to the hosts file.
eo_support
Posted: Monday, September 16, 2013 10:03:02 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Usually the port does not matter. If the port Url the converter see and the port the custom see are different, then you will either need to set BaseUrl manually, or configure your server such that your server will still serve on the same port as the customer sees it.

For example, if user enter "http://www.yoursite.com/page1.aspx", but your web server actually only handles http://www.yoursite.com:1234/page1.aspx", then you have two options:

1. Configure your web server so that it can handle both "http://www.yoursite.com:1234/page1.apsx" and "http://www.yoursite.com/page1.aspx". This way if the customer enters a Url, it gets redirect and handled through port 1234, but the converter still goes through port 80;

-- OR --

2. Set HtmlToPdf.Options.BaseUrl to "http://www.yoursite.com:1234" in your code. At runtime, the converter use BaseUrl to form the final Url in your page. For example, if you have something like "<style href='styles.css' />", then the converter use BaseUrl to resolve "styles.css" and use "http://www.yoursite.com:1234/styles.css" as the final Url to contact your web server;

Option 1 would be the preferred method since it does not require you to change your code. Option 2 would require you to change your code to explicitly set BaseUrl (I believe you would set it in your action method).

Hope this helps. Please let us know how it works out.

Thanks!
KevinM
Posted: Tuesday, September 17, 2013 3:47:57 AM
Rank: Newbie
Groups: Member

Joined: 9/4/2013
Posts: 8
We went for option 2 in the end and have managed to get this working. Thanks for your help. :)
eo_support
Posted: Tuesday, September 17, 2013 11:45:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
You are very welcome. Glad to hear that it's working for you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.