4

I import a PDF file with 2 pages using fpdi, it works.

I need to insert an image in my imported pdf but its in under the original pdf layout so I cant see the image that i want to insert. By the way, I can add text and it works properly.

I do the same thing in the second page of my pdf and it works, i can see the image (jpg and png). In my 2nd page of my original pdf I dont have any layout/image coming from the original imported pdf.

I need a z-index property like in css/html

SOURCE: http://pastebin.com/45BEY7fw

Otto
  • 4,020
  • 6
  • 35
  • 46

2 Answers2

3

Try this: http://forums.devshed.com/php-development-5/fpdf-background-image-510220.html

Since you are importing data from a PDF file I don't know how it handles it. Are you getting elements as text or image? I guess that you are trying to get an image-converted PDF (you're reading an image, like a snapshot of the page, and not text items) over an image on the background. I guess that this won't work if the original PDF conversion was made with JPG.

Let me know if that's happening.

Mário Rodrigues
  • 833
  • 7
  • 21
  • My imported pdf have a background image in the page 1, not in page 2. So i can see my inserted image in the second page and not in the first page. Source added – Otto Nov 08 '11 at 12:44
  • Yep, like I said. I guess you are trying to put a watermark under that page, right? You create your PDF document. Add the background image and then when you open your PDF, the 1st page's background is loaded over the first image. The background image of the PDF file you are importing had been converted to JPEG, for instance, wich covers the first one you had on the new document. Can you place the background image of the 1st page before the one you're trying to add on the new document? This would place the 'test.png' over the initial background. Can you test it and give me a notice? – Mário Rodrigues Nov 08 '11 at 12:50
  • Also found this: http://staff.dasdeck.de/valentin/fpdf/fpdf_alpha/ which seems to add FPDF lib the ability to handle the image's alpha channels. – Mário Rodrigues Nov 08 '11 at 12:55
  • I want to add an image over all my imported pdf.I dont create a pdf, I import it. I think the original pdf was made in Corel Draw – Otto Nov 08 '11 at 13:19
  • Did you ever get round this? I'm in the same scenario, imported images are behind my content. – Ben May 07 '14 at 09:47
1

If you print on the page before importing template page - it works . here is my code :

  $pdf - > AddPage();

  //draw watermark
  $pdf - > SetTextColor(215, 215, 215);
  $pdf - > SetFont('Times', '', 90);
  $pdf - > RotatedText(24.5, 234.5, $school_data['watermark'], 45);
  $pdf - > SetTextColor(0, 0, 0);

  //load template
  pdf - > setSourceFile('reports/template.pdf');
  $tplIdx = $pdf - > importPage(1);
  $pdf - > SetAutoPagebreak(false, 0);

  //use the imported page and place it at point 0,0; calculate width and height
  //automaticallay and ajust the page size to the size of the imported page
  $pdf - > useTemplate($tplIdx, 0, 0, 0, 0, false);
Sergey
  • 749
  • 6
  • 13