Jump to content

Pages2Pdf


Wanze

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.

Probably.

You can also do this and use variables.

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

Hi,

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?

Regards

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

/pages2pdf

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

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

etc..

 

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

Quote

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 😅

Cheers

  • Like 3
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.

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

 

  • Like 3
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.

      <?php            
        $pdf = $modules->get('WirePDF');
             
        ob_clean();
             
        $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;
   
        $pdf->download('pages2pdf/custom.pdf');
  
        echo "<a href='{$config->urls->templates}pages2pdf/custom.pdf' download>Download PDF</a>";    
        ?>

 

  • Like 2
Link to comment
Share on other sites

  • 5 months later...

Hello everyone.

 

I started a while ago with processwire and I like it a lot 🙂

But now I ran into some problems with pages2pdf and I hope someone has a solution for those problems:

 

1. I try to add pictures (mostly pngs) into a pdf but some aren't shown and I can't tell why. 
The picture are shown on the webpage but not in the created PDF: 
image.png.eded932dc88e40578fc491f2e18f6fa7.png

I create them with this command: $picture->size(100)->httpUrl
It works for some pictures but not for all. I think it has something to to with the way processwire creates the smaller picture because it works fine with this command: $picture->httpUrl when I remove the size command.

2. to make it even more complicated, some pictures aren't even visible with this command. Maybe it's a problem with the transparency from png. but other formats and some pictures without transparancy are also affected.
 

I would be happy if someone has a tip or could tell me what I'm doing wrong or if there is a setting to change, thanks.

Link to comment
Share on other sites

Hello @bernhardthanks for your suggestion but filename works only for the picture where httpUrl is also working.

 

I don't think it's a problem with the links but with the way the original picture are created. mostly pictures with a white or black background instead of as transparent one are working fine. 🤔

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
×
×
  • Create New...