Wanze Posted April 13, 2016 Author Share Posted April 13, 2016 Glad it works! I'll check if this is an issue with my module or mPDF in general. Am I write that the file call's the module needs to be included before any other files? I am assuming this has to do wit the header that has to be sent. The order of the includes doesn't matter, but you need to be careful not sending any output (headers) to the browser before downloading the PDF. For example echo out something, though in the context of ProcessWire all echos in your template are catched by PHPs output buffer, so you should be fine. You'd get warnings if that happens, something like "Headers already sent" Cheers 2 Link to comment Share on other sites More sharing options...
RyanJ Posted April 13, 2016 Share Posted April 13, 2016 Thanks Wanze, the output headers was one of my issues indeed. I am back at it again with some issues getting custom fonts to load. In this case I have read a few topics in the forum as well as the manual here. I am attempting to include an Open Sans font. The steps I have taken are so. Added ttf file to modules/Pages2Pdf/mdf/ttfonts modified config_fonts.php $this->fontdata = array( "dejavusanscondensed" => array( 'R' => "DejaVuSansCondensed.ttf", 'B' => "DejaVuSansCondensed-Bold.ttf", 'I' => "DejaVuSansCondensed-Oblique.ttf", 'BI' => "DejaVuSansCondensed-BoldOblique.ttf", ), "opensans" => array( 'R' => "OpenSans.ttf", 'B' => "OpenSansB-Bold.ttf", 'I' => "OpenSansI-Italic.ttf", ), Changed Mode in the module settings to "s" Updated the Default Font in the Module Settings to "OpenSans" Anything stand out that I am missing? Link to comment Share on other sites More sharing options...
Gideon So Posted May 9, 2016 Share Posted May 9, 2016 Hi, All Chinese characters in the output pdf file become . How to config to use CJK fonts?? Thanks. Gideon Link to comment Share on other sites More sharing options...
Gideon So Posted May 10, 2016 Share Posted May 10, 2016 Hi, All Chinese characters in the output pdf file become . How to config to use CJK fonts?? Thanks. Gideon Work it out myself. Maybe someone need the answer. Here it is. 1. Download mpdf 6.0 from http://www.mpdf1.com/mpdf/index.php 2. copy the Sun-ExtA.ttf file to /path/to/your/web/site/modules/Pages2Pdf/mpdf/ttfonts 3. add the following lines to /path/to/your/web/site/modules/Pages2Pdf/mpdf/config_fonts.php "sun-exta" => array ( 'R' => "Sun-ExtA.ttf", 'sip-ext' => 'sun-extb', ), 4. change the mode to R in WirePdf module config page 5. Chang fonts to sun-exta in WirePdf module config page Done. Gideon 2 Link to comment Share on other sites More sharing options...
a.masca Posted May 19, 2016 Share Posted May 19, 2016 Hello and thanks for the great module!! Everything seems to work but I have a doubt. I should create a pdf of a list of events that are setup by the user via a form. I would then pass a variable with the exact list to the template that I use to create PDF, but I can not. Some idea? Thanks so much Andrea Link to comment Share on other sites More sharing options...
Wanze Posted May 20, 2016 Author Share Posted May 20, 2016 Hi a.masca Can you share your current code? Do you store the events inside ProcessWire or are they only available after submitting the form? Cheers Link to comment Share on other sites More sharing options...
a.masca Posted May 20, 2016 Share Posted May 20, 2016 Hi a.masca Can you share your current code? Do you store the events inside ProcessWire or are they only available after submitting the form? Cheers Thanks Wanze for the answer. In the page where I want to put my download pdf button, I have a list of reservations (every reservation is a page) that the user can filter with a form. example: $prenotazioni = $pages->find("template=prenotazione, giorno=xxx"); So my goal is to pass to the pages2pdf this variable $prenotazioni, so the user can download the pdf of the list that he filtered. Thanks a lot Andrea Link to comment Share on other sites More sharing options...
Tony Carnell Posted July 9, 2016 Share Posted July 9, 2016 Hi all, This is a brilliant module, but I have noticed something unexpected, that I hope someone can help with. I have a text string which contains a degree symbol ( ˚ ) but for some reason the produced PDF replaces that symbol with a question mark - indicating it doesn't understand it (the same string appears fine on the html page itself). I have made sure the string is UTF-8 encoded and I'm using the Times font when outputting the PDF. Does anyone have any ideas why this is happening and any possible way of fixing it? All the best, Tony. Link to comment Share on other sites More sharing options...
Tony Carnell Posted July 24, 2016 Share Posted July 24, 2016 Hi all, How do you go about adding a page break to your generated PDF? I've tried adding <? $pdf = $modules->get('WirePDF'); $pdf->AddPage(); ?> into the template file, but although it doesn't give an error when rendering the PDF, neither does it add a new page! All help gratefully received. Tony. Link to comment Share on other sites More sharing options...
bernhard Posted July 24, 2016 Share Posted July 24, 2016 hi tony, did you read the manual? http://www.mpdf1.com/mpdf/index.php 2 Link to comment Share on other sites More sharing options...
Tony Carnell Posted July 24, 2016 Share Posted July 24, 2016 34 minutes ago, bernhard said: hi tony, did you read the manual? http://www.mpdf1.com/mpdf/index.php Thanks for the link Bernhard. I had read other online documentation, but it didn't make it clear that all you had to do was include the HTML tag <pagebreak />. I did that and voila, a page break Thanks again, Tony. 2 Link to comment Share on other sites More sharing options...
Wanze Posted July 24, 2016 Author Share Posted July 24, 2016 On 9.7.2016 at 11:23 PM, Tony Carnell said: I have a text string which contains a degree symbol ( ˚ ) but for some reason the produced PDF replaces that symbol with a question mark - indicating it doesn't understand it (the same string appears fine on the html page itself). I have made sure the string is UTF-8 encoded and I'm using the Times font when outputting the PDF. Does anyone have any ideas why this is happening and any possible way of fixing it? Hi Tony, Could you already solve this problem? It looks like this character is not included in the chosen font, maybe try another one? How did you output the degree symbol, hardcoded or with an entity, e.g. ° ? Cheers Link to comment Share on other sites More sharing options...
hheyne Posted August 16, 2016 Share Posted August 16, 2016 Hello, big thanks for this wonderful modul. I have here a interesting problem. If I save 2 pages with individual templates, the second page always gets the first template. I want to create an invoice and a list of items. Is there something to keep an eye on when doing such stuff? This is my code: $rechnung = new Page(); $rechnung->template = "rechnung"; $rechnung->parent = wire('pages')->get("/rechnungen/"); $rechnung->title = "HG-".$order->id; $rechnung->orderid = $order->id; $rechnung->save(); $rechnung->of(false); $mail->attachment(wire('modules')->get('Pages2Pdf')->getPDFFilePath($rechnung)); $stueckliste = new Page(); $stueckliste->template="stueckliste"; $stueckliste->parent = wire("pages")->get("/stuecklisten/"); $stueckliste->title = "HGSL-".$order->id; $stueckliste->orderid = $order->id; $stueckliste->save(); $stueckliste->of(false); $mail->attachment(wire('modules')->get('Pages2Pdf')->getPDFFilePath($stueckliste)); Both templates are configured for pages2pdf and I have for both of them an template-file underneath pages2pdf. The first one use the template rechnung and the second page also uses the page rechnung. I use the newest version of pages2pdf and processwire 2.7.2 in combination with the actual release of padloper. Has anyone here in the forum an idea howto solve this? Thanks Henning Link to comment Share on other sites More sharing options...
Wanze Posted August 16, 2016 Author Share Posted August 16, 2016 Hi Henning, Interesting approach on how to use the module Looks like a caching problem to me, could you try to add $this->pdf = null after this line: https://github.com/wanze/Pages2Pdf/blob/master/Pages2Pdf.module#L218 The code should then look like the following snippet: [...] } else { $this->create($page, true); $name = $this->getPDFFilename($page); $this->wire('session')->message(sprintf($this->_("Pages2Pdf: Created PDF file(s) '%s'"), $name)); } // Add me! $this->pdf = null; } Cheers 4 Link to comment Share on other sites More sharing options...
hheyne Posted August 16, 2016 Share Posted August 16, 2016 Hi Wanze, thank you very much for the lightning fast response. It works with this addition. BR Henning Link to comment Share on other sites More sharing options...
cappuccino Posted August 28, 2016 Share Posted August 28, 2016 Hey thanks a million for this modul Unfortunately, I have some troubles. I've installed the modul, add the current template in the settings and tried it out. In the template file (htdocs/site/templates) I've add this code, like in the instructions: echo $modules->get('Pages2Pdf')->render(); But I receive always the same error. Something like "Error loading PDF-File". What's wrong? Did I forgot something? I use Processwire 3.0.29. Thanks for your help. PS: Sorry for my "English" Link to comment Share on other sites More sharing options...
Wanze Posted August 31, 2016 Author Share Posted August 31, 2016 @cappuccino You're welcome, I never saw this error before. What is the content of your ProcessWire PDF template (site/templates/pages2pdf/..) that is rendered by the module? Does it work if you you just put a "Hello World" in it? If so, you'd need to simplify your markup and debug what is causing the error. Cheers Link to comment Share on other sites More sharing options...
jploch Posted August 31, 2016 Share Posted August 31, 2016 Hi! Thanks for this great module! This is probably easy, but I cant get it to work (Iam a PHP noob). I want to generate two PDfs (with different templates) from the same page. I have two files in the pages2pdf folder under templates (expose_preisliste.php, expose_wohnung.php). If I understand correctly I would set it up like this: $preisliste = $modules->get('WirePDF'); $preisliste->markupMain = $config->paths->templates . 'expose_preisliste.php'; $preisliste->save('preisliste.pdf'); $wohnung = $modules->get('WirePDF'); $wohnung->markupMain = $config->paths->templates . 'expose_wohnung.php'; $wohnung->save('wohnung.pdf'); Now I want two links on the frontend to download the files. How do I call the variable for the Link? I want the PDFs to be generated when clicking the link. Thx for your help! I managed to get this working. Link to comment Share on other sites More sharing options...
jploch Posted August 31, 2016 Share Posted August 31, 2016 Now I have a new Problem. I have several pages I just use for data storage (no template file associated). The pages are all children of a page called "wohnen". The data of those pages is used on the page home. Now I want to create a PDF from all these pages (of parent "wohnen"). To let the module know wich PDFs to generate I used a session. In my template for generating the PDFs I have something like this: session_start(); $wohnungsnr = $_SESSION['wohnungsnr']; <?php $targetPage = "/$wohnungsnr/"; $wohnung = wire('pages')->get($targetPage); $out = " <h1>{$targetPage}</h1> "; $out .=" <div id='{$wohnungsnr}-content' class='fbox-content'> <div class='grid'> <h1 class='size1of1'>{$wohnung->headline}</h1> "; foreach ($wohnung->grundrisse as $grundriss) { $out .= "<img class='size1of3' src='{$grundriss->url}'>"; }; $out .= " <div class='size1of3 wohnung-content'> <table> <tr> <th>Wohnungstyp</th> <th>Etage</th> </tr> <tr> <td>{$wohnung->options_zimmer->title} Zimmer</td> <td>{$wohnung->options_etage->title}</td> </tr> <tr> <th>Grösse</th> <th>Kaufpreis</th> </tr> <tr> <td>{$wohnung->size}</td> <td>{$wohnung->preis}</td> </tr> <tr> <th colspan='2'>Ausstattung</th> </tr> <tr> <td colspan='2'> <ul> "; foreach ($wohnung->ausstattung_repeater as $item) { $out .= " <li>– {$item->headline}</li> "; } $out .= "</ul> </td> </tr> </table> </div> </div> </div> "; echo "{$out}"; ?> <?php include("_footer.php"); ?> On the page home I have a function that shows all the data from the children of the"wohnen" page with a download button for every page. My Idea was to change the session variable on click of the download buttton to let the pdf template know wich page to render. Any Ideas how this works? You can delete this post I figured it out. I send the variable with the URL like this: <a href='$page->url?pages2pdf=1&wohnungsnr={$wohnung->title}' class='button' id='{$wohnung->title}'><img src='http://projekte.janploch.de/fabricius/site/templates/img/icon-download.svg' class='button-icon'>Download Exposé</a> Link to comment Share on other sites More sharing options...
celfred Posted September 3, 2016 Share Posted September 3, 2016 Hello, I'm struggling with this : a 504 Gateway Timeout when generating my PDF. I used to be able to generate a particular PDF listing 52 places with a photo (small), a little text and a few pieces of information for each in a table. It worked and I had a PDF of about 350Ko. Now, I'm trying to generate a PDF of about 250Kos and I get the 504 error. I've tried to re-generate my places catalogue and again, I have the 504 error. All my templates work fine (although it takes a little while) to generate smaller PDF files. The page I'm trying to generate is : http://planetalert.tuxfamily.org/players/4e/amandine If someone have advice on how I could find my way out of this, I'd greatly appreciate Thanks ! Link to comment Share on other sites More sharing options...
hheyne Posted September 4, 2016 Share Posted September 4, 2016 I want to let it work with PHP7. I get this error message: Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; mPDF has a deprecated constructor in /site/modules/Pages2Pdf/mpdf/mpdf.php on line 66 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; grad has a deprecated constructor /site/modules/Pages2Pdf/mpdf/classes/grad.php on line 3 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; form has a deprecated constructor in /site/modules/Pages2Pdf/mpdf/classes/form.php on line 3 Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; cssmgr has a deprecated constructor in /site/modules/Pages2Pdf/mpdf/classes/cssmgr.php on line 3 %PDF-1.4 % 3 0 obj <> /Contents 4 0 R>> endobj 4 0 obj <> stream xOO0\IhN=bZW$~wi+(\ `'l4cm=@Κ|҃7X(c)qe8嶴~wuxj=ϭ; Gۗ}qE k4FX"%7_Y`Id-#US,qڪQ!)$5|LJO(qiuYvr]ǿbnsP\\ Ґb,ߞymAM*{Hv6EÞy{(ŵjV/M x98F&P{y=+^mKi߀&mKU^0}Y֊';#lKO)]Iҍ,<_216=q0 endstream endobj 1 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj 7 0 obj <> endobj 8 0 obj <> endobj 9 0 obj <> endobj 2 0 obj <> /ExtGState << /GS1 5 0 R >> >> endobj 10 0 obj << /Producer (mPDF 5.7.4) /CreationDate (20160904200643+02'00') /ModDate (20160904200643+02'00') >> endobj 11 0 obj << /Type /Catalog /Pages 1 0 R /OpenAction [3 0 R /XYZ null null 1] /PageLayout /OneColumn >> endobj xref 0 12 0000000000 65535 f 0000000713 00000 n 0000001255 00000 n 0000000015 00000 n 0000000223 00000 n 0000000802 00000 n 0000000863 00000 n 0000000959 00000 n 0000001060 00000 n 0000001158 00000 n 0000001401 00000 n 0000001529 00000 n trailer << /Size 12 /Root 11 0 R /Info 10 0 R /ID [<3df5fdeb256069fc900acdab6c3ab3f0> <3df5fdeb256069fc900acdab6c3ab3f0>] >> startxref 1639 %%EOF Any hints? Thanks! Link to comment Share on other sites More sharing options...
netcarver Posted October 15, 2016 Share Posted October 15, 2016 @hheyne @Wanze I'm hitting the same problem with this module. PW3.0.36 and PHP7. Even though they are only notices, this seems to stop the PDF file from being correctly generated (at least, for me.) Is the mPdf project still being maintained? I wonder if a patch is in the works for this? Link to comment Share on other sites More sharing options...
BitPoet Posted October 16, 2016 Share Posted October 16, 2016 The latest version of mPDF (7.0.0) already supports PHP 7, so it should be just a matter of pulling the latest sources into the module (unless there were breaking changes since 5.7). 1 Link to comment Share on other sites More sharing options...
Matt_P Posted October 20, 2016 Share Posted October 20, 2016 Hi everyone, I've just installed this module and it works lovely. However I am unsure as to a few things. I would like to call my original css files "main.css" in my templates folder to use on the pdf. As of now it doesn't seem to load any CSS. I added some inline-styles to the files in the "pages2pdf" folder and they did not seem to load. Reading the module files I see the below. Though I am unsure what the difference between the two CSS option are. Also I'm unsure as to what I put in them. Where do I start the path? etc. I apologize for my ignorance of PHP and PW. protected static $config = array( 'markupMain' => '', 'markupHeader' => '', 'markupFooter' => '', 'mode' => 'c', 'pageOrientation' => 'P', 'pageFormat' => 'A4', 'topMargin' => 30, 'rightMargin' => 15, 'bottomMargin' => 20, 'leftMargin' => 15, 'headerMargin' => 5, 'footerMargin' => 10, 'font' => 'Helvetica', 'fontSize' => 12, 'author' => '', 'headerFirstPage' => 1, 'cssFile' => '', //this one 'css' => '', //and this one ); Also is there a way to remove the auto generated header and footer that the pdf seems to generate. The ones that says "default header..." "...created with processwire and pages2pdf..." as well as the header and footer for the website (the one I made). I get seem to get both some times and sometimes not. Finally some of my images don't appear to load. I've read that there are issues with background-images, but this is just a regular image element. Note: I have deactivated the header and footer settings in the back-end module settings but I still get the default head/foot, infact everything I change does not appear to have anything effect, even changing from portrait to landscape; it will still come out portrait. Any help is much appreciated. Thanks, Matt Link to comment Share on other sites More sharing options...
Wanze Posted October 28, 2016 Author Share Posted October 28, 2016 @Matt_P It sounds like you always get a cached PDF. Try enabling the debug mode or change the cache time to "0" in the Pages2Pdf, then you should actually see your settings taking place. As for the image, can you share your code? Be aware that CSS support is limited when rendering the PDF, that's why you should load a separate CSS file containing the styles just for the PDF's. Cheers Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now