CSS for PDF Download

  • Paul T
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #113832 by Paul T
CSS for PDF Download was created by Paul T
In Eshop product pages it has the feature to Download a PDF of the page. Is there any way I can set CSS for the output of that PDF. I want to set images that have a particular class to display none in the PDF only.

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
6 years 6 months ago #113840 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic CSS for PDF Download
Hello Paul,

You can edit layou of Product PDF by editing the file components\com_eshop\pdftemplates\default.php

Hope that this is useful.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

  • Paul T
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #113852 by Paul T
Replied by Paul T on topic CSS for PDF Download
Unfortunately it didn't help as the output doesn't take any notice of the normal css file.
The line that outputs the html is
Code:
<?php echo $this->product->product_desc; ?><br />

Is it possible to write an inline css declaration here that would affect the code in product_desc?

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
6 years 6 months ago #114065 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic CSS for PDF Download
Dear Paul,

I am not sure about that. However, you can try to add the Style inline there if you want.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

  • Paul T
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #114075 by Paul T
Replied by Paul T on topic CSS for PDF Download
I have tried as many ways I can think of to add the inline CSS there but none of them worked. Obviously I need to learn more about PHP to make it work. I just assumed as you wrote this software you would know how to write the PHP to do that in your sleep.

If anyone else reading this forum post knows how to add inline CSS to that line of code (where the product_desc is pulling the html directly from the database) please let me know.

Thanks.

Please Log in or Create an account to join the conversation.

  • Paul T
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #114166 by Paul T
Replied by Paul T on topic CSS for PDF Download
The situation I was running into was, I was able to apply basic styles to pdftemplates/default.php using style tags but when I tried to use display none to an image which had a class, it just made everything blank on the PDF from that piont onwards.

Data: I found that eshop uses tcpdf to create PDFs and tcpdf only has very limited CSS capabilities. This stack overflow post explains this:
stackoverflow.com/questions/11395171/why...ignore-my-inline-css

Solution: I found that if I wrapped the image in a span tag and placed the class on the span instead. Then I was able to use display none to the span and the image didn't appear in the PDF out put and it worked fine.

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
6 years 6 months ago #114240 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic CSS for PDF Download
Dear Paul,

You should try to add the CSS inline in that file to make it work as the way that you want. It's not too hard I think.

Sincerely, Giang

Please Log in or Create an account to join the conversation.

  • Paul T
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 6 months ago #114242 by Paul T
Replied by Paul T on topic CSS for PDF Download
As far as I am concerned I have solved the issue I just put up the last reply so anyone else with this issue has some idea of what I ran into so it may help them.

Please Log in or Create an account to join the conversation.

  • Giang Dinh Truong
  • Offline
  • Administrator
  • Administrator
More
6 years 6 months ago #114243 by Giang Dinh Truong
Replied by Giang Dinh Truong on topic CSS for PDF Download
OK Paul!

Please Log in or Create an account to join the conversation.

Moderators: Giang Dinh Truong