Developer forum

Forum » Templates » RE: Generate PDF based on specific defined template

RE: Generate PDF based on specific defined template

Mikkel Toustrup Olsen
Reply

Hello,

I have created a custom print.html template, which renders a print version of a given page. The print layout when hitting ctrl+p or a button command is just fine, however when I try to create a PDF on the given page by adding ?pdf=true&landscape=true to the URL it crashes and gives me the following error: 

System.Exception: PDFClass constructor exception ---> WebSupergoo.ABCpdf9.Internal.PDFException: Unable to render HTML. ABCPDF_INTERNAL_MSHTML_RENDERED_IN_IE9_MODE (HTTP 200). at WebSupergoo.ABCpdf9.Doc.AddUrlHtml(String urlOrHtml, Boolean isHtml, Boolean paged, Int32 width, Boolean disableCache) at WebSupergoo.ABCpdf9.Doc.AddImageUrl(String url, Boolean paged, Int32 width, Boolean disableCache) at WebSupergoo.ABCpdf9.Doc.AddImageUrl(String url) at Dynamicweb.PDFClass..ctor(String strUrl, Boolean landscape, Boolean letter, Int32 leftRightMargin, Int32 topBottomMargin) --- End of inner exception stack trace --- at Dynamicweb.PDFClass..ctor(String strUrl, Boolean landscape, Boolean letter, Int32 leftRightMargin, Int32 topBottomMargin) at Dynamicweb.Frontend.PageView.Output()

I am currently querying: www.domainname.dk/somepage.aspx?template=print.html&pdf=true&landscape=true ..

Am I missing something? :)

Thanks

/MikkelTO


Replies

 
Mikkel Ricky
Reply

You may have something in your HTML that ABCpdf cannot handle (cf. http://www.websupergoo.com/support.htm#6.7). Try validating your page using the print template.

Best regards,
Mikkel

 
Mikkel Toustrup Olsen
Reply

I ran through the checks listed - All should be fine. 

Am I doing it the "wrong" way around by querying as ?template=print.html&pdf=true&landscape=true ..

I can get it to work(it generates a pdf) by copying the print.html to a folder and query the url like ?LayoutTemplate=folder/print.html?pdf=true&landscape=true, however it does not render any content/values like the template=print.html does.

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel


template=xxx is from the old stylesheet way of implementing Dynamicweb.

LayoutTemplate=Designs/Condition/Print.html is what you should use when using designs & layouts (according to documentation).

Your path seems wrong in you example code above. You need to specify Designs/NameOfYourDesign/LayoutFileName.html

Otherwise post the real URL and we will have a look

Nicolai

 
Mikkel Toustrup Olsen
Reply

Hi Nicolai,

That does not seem to do the trick. 

http://silhorkosandbox.net.dynamicweb-cms.com/forside-5/50_m3-h_continuous_supply_of_ultrapure_water_for_chemical_production.aspx?LayoutTemplate=Designs/Silhorko/print.html

The above mentioned URL is the URL to the print.html - however it only shows some text, which goes in the bottom on the "working template". This is because im inserting different values via a snippet (which outputs perfectly on the ?template=print.html method as you can see).

The solution is quite old - why I think the ?template=print.html is the way to go .. ?

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Arh - misunderstood something. This site is not using designs and layouts. So of course you should use ?template=print.html.

The error comes because there is something in your HTML that will not render on the server. Like Mikkel said. Try snipping out bits and pieces until it works to find out what exactly does not work. It is not a DW thing - it is something that IE on the server cannot render.

BR Nicolai

 
Mikkel Toustrup Olsen
Reply

Hi Nocilai,

Well I tried your suggestion, with no luck unfortunately. Then I tried, simply to create a new html file blank - with only some random text in it and parsed this as: ?template=empty.html&pdf=true - and it stills give me the exception. 

in the empty.html template i have tried with and without <html> </html> markup as well, without no luck either.

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Try on another page. It could be a caching issue...

 
Nicolai Høeg Pedersen
Reply

Hi Mikkel

Does not work either. If you check http://silhorkosandbox.net.dynamicweb-cms.com/forside-5/50_m3-h_continuous_supply_of_ultrapure_water_for_chemical_production.aspx?template=blank.html it has a lot of HTML still. Try removing that as well. You might need a new master template as well without all the 'crap'.

You can override the master template doing this: &MasterTemplate=some.html

 
Mikkel Toustrup Olsen
Reply

Hey Nicolai,

By removing the mastertemplate the ?template=page.html&pdf=true etc. actually worked - so there must have been somethingi n the mastertemplate it couldn't render. Styling wise - is there any best practice on the "old way" of doing so to this template. The font etc. in the generated PDF seems to be quite larger than the styles on the acutal html file :) ?

 
Nicolai Høeg Pedersen
Reply

Usually it is not a problem.

The font issue is probably because you removed the CSS in the master that handles the font. Make sure you have another CSS included instead.

Nicolai

 
Michael Stigaard Sørensen
Reply

I had the same problem. I solved it by setting "Load User Profile" to True in the Application Pool settings.

Michael

 

 

You must be logged in to post in the forum