webhoes Posted September 11, 2020 Share Posted September 11, 2020 2 hours ago, kongondo said: @webhoes it is recommended to use the spoiler tags to wrap very long text. I've done this for your post above. Thanks. Sorry @kongondo, I was not aware that. Thanks. Link to comment Share on other sites More sharing options...
kongondo Posted September 11, 2020 Share Posted September 11, 2020 59 minutes ago, webhoes said: Sorry @kongondo, I was not aware that. No worries...but no need to apologise though ?. It's just a 'community' recommendation not a rule. Link to comment Share on other sites More sharing options...
a-ok Posted December 2, 2020 Share Posted December 2, 2020 Is it possible to assign a PDF filename via a hook? I want to assign a different filename (custom, not using {page.id} etc) for different pages. Link to comment Share on other sites More sharing options...
webhoes Posted December 2, 2020 Share Posted December 2, 2020 6 minutes ago, a-ok said: Is it possible to assign a PDF filename via a hook? I want to assign a different filename (custom, not using {page.id} etc) for different pages. Probably. You can also do this and use variables. $print_date = date("jMY", time()); $pdf->save(); $pdf->download('Logbook - ' . $drone->title . ' - ' . $print_date . '.pdf'); Link to comment Share on other sites More sharing options...
pwFoo Posted December 9, 2020 Share Posted December 9, 2020 Hi, I would build a website with embedded videos (because of used video source maybe need to use iframe...) and would like to export sites to PDFs. Before I start with PW / pages2pdf... is it possible to export a page to pdf with the embedded video? Anyone tested that use case? Regards Link to comment Share on other sites More sharing options...
tires Posted July 20, 2021 Share Posted July 20, 2021 Is there a way to get this running with php 7.3? How can i upgrade the mpdf version? The files that i can download here https://github.com/mpdf/mpdf/releases doesn't look very much like the ones i got in my /site/modules/Pages2Pdf/mpdf folder. Or is this module not usable anymore? Thanks! 2 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 15, 2021 Share Posted October 15, 2021 Hi, i need some help from you prefessionals. I need to generate multiple pdf´s on the same page but with different content and styling. So you could have the folder for example /pages2pdf _footer.php, _header.php, _default.php, styles.css _footer2.php, _header2.php, _default2.php, styles2.css etc.. This is my generated button from the module i have now. So i need multiple buttons on the same page that generates different content and styling. <?php $options = array( 'title' => 'Print PDF', 'markup' => '<a href="{url}" target="_blank" title="OFFERT" rel="noopener"><div class="button secondary-button">OFFERT</div></a>', 'page_id' => '', // Pass a page ID if you want to download the PDF for another page ); echo $modules->get('Pages2Pdf')->render($options);?> Is that possible? Please somebody help... Link to comment Share on other sites More sharing options...
Wanze Posted October 23, 2021 Author Share Posted October 23, 2021 Hi @Flashmaster82 Quote I need to generate multiple pdf´s on the same page but with different content and styling. In this case you need to use the module "WirePDF" bundled in the Pages2Pdf module. You can use WirePDF to generate PDFs with custom content and styling. The readme has some examples how to do this: https://github.com/wanze/Pages2Pdf#wirepdf I suggest to also take a look at other existing ProcessWire PDF modules, as this one is really old and not maintained actively - it still works though ? Cheers 3 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 23, 2021 Share Posted October 23, 2021 For anyone with the same problem here is my code for generating custom and multiple pdf´s on the same page with different content and styling. <?php $pdf = $modules->get('WirePDF'); $pdf->markupMain = $config->paths->templates . '/pages2pdf/custom.php'; $pdf->markupFooter = $config->paths->templates . '/pages2pdf/custom_footer.php'; $pdf->cssFile = $this->config->paths->templates . '/pages2pdf/custom_style.css'; $pdf->pageOrientation = 'P'; $pdf->pageFormat = 'A4'; $pdf->bottomMargin = 10; $pdf->save('pages2pdf/custom.pdf'); echo "<a href='{$config->urls->templates}pages2pdf/custom.pdf' download>Download PDF</a>"; ?> 3 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted October 24, 2021 Share Posted October 24, 2021 Also if you want to preview the PDF when working on the styling. I added ob_clean(); because otherwise it only works in Firefox. <?php $pdf = $modules->get('WirePDF'); ob_clean(); $pdf->markupMain = $config->paths->templates . 'pages2pdf/custom.php'; $pdf->markupFooter = $config->paths->templates . 'pages2pdf/custom_footer.php'; $pdf->cssFile = $this->config->paths->templates . 'pages2pdf/custom_style.css'; $pdf->pageOrientation = 'P'; $pdf->pageFormat = 'A4'; $pdf->bottomMargin = 10; $pdf->download('pages2pdf/custom.pdf'); echo "<a href='{$config->urls->templates}pages2pdf/custom.pdf' download>Download PDF</a>"; ?> 2 Link to comment Share on other sites More sharing options...
Luigi Posted April 21, 2022 Share Posted April 21, 2022 Hello everyone. I started a while ago with processwire and I like it a lot ? But now I ran into some problems with pages2pdf and I hope someone has a solution for those problems: 1. I try to add pictures (mostly pngs) into a pdf but some aren't shown and I can't tell why. The picture are shown on the webpage but not in the created PDF: I create them with this command: $picture->size(100)->httpUrl It works for some pictures but not for all. I think it has something to to with the way processwire creates the smaller picture because it works fine with this command: $picture->httpUrl when I remove the size command. 2. to make it even more complicated, some pictures aren't even visible with this command. Maybe it's a problem with the transparency from png. but other formats and some pictures without transparancy are also affected. I would be happy if someone has a tip or could tell me what I'm doing wrong or if there is a setting to change, thanks. Link to comment Share on other sites More sharing options...
bernhard Posted April 21, 2022 Share Posted April 21, 2022 Hi @Luigi does ->filename work? Link to comment Share on other sites More sharing options...
Luigi Posted April 22, 2022 Share Posted April 22, 2022 Hello @bernhardthanks for your suggestion but filename works only for the picture where httpUrl is also working. I don't think it's a problem with the links but with the way the original picture are created. mostly pictures with a white or black background instead of as transparent one are working fine. ? Link to comment Share on other sites More sharing options...
Flashmaster82 Posted April 26, 2022 Share Posted April 26, 2022 You can only have Jpg images so try and change and see if it works. Link to comment Share on other sites More sharing options...
Cybermano Posted December 28, 2022 Share Posted December 28, 2022 Hi everybody. I'm using this module in a site, either in hooks and in page API and it works fine. (Actually in page API mPdf generates a deprecated method - v5.7 - that I suppress with a postponed @, but all work fine.) Now I'm trying to use it in an AJAX call, handled by another hook "ProcessPageView::execute", but I get an exception due a Page::localName as a method that doesn't exist or is not callable. (in /wire/core/Wire.php line 564) For me it's a strange behavior: why this exception in wire.php? And only with ajax call? I'm not sure, but I think it could depend by a "<br/>" outputted in the JSON parse (from where?), this is the message of the inspector: XHRGEThttps://pdftestsite.com/create-pdf/?page=3527 [HTTP/1.1 500 Internal Server Error 234ms] SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data 1 <br /> 2 3 4 Hmm… Error: Exception: Method Page::localName does not exist or is not callable in this context (in /wire/core/Wire.php line 564) 5 6 #0 /wire/core/Page.php(1808): ProcessWire\Wire->___callUnknown('localName', Array) 7 #1 /wire/core/Wire.php(420): ProcessWire\Page->___callUnknown('localName', Array) 8 #2 /wire/core/WireHooks.php(951): ProcessWire\Wire->_callMethod('___callUnknown', Array) 9 #3 /wire/core/Wire.php(485): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Page), 'callUnknown', Array) 10 #4 /wire/core/Wire.php(488): ProcessWire\Wire->__call('callUnknown', Array) 11 #5 /site/modules/Pages2Pdf/Pages2Pdf.module(506): ProcessWire\Wire->__call('localName', Array) 12 #6 /site/modules/Pages2Pdf/Pages2Pdf.module(261): Pages2Pdf->getPDFFilename(Object(ProcessWire\Page), 13 14 This error message was shown because: you are logged in as a Superuser. Error has been logged. 15 16 Does anyone have any idea? At the moment I solved with a in page if($input->get->savepdf) statement, but I prefer to use ajax for a much better controls of the responses. For completeness of information, this is the function invoked from the ajax call, but I'm quite sure it's correct: Spoiler // WIRE TRANSFER: Generate PDF // WIP - mPdf generates errors for deprecated methods private function create_pdf() { // if AJAX call if (wire('config')->ajax){ $pageID = $_GET['page']; $page = wire('pages')->get('id='.$pageID); header('Content-Type: application/json'); if (!wire('user')->isLoggedIn()){ echo json_encode([ 'result' => 'error', 'message' => __('User not recognized', '/site/templates/vouchers/translations/_vouchers.php') ]); exit(); } if (!$page->id){ echo json_encode([ 'result' => 'error', 'message' => __('Voucher page not found', '/site/templates/vouchers/translations/_vouchers.php') ]); exit(); } if ($page->id){ // GET user_lang and Create fresh PDF $lang_id = wire('languages')->get('name='.$page->user_lang_name); // Create file in user language wire('modules')->get('Pages2Pdf')->createPDF($page, wire('languages')->getLanguage($lang_id)); sleep(1); if($page->user_lang_name == 'default'){ // Adding pdf into pageFile ( Carico il file pdf e lo trovo nella pagina del voucher ) $pdfVoucher = wire('config')->paths->files.$page->id.'/'.$page->name.'-'.$page->id.'.pdf'; // Verificare con effettiva creazione file if (file_exists($pdfVoucher)){ // $page->warning($pdfVoucher); // $page->of(false); $page->pdf_voucher->add($pdfVoucher); $page->save('pdf_voucher'); // $page->of(true); } } else { $pdfVoucher = null; } // MULTILANGUAGE if($page->user_lang_name == 'en'){ // Verificare con effettiva creazione file $pdfVoucherEN = wire('config')->paths->files.$page->id.'/'.$page->name.'-'.$page->id.'-en.pdf'; if (file_exists($pdfVoucherEN)){ // $page->warning($pdfVoucherEN); // $page->of(false); $page->pdf_voucher->add($pdfVoucherEN); $page->save('pdf_voucher'); // $page->of(true); } } else { $pdfVoucherEN = null; } if ((file_exists($pdfVoucher)) || (file_exists($pdfVoucherEN))){ echo json_encode([ 'result' => 'ok', 'message' => wire('config')->paths->files.$page->id.'/'.$page->name.'-'.$page->id, 'pageID' => $page->id, 'entryID' => $page->entry_id]); exit(); } else { echo json_encode([ 'result' => 'error', 'message' => __('PDF NOT generated.'), 'pageID' => $page->id, 'entryID' => $page->entry_id]); exit(); } } } else { echo 'Invalid AJAX call.'; exit(); } } Link to comment Share on other sites More sharing options...
Cybermano Posted December 28, 2022 Share Posted December 28, 2022 6 minutes ago, Cybermano said: ... I'm not sure, but I think it could depend by a "<br/>" outputted in the JSON parse (from where?) ... Does anyone have any idea? ... I also thought about a problem with the page name (on multilanguage): in fact I'm stunned with all the "___callUnknown('localName', Array)" errors... Could it be due the array structure of the page name on multilanguage ('data' for default lang, and a kind of 'nameXXXX' for the other languages) ? If so, I never received a similar error before... not in page API, not in hooks, not AJAX... Link to comment Share on other sites More sharing options...
Markus Thomas Posted January 27 Share Posted January 27 Since I had to update more and more projects lately and also the PHP version of some of these projects was set to >=8 in the meantime I created a fork of the module and updated mPDF to version 8.1.3. With only some small changes in the WirePDF module I can now continue to use Pages2PDF without any restrictions. Maybe this is helpful for someone. https://github.com/markusthomas/Pages2Pdf 4 Link to comment Share on other sites More sharing options...
jacmaes Posted February 1 Share Posted February 1 @Markus Thomas You're a lifesaver! Thanks a lot. It works now on PHP 8.2. 1 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