Jump to content
Wanze

Pages2Pdf

Recommended Posts

1 hour ago, iNoize said:

EDIT: Have stiill problems. If I edit something in the default_templates the Module dont use the new changes
Something with cache or how can i  change this ?

Yes, in Pages2Pdf module settings :

Capture.PNG.5ef932891f09afbfe490b222b64d9075.PNG

 

You can stay with PHP 7.3.x, and you can also try the same method to update it with the last mPDF version. If it didn't work, then use an older mPDF version like I did. 

Share this post


Link to post
Share on other sites
43 minutes ago, flydev said:

Yes, in Pages2Pdf module settings :

Capture.PNG.5ef932891f09afbfe490b222b64d9075.PNG

 

You can stay with PHP 7.3.x, and you can also try the same method to update it with the last mPDF version. If it didn't work, then use an older mPDF version like I did. 

Don't really work for me with the 1 in the cache. I'll try to update mpdf and set php to 7.3 maybe then. 

EDIT: Ok the latest mpdf have other filestrukture i think i cant replace the folder so easy also i will stay at 6.1 but i cant see my custom template files. Where could the problem be ? 

Share this post


Link to post
Share on other sites

Hi @All, @Wanze thanks for the module!

Please mates, is there a way to add pdf button/link to backend template? I need to print particular template from backend.

 

Share this post


Link to post
Share on other sites

That's a really great module! Thanks a lot!

On localhost it works perfect. But on the server I have the problem, that it don't creat the pdf file correctly. The file has only 0 Bytes and there is an error if I open it. Somethink like "the file is damaged". Does somebody has an idea where to problem is? On Chrome DevTools is this error:

Resource interpreted as Document but transferred with MIME type application/pdf:

Thanks for your help.

 

<a href="<?php echo $page->url;?>?pages2pdf=1">PDF erstellen</a>

 

Share this post


Link to post
Share on other sites

SOLVED: On the server "readfile()" was disallowed

One problem was, that I used PHP 7.2 on the server. Now i changed to PHP 5.6.

But if I click on the Link (<a href="<?php echo $page->url;?>?pages2pdf=1">PDF erstellen</a>), the file is saved on the server in /site/assets/files/page-id. But no visiual download ond the webpage. It opens just a empty page with the following url: .../page_name?pages2pdf=1. On localhost it works. Does somebody has an idea where my fault is? Thank you.

Share this post


Link to post
Share on other sites

Hello I get this Error if I try to Execute ImportPagesFrom XML 

 

Fatal Error: Uncaught TypeError: Argument 2 passed to Pages2Pdf::getPDFFilePath() must be an instance of Language, instance of ProcessWire\Language given, called in /usr/www/users/ulmmsc/2018cms/site/modules/Pages2Pdf/Pages2Pdf.module on line 177 and defined in /usr/www/users/ulmmsc/2018cms/site/modules/Pages2Pdf/Pages2Pdf.module:259

Language Support is installed. 
 

Also is Multilanguage Checked in the pages2PDF Module 

Share this post


Link to post
Share on other sites

Guys I'm really desperate. The templates can not be changed, I have no idea why. Not the headers or not the default it always stays the same.

It also does not work with Multilanguage. Is nobody there who can help me?

Share this post


Link to post
Share on other sites

The better the questions the better the answers. 

1 hour ago, iNoize said:

The templates can not be changed, I have no idea why.

You cannot expect that forum members can remember the exact problem that you have posted several weeks ago. Describe your problem. Try to make it reproducable (eg by providing a site profile of a clean installation that shows the problem) and I'm sure there will be someone who can help you.

Sometimes even describing the problem as good as you can brings you to the solution 😉 

  • Like 1

Share this post


Link to post
Share on other sites

Just to get the records straight...

  • ProcessWire version?
  • Multilanguage profile or another profile made multilanguage?
  • How many languages?
  • Does it work in any of the languages?
  • PHP version?
  • Module version?
  • How do you generate the PDFs? Code snippet would be great
  • Where do you create the PDFs - frontend or backend?
  • Templates: page or PDF?
  • Template location?
  • Template strategy - delayed, direct, regions?
  • Like 3

Share this post


Link to post
Share on other sites

@bernhard @wbmnfktr

Thanks for the fast answer. So i try to describe the situation. 
I have installed the module.  CURRENTLY SITCHED OFF THE MULTINLANGUAGE SUPPORT ON PW 

ProcessWire 3.0.126 © 2019
PHP 7.2  
Screenshot_3.thumb.jpg.e85f681a55fad9dab9bdab76d0a1b872.jpg

 

So now if i try to change the templates in /site/modules/Pages2Pdf/default_templates
for example 

default.php 
<h1><?= $page->get('headline|title') ?></h1>
<p><?= $page->body ?></p>

<?php if (count($page->immo_images)): ?>
    <?php foreach ($page->immo_images as $image): ?>
        <div class="image">
        <img src="<?= $image->size(400, 400)->url ?>" alt="<?= $image->description ?>" />
        </div>
    <?php endforeach; ?>
<?php endif; ?>


_header.php 
<?php
/*
 * Pages2Pdf default header markup
 * Styles defined in styles.css file
 *
 * You can use {PAGENO} for the current page number and {nbpg} for the total of pages
 *
 */
?>

<div class="head">Test </div>
Hier kommt EXPOSE 
<hr>
Hallo WELT 

Then try to generate the file on the site 

 

$options = array(
  'title' => 'Expose als PDF',
  'markup' => '<a href="{url}" target="_blank" class="btn button-sm border-button-theme col-lg-12 col-md-12 col-xs-12 margin-b-10"  >{title}</a>',
  //'page_id' => '', // Pass a page ID if you want to download the PDF for another page
);
echo $modules->get('Pages2Pdf')->render($options);

nothing happens. 
It generates always the same PDF see as attached. 
There is the standart header and footer. 
Also on the content is the standart code. 

THE CACHE IS ON 1 

 

 

 

neubau-einfamilienhaus-in-burgrieden-pdf-1148 (1).pdf

Share this post


Link to post
Share on other sites

I tried this:

  • fresh 3.0.123 installation
  • multilanguage profile
  • PHP 7.2
  • latest Pages2PDF module

2019-10-02-165040_1683x1417_scrot.thumb.png.db7377434462b967970a511a2f63da7c.png

At first I saw no changes at all because I changed the wrong templates in /site/modules/Pages2PDF/default_templates/ and not those in /site/templates/pages2pdf/.

Right now... all I can say is: it's working as expected. Sure... there is no custom code in my page templates or anythings. Just the basic stuff.

My recommendation: try it with a simple basic template without anything else in it. Maybe even blindtext. Maybe the reason for your errors are at a different place than the module itself.

Update: just saw in your post that you ARE in the wrong folder with the wrong templates.

  • Like 3

Share this post


Link to post
Share on other sites

@wbmnfktr 
ok thats really embrrassing now. 

With the Templates I was in the wrong path. The module  path not the template. 

With the multilanguage i installed not the profile only the module (part of PW Multilanguage Support )
But thanks a lot for the HELP. Now it works with the PDF files without multilanguage. 


 

Share this post


Link to post
Share on other sites

You will remember it the next time. 😉 

I checked the multilanguage support... that worked as well.

2019-10-02-173828_1993x507_scrot.thumb.png.69d3bfb8d630fef9a97aec62eb1dfba1.png

As said before... try taking it apart with just a few simple templates to find the real problem.

  • Like 2

Share this post


Link to post
Share on other sites

@wbmnfktr OK I think the error is not in the pages2pdf I use to import files the ImportPages2Xml module and when the multilanguage is on then the error comes that pages2pdf

Fatal Error: Uncaught TypeError: Argument 2 passed to Pages2Pdf::getPDFFilePath() must be an instance of Language, instance of ProcessWire\Language given, called in /usr/www/users/ulmmsc/2018cms/site/modules/Pages2Pdf/Pages2Pdf.module on line 177 and defined in /usr/www/users/ulmmsc/2018cms/site/modules/Pages2Pdf/Pages2Pdf.module:259

Share this post


Link to post
Share on other sites
On 9/15/2017 at 10:14 AM, maxf5 said:

Hi bernhard,

thank you for the hint.  The image field is set as single element.
 


  <td colspan="1" style="padding:15px">
    <img src="<?= $page->navimg->url; ?>" width="220"/>
    <p><?= $page->navimg->url ?></p>
  </td>

something between ..

<?php if ($page->images->count > 0) : ?>
<table>
  <tr>
  <?php
    $gallery = $page->images;
    $gallery = $gallery->slice(0,4);
   foreach ($gallery as $image): ?>
    <td>
      <img src="<?= $image->size(200, 200)->url ?>" width="200" height="200"/>
    </td>
  <?php endforeach; ?>
  </tr>
</table>
<?php endif; ?>

 

template part:


<?php 
$optionspdf = array(
  'title' => 'Datenblatt',
  'markup' => '<a class="uk-button gaming" href="{url}" download>{title}</a>',
  'pageFormat' => 'A4'
);
echo $modules->get('Pages2Pdf')->render($optionspdf);
?>

 

result:

Unbenannt.thumb.PNG.434147903301c5d7a1ddea668fee6fee.PNG

 

Hello, have somebody solved it now ? 
The Problem i found out is with the png . 

Tried it with jpg it works. 
How to handle it with PNG Files ? 

Updated the mpdf to 6.1 

 

Share this post


Link to post
Share on other sites

I don't know what it was in my case but one of these things fixed it or at least I got the .png files in my PDFs:

  • using relative path to the file
  • installing GD and PHP GD extension (or was it ImageMagick?)

And somehow I was able to get more details about the problems aka got a real error message but it's way too long ago as I can remember this in full detail. 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...