FrDeamon / EnseparHtml2pdfBundle

Html2pdf for Symfony 2 as a service.
MIT License
22 stars 22 forks source link

Merge PDF files and positioning Variable #21

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello,

how i can create a pdf with variable who i positioning vars, and after that i merge with other pdf ?

OwlyCode commented 8 years ago

I'm not sure to understand what you mean by positioning vars. Are you talking about writting something into a PDF and then appending another PDF ?

ghost commented 8 years ago

i m using fpd fpdi library :

well to merge pdf i use this code :

 /**
     * @Route("/generatePDF3")
     */
    public function generatePDF3Action(Request $request){

        $arrayInformation = array("civilite" => $_POST["civilite"],
                "nom" => $_POST["nomr"]
        );
        $pdf  = new \FPDF_FPDF();
        $pdi  = new \FPDF_FPDI();

        //$pdi->AddPage();

        $cvPath = '/var/www/html_prod/my_projectDemo/web/docs/demoFond01.pdf';

//on affiche le fond de page 1        
        $pdi -> setSourceFile($cvPath);
        $pdi->addpage();
        // import page 1
        $tplIdx = $pdi -> importPage(1);
        // use the imported page and place it at point 10,10 with a width of 100 mm
        $pdi -> useTemplate($tplIdx, 0, 0, 0);
//on affiche le texte de la page 1
        $pdi->SetFont('Arial','B',12);
        $pdi->Cell(100,100,$arrayInformation["civilite"]);

        //on affiche le fond de page 2
        $pdi -> setSourceFile($cvPath);
        $pdi->addpage();
        // import page 2
        $tplIdx = $pdi -> importPage(2);
        // use the imported page and place it at point 10,10 with a width of 100 mm
        $pdi -> useTemplate($tplIdx, 0, 0, 0);
        //on affiche le texte de la page 1
        $pdi->SetFont('Arial','B',8);
        $pdi->Cell(100,100,'Hello World');  

        return new Response($pdi->Output(), 200, array('Content-Type' => 'application/pdf'));

    }

so like use i open an existing pdf and i add some text on it. the text i can positioning it with the $pdi->Cell(100,100,'Hello World');

thanks

OwlyCode commented 8 years ago

I think this issue is not related to this bundle as you don't use it in the code you posted. You should try to open an issue on https://github.com/Setasign/FPDI