Menu

Print 2 a4 pages on a3 pdf

Help
floyd0987
2014-12-11
2014-12-11
  • floyd0987

    floyd0987 - 2014-12-11

    Hello,
    i'd like to ask for some help on an issue that i think is easily solvable, but I still can't sort out how.
    I prepared the scripts for an a4 sized menu booklet. The client also wants a a3 printable version of the same which is not an extended variant of the a4, but it's simply two a4 pages next to each other on an a3 page.
    Is it possible to set a page break horizontally?

    A4 | A4

     
  • Simon

    Simon - 2014-12-11

    You could either use columns to split over the pages, or create an A4 pdf, then import the pages into an A3 pdf using FPDI.

     
  • floyd0987

    floyd0987 - 2014-12-11

    Interesting. Therefore with tcpdf it's not possible to have a "virtual" page break at a given point, right? I'd rather not rewrite everything to fit the a4s inside columns since they'll have to be identical to the original a4 format.
    I thought there would be a parameter i could add to $pdf->AddPage.

     
  • Simon

    Simon - 2014-12-11

    It is very difficult to say without seeing your code, it may not require much to use columns, or restart on the same page but with different margins - but it may be easier to just use FPDI.

     
  • cpw

    cpw - 2014-12-11

    At least in Adobe Reader you can combine multiple pages to print on one sheet: Pages per sheet "Custom" - "2 x 1" and page order "Horizontal" should do the trick. As I have no A3 printer I can't verify this however.

    So if this is just about printing and your client doesn't insist on having the document itself like that, this would be the easiest solution.

     
  • floyd0987

    floyd0987 - 2014-12-11

    ok. im trying to use the concatenation with fpdi.
    Like this im getting A3 pages with a A4 on the left side and the right side is blank.

    A4 | Blank
    A4 | Blank
    A4 | Blank
    A4 | Blank

    how can I have the even numbered pdfs on the right side? This is my code.

    // define some files to concatenate
    $files = array(
    "1_pdfsam_example_048.pdf", "2_pdfsam_example_048.pdf", "3_pdfsam_example_048.pdf", "4_pdfsam_example_048.pdf"
    );

    // initiate FPDI
    $pdf = new FPDI();

    // iterate through the files
    foreach ($files AS $file) {
    // get the page count
    $pageCount = $pdf->setSourceFile($file);
    // iterate through all pages
    for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
    // import a page
    $templateId = $pdf->importPage($pageNo);
    // get the size of the imported page
    $size = $pdf->getTemplateSize($templateId);

       $pdf->AddPage('L', 'A3');
    
        $pdf->useTemplate($templateId);
    
    }
    

    }

    // Output the new PDF
    $pdf->Output();

     

    Last edit: floyd0987 2014-12-11
  • Simon

    Simon - 2014-12-11

    You'll need to specify where to import the page, so something like this:

    foreach ($files AS $file) {
      // get the page count
      $pageCount = $pdf->setSourceFile($file);
      // iterate through all pages
      for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
        // import a page
        $templateId = $pdf->importPage($pageNo);
        if ($pageNo&1) {
          //odd page
          $pdf->AddPage('L', 'A3');
          $pdf->useTemplate($templateId);
        } else {
          //even page
          $pdf->useTemplate($templateId, 210, 0);
        }
    }
    
     
  • floyd0987

    floyd0987 - 2014-12-11

    Thanx Simon, but still with this code I get this:

    A4 | Blank
    A4 | Blank
    A4 | Blank
    A4 | Blank

    it seems it never gets inside the else statement
    else {
    //even page
    $pdf->useTemplate($templateId, 210, 0);

     
  • Simon

    Simon - 2014-12-11

    are your pdfs actually multipage? or are they a series of single page pdfs?

     
  • floyd0987

    floyd0987 - 2014-12-11

    ok. got it the counter should take in the half pages and not the actual a3 page counts.
    This works:

    $halfpage = 1;

    // iterate through the files
    foreach ($files AS $file) {
    // get the page count
    $pageCount = $pdf->setSourceFile($file);
    // iterate through all pages
    for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
    // import a page

    $templateId = $pdf->importPage($pageNo);
    
    if ($halfpage % 2 != 0) {
      //odd page
      $pdf->AddPage('L', 'A3');
      $pdf->useTemplate($templateId);
      $halfpage = $halfpage+1;
    
    } else {
      //even page
      $pdf->useTemplate($templateId, 210, 0);
       $halfpage = $halfpage+1;
    
    }
    

    }

    }

     

Log in to post a comment.