Jump to content



Recommended Posts

  • 2 months later...
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.


You can also do this and use variables.

$print_date = date("jMY"time());
    $pdf->download('Logbook - ' . $drone->title . ' - ' . $print_date . '.pdf');
Link to comment
Share on other sites


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?


Link to comment
Share on other sites

  • 7 months later...
  • 2 months later...

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


_footer.php, _header.php, _default.php, styles.css

_footer2.php, _header2.php, _default2.php, styles2.css



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

Hi @Flashmaster82


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 😅


  • Like 2
Link to comment
Share on other sites

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.

        $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;
        echo "<a href='{$config->urls->templates}pages2pdf/custom.pdf' download>Download PDF</a>";    


  • Like 2
Link to comment
Share on other sites

Also if you want to preview the PDF when working on the styling. I added ob_clean(); because otherwise it only works in Firefox.

        $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;
        echo "<a href='{$config->urls->templates}pages2pdf/custom.pdf' download>Download PDF</a>";    


  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By Marco Ro
      Hi guys!
      I'm a bit anxious because this is the first module I present! (beta modulo) But I will finally be able to share something with the community too! :)
      This is a BETA version of the PayPal payment system called: PayPal Commerce Platform.
      It is an advanced system (Business Pro account is needed) that brings various benefits in terms of fees and above all integrates direct payment with credit/debit cards. 
      The module integrates with Padloper 0.0.2, which is the current installation I'm using.
      This system integrates the classic PayPal buy button, the alternative or local payment method and the new payment system: credit/debit cards that doesn't go through the PayPal account. It is a Stripe-style payment, it connects directly with the bank and integrates 3D security validation.
      I say that it is a BETA because this module currently only works with Sandbox account, to put it live you need to change API url manually (manually for the moment).
      Because this module is not ready for live:
      I would like to have your opinion on how I built the module (is the first one I do). I don't want to share something that is not fish but I need a comparison with someone more experienced than me, for be sure that this is the best way to code the module.
      If you want to try this I created a git, you will find all the instructions for installation and correct operation. (Git has a MIT licensed)
      https://github.com/MarcooRo/processwire-PayPal-Commerce-Platform I hope I did something that you guys can like :)
    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.

      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
  • Create New...