Jump to content



Recommended Posts

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" :)


  • Like 2
Link to comment
Share on other sites

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

  • 4 weeks later...


All Chinese characters in the output pdf file become ???. How to config to use CJK fonts??



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



  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

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?


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


Link to comment
Share on other sites

  • 1 month later...

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,

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

How do you go about adding a page break to your generated PDF?

I've tried adding

	$pdf = $modules->get('WirePDF');

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.


Link to comment
Share on other sites

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. &deg; ?


Link to comment
Share on other sites

  • 4 weeks later...


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;
$stueckliste = new Page();
$stueckliste->parent = wire("pages")->get("/stuecklisten/");
$stueckliste->title = "HGSL-".$order->id;
$stueckliste->orderid = $order->id;

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

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:


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;


  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

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

@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.



Link to comment
Share on other sites

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';

$wohnung = $modules->get('WirePDF');
$wohnung->markupMain = $config->paths->templates . 'expose_wohnung.php';

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

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:

$wohnungsnr = $_SESSION['wohnungsnr'];
    $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'>
                            <td>{$wohnung->options_zimmer->title} Zimmer</td>
                        <th colspan='2'>Ausstattung</th>
                            <td colspan='2'>
        foreach ($wohnung->ausstattung_repeater as $item) {
            $out .= " 
                                    <li>– {$item->headline}</li>
        $out .= "</ul>
            </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


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

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ۗ}q؃E 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?


Link to comment
Share on other sites

  • 1 month later...

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.



Link to comment
Share on other sites


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.


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 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
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

  • Create New...