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 2
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 2
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 1
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...