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 2

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 2

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

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 Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...