Menu

Mirror pdf

Help
Exe
2014-09-10
2014-09-11
  • Exe

    Exe - 2014-09-10

    Hi,

    is there a way to mirror the result of a tcpdf pdf or a given pdf-file?

    I'm creating a pdf for printing with tcpdf. It's for printing on products. It's required to mirror the printout. I don't really want to change the full creation proccess to mirror (MirrorH) every single object. That would make it much more complicated.

    Or is it possible to save the result in a php var to reopen it and mirror the pdf-result?

    Best

     
  • Simon

    Simon - 2014-09-10

    MirrorH should be fine and if you combine with translate should not require any further maths.

    Something like:

    <?php
    $pdf->StartTransform();
    $pdf->MirrorH(0);
    $pdf->TranslateX($pdf->GetPageWidth());
    // Your page here
    $pdf->StopTransform();
    ?>
    
     
  • Exe

    Exe - 2014-09-11

    Ah ok.

    With "Your page here" you mean I need the pdf to mirror in another pdf-object?
    Guess I have to mirror each page.

    I'm not sure how to use my pdf there. I need to create a 2nd pdf object for the transformation?

     
  • Simon

    Simon - 2014-09-11

    In fact having now tried it, it is easier to do this:

    <?php
    
    $pdf->AddPage();
    $pdf->StartTransform();
    $pdf->MirrorH($pdf->getPageWidth()/2); 
    // Your page here
    $pdf->AddPage();
    $pdf->StartTransform();
    $pdf->MirrorH($pdf->getPageWidth()/2);
    // Your page here
    
    ?>
    

    You are right that this seems to need doing at each new page, so perhaps you could extend the class to do this for you on each new page.

    When I say Your page here - I mean do all the normal things you do to create your page - so $pdf->write() etc.

     

    Last edit: Simon 2014-09-11
  • Exe

    Exe - 2014-09-11

    Thank you. Its working really well.

     

Log in to post a comment.