Jump to content
Wanze

Pages2Pdf

Recommended Posts

The config path variables do update with moving the installation.

Yes. But does the WirePDF input field accept a config path variable?

  • Like 1

Share this post


Link to post
Share on other sites

@Spica

Nope not yet, I will consider this for the next version. Makes sense!

  • Like 1

Share this post


Link to post
Share on other sites

Hi, I'm using multi language support and everything is working well (great module btw) except for the text coming from a TextAreaLanguage field where I get missing characters, like in Portuguese, that are replaced by '?'. Anyone having this problem or know what can be wrong? Thanks.

Share this post


Link to post
Share on other sites

Are those question marks at the frontend? Then you are probably defining wrong character encoding in you template files or you have saved your template files with wrong encoding.

Share this post


Link to post
Share on other sites

Yes, those are on the front-end, but all the other content is ok except for the text coming from the TextAreaLanguage :/.

Are those question marks at the frontend? Then you are probably defining wrong character encoding in you template files or you have saved your template files with wrong encoding.

Share this post


Link to post
Share on other sites

Hi zyON,

I think the problem is that the used fonts don't contain your portuguese characters. Can you try to change your WirePDF settings:

  • Mode: "s" instead of "c"
  • Font: "DejaVuSans"

See this post for more information: https://processwire.com/talk/topic/3008-pages2pdf/page-6#entry96263

If this does not work, you'd probably need to add a font that supports your character set by yourself to mPDF.

  • Like 2

Share this post


Link to post
Share on other sites

Wanze: Thanks. You were right, I had to change it to DejaVuSans (but I also had to to copy the DejaVuSansCondensed family to the module ttfonts folder because it was looking for them somehow and throwing an error.

I was using Helvetica and it should contain Portuguese characters... I'm using it on the site text too. 

Share this post


Link to post
Share on other sites

Hello Wanze,

I'm trying to use your module to send PDF invoices to customers of my store and I was wondering if it was possible to pass an object to the template similar to $template->set() works ...? 

Thanks,

thomas

Share this post


Link to post
Share on other sites

You can use the WirePDF module with any kind of markup you need. I'm using wireRenderFile() to render the html with custom data and then pass it into WirePDF.

  • Like 2

Share this post


Link to post
Share on other sites

Hi

after upgrading from 2.7.x to 3.0.5 I get this error when trying to download a pdf.
Superuser/Admin:
Parse Error: syntax error, unexpected ',' (line 8910 of /www/htdocs/.../site/modules/Pages2Pdf/mpdf/mpdf.php)

User:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Pages2Pdf 1.1.6

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

Hi Metaphora,

Well that's strange, I guess this has to do with ProcessWire's FileCompiler in 3.x. I'll take a look at it in the next days.

Cheers

Share this post


Link to post
Share on other sites

Also strange error on saving article in PW 3 (in this case PW 3.0.8):

Parse Error: syntax error, unexpected '.' (line 39 of /home/.sites/......./site/modules/Pages2Pdf/mpdf/mpdf.php) 

Best regards Jürgen

Share this post


Link to post
Share on other sites

I'm also getting a parse error on 3.08:

Parse Error: syntax error, unexpected 'var' (T_VAR) (line 39 of /var/www/example.com/site/modules/Pages2Pdf/mpdf/mpdf.php) 

Share this post


Link to post
Share on other sites

Hi guys,

Thanks for reporting those errors. I'll find some time to make this module 3.x compatible in the next few days, I guess disabling the new FileCompiler for the external mpdf library should do the trick.

  • Like 1

Share this post


Link to post
Share on other sites

Hi folks,

I quickly tested locally with ProcessWire 3.x and it worked by disabling the file compiler for the external mpdf library. I need to test a bit more, especially the multi language support of the module, before I commit a new version. But if you want to make it work in the meantime, here you go:

  1. Add // FileCompiler=0 to the first line after the php opening tag in the file /site/modules/Pages2Pdf/mpdf/mpdf.php
  2. Delete the folder /site/assets/cache/FileCompiler/site/modules/Pages2Pdf to make sure the module files are recompiled

Now generating and downloading PDFs should work :)

Cheers

  • Like 6

Share this post


Link to post
Share on other sites

Is it possible to have the PDF presented as an inline file rather than a download?

Whether a PDF file is downloaded or not depends on server configuration or browser settings and maybe on transferring the document files through PHP should it be the case.

eg.: https://www.devside.net/wamp-server/forcing-a-pdf-or-doc-to-open-in-browser-rather-than-downloading

Personally my Safari is set to force the download of any PHP file by turning off the viewer plugins. So you might need to check the client's setup as well.

  • Like 1

Share this post


Link to post
Share on other sites

@Asmordean

You might want to have a look at https://github.com/mozilla/pdf.js Widely used code for embedding PDFs in a standards-friendly way.

As szabesz said, you still need to check for the client's browser setup and act accordingly if you want to make sure that the PDF is embedded in your HTML. Here's some code to point you in the right direction: https://gist.github.com/falexandrou/9753871

Instead of using an Iframe you could embed it as an object (see the first link above).

  • Like 4

Share this post


Link to post
Share on other sites

I am not sure the best approach for this, but suggestions are appreciated. I have created a members portal that allow each member to select some "nodes" (pages) and stores them in a page field type that I have assigned to the user template which is an admin template. They can then download the pdf containing the pages that they have selected.

The issue is that I need to store the pdf's under each users page instead of the selected page. Is this possible? I would also really like to be able to use $user->name in the naming convention as well. I guess this would be possible using the hook you described here.

I think just appending the user's id to the file name would do the trick for now.

Awesome module by the way. Thanks for sharing it.

Share this post


Link to post
Share on other sites

Hi RyanJ,

I think the problem is that the module does not allow you to select the user template in the settings, am I right?

Probably the simplest way would be to generate and store the PDFs by yourself with the module WirePDF. It's a wrapper around the mPDF library and included in the Pages2Pdf module. Check the examples here how to use the module, and please ask if you need further help in this.

Cheers

Share this post


Link to post
Share on other sites

Hi Wanze, 

Thanks for pointing out the examples. I was hoping I could just append an id, but I have went the route you suggested. The problem I am having is actually getting the document to display. (I am getting a Failed to load PDF document message). I have a get variable set as ?pdf=1 and the pdf is being written to the folder using.

$pdf->save($page->filesManager->path . $file_name);
$pdf->download($file_name);

When I download the pdf, it is perfect, but viewing it in the browser is the issue.

Thanks for your assistance.

Updates:: forcing a download also has the same issue

$pdf->download($file_name, 'D');

Update::

This issue was where I was calling the module. It should go before the header file is included. This may or may not be the right solution, but it did to the trick for me. Although, there is some issues now with images not showing up.

Edited by RyanJ

Share this post


Link to post
Share on other sites

Hi Ryan,

Strange, I've never seen this message before. Do you need to save the file or could you generate it dynamically when a download is requested? I'm thinking that maybe the combination of calling $pdf->save() first and then $pdf->download() afterwards has some issues. You could try these two approaches:

1) Save the PDF to the disk and let ProcessWire download it:

$pdf->save($page->filesManager->path . $file_name);
wireSendFile($page->filesManager->path . $file_name, array('forceDownload' => true));

You can also omit the forceDownload and see if it works.

2) Don't save the PDF to disk, always create it dynamically and download it:

$pdf->download($file_name);

Does any this work? :)

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

Hi Wanze, 

That did the trick. I commented out the saving of the file and all appears to be working now (Virtual Hug). 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.

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 orphaned references to images that get deleted are automatically removed. When you delete an image from one of the pages that hold your site-wide images, all pages that use this fieldtype will be searched. If any page contains a reference to the image you just deleted, that reference will be reset. You will get warning messages to edit those pages and add new image references there. 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 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...