Results 1 to 17 of 17

Thread: Printing content to PDF - CSS issue

  1. #1
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default Printing content to PDF - CSS issue

    I am using built-in PDF printing option on some pages, but when I print them, the content is missing some parts of layout, e.g. tables have no borders, columns are narrower than supposed to be, background colour is removed, etc... Layout is specified with CSS rules which are not used by printer, obviously.

    Is there any way to change this (what you see is as it would be when you print a PDF document)?
    Last edited by tetrijeb; 03/13/2014 at 14:51.

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Tcpdf is very limited. You will have better results with dompdf. You can try extension dompdf for contao or try my moded version. With my version you can do some settings in BE-Settings. Add a Header and a Footer as far as I remember. And you can individualy select a css file for your PDFs. Don't know if it still works. Write me an email and I can send you my mod.

    Inside Contao tcpdf did not take notice of any CSS file.
    Last edited by Andreas; 03/14/2014 at 11:09.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Thank you for your reply.

    I've tried DOMPDF. It provides a slightly better result (table cells are properly aligned, background colour and borders are still missing), but has no support for Unicode.
    Last edited by tetrijeb; 03/14/2014 at 11:59.

  4. #4
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    I've send you a mail with 2 versions for C2.9.5 and C3.?. AFAIK dompdf meanwhile supports unicode. I've had no problems with german special chars äöüß.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  5. #5
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Quote Originally Posted by Andreas View Post
    AFAIK dompdf meanwhile supports unicode. I've had no problems with german special chars äöüß.
    I just checked, it states

    Use DOMPDF to export articles as PDF.

    This is the former "dompdf" core plugin. It has been moved to the extension repository, because it is outdated and TCPDF is much faster and provides full unicode support.
    so it seems it works with some character sets, but not with Serbian letters č,ć,š,ž...

  6. #6
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    The speed of dompdf will not be a problem.

    There's a dompdfconfig.php in system/config/
    PHP Code:
    /**
     * Whether to use Unicode fonts or not.
     *
     * When set to true the PDF backend must be set to "CPDF" and fonts must be
     * loaded via load_font.php.
     *
     * When enabled, dompdf can support all Unicode glyphs.  Any glyphs used in a
     * document must be present in your fonts, however.
     */
    def("DOMPDF_UNICODE_ENABLED"true); 
    I have another small extension where you can set a CSS file for tcpdf but its not fun trying CSS in tcpdf.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  7. #7
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Check your mailbox. My mail could not be delivered as your mailbox is full. Did you get my extensions?
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  8. #8
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Quote Originally Posted by Andreas View Post
    Check your mailbox. My mail could not be delivered as your mailbox is full. Did you get my extensions?
    No, I am not sure that inbox is problem, but just in case, I cleaned it up right now. I've got one other mail recently without any problem. What is the size of attachment?

  9. #9
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Feedback (using your mod):

    After a couple of hours of experimenting I came to this: CSS implementation worked perfectly. Output layout is identical to that on HTML page. In some segments even better...

    The char issue was not so successful. I've got some of the chars like Š,š,Ž,ž, but č,ć,đ are simply omitted. I simply can't find proper font. But at one moment, I almost made it. I've got all letters but font was horrible (and I don't remember now what font was it - it looks like type-machine output with huge spacing. After that I returned to Arial, Verdana, etc. but now I am lost. I am not sure where I should change output font. I can't find it any more. Wherever, whatever I try, I have same result. Could you give me a hint? Or I will just upload it again from start.

    Anyway, font quest should be continued.

    PS. Ü, ü, Ö, ä ß are working for me too. No problems with that.

    PS 2. All this is for latin letters, and I didn't even tried with cyrillic. :/

    /* End of feedback */

  10. #10
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Maybe this can help as a first step

    http://stackoverflow.com/questions/2...or-entire-page
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  11. #11
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Quote Originally Posted by Andreas View Post
    Maybe this can help as a first step

    http://stackoverflow.com/questions/2...or-entire-page
    Finally! And perfect! Whole thing could be achieved with CSS. Appropriate font family is dejavu (all versions, but I choose dejavu sans condensed - it looks better IMO).

    Thanks, Andreas once more. I owe you a beer, or wine, or whatever drink you prefer...

  12. #12
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Ok I take a Southern Comfort Cheers!
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  13. #13
    User
    Join Date
    10-12-13.
    Posts
    104

    Default dompdf

    Hi!
    I have the same problem with printing pdf wit unicode ščćžđ letters, but in attached pdf invoices in emails. I'm using isotope eccommerce and have istalled dompdf!
    Any idea how to I config in enable it?
    Best regards, Goran

  14. #14
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Quote Originally Posted by essecosi View Post
    Hi!
    I have the same problem with printing pdf wit unicode ščćžđ letters, but in attached pdf invoices in emails. I'm using isotope eccommerce and have istalled dompdf!
    Any idea how to I config in enable it?
    Best regards, Goran
    Hi, Goran.

    Did you set correct font family in dompdf settings?

  15. #15
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    And the font must be available in system\modules\dompdf\resources\lib\fonts

    Also take a look into this folder, theres a mustRead.html.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  16. #16
    User
    Join Date
    10-12-13.
    Posts
    104

    Default

    Quote Originally Posted by Andreas View Post
    And the font must be available in system\modules\dompdf\resources\lib\fonts

    Also take a look into this folder, theres a mustRead.html.
    I have it only in /composer/vendor/dompdf and not in /system/modules

  17. #17
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    I'm talking about Contao 3.5.x without composer. Don't know how to do it in C4 or with composer. So you should know, where your extension resists in.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •