Page 1 of 1

urgent question about pdf/fdf

Posted: Mon Dec 08, 2008 6:24 pm
by yacahuma
Hello,

I recently posted a question about dynamically filling a pdf form. It turns out to be easy using fdf. Use adobe, create fields in the form and use a little function to do a search and replace. I started my coding and everything looked perfect until I realized that I have to repeat some pages from the original document depending on the data.
So , for example the original document has page 1,2,3. But depending on the data I want to repeat page 3 2 times. So at the end I will have page 1,2,3,3.

Now I have no idea how to do this , and found no clues on the Internet so far.

Anyone here work with fdf/ pdf before that may have the answer to my urgent problem.

The problem is that fdf are not pdf, they are just an external key-value flat file that need the original pdf in order to merge on the fly. Since the original will have a pre-defined set of pages.

Re: urgent question about pdf/fdf

Posted: Tue Dec 09, 2008 1:23 am
by maneetpuri
Hi,

There is no direct way of doing this but what you can do is implement this logic: -
Keep storing the pages gathered form the original PDF in separate variables and depending upon the data entered you will have to pick the respective variable use its content to add that page at the end of the PDF you are creating. Say for example you have a PDF with three pages and you run a loop and render all the pages in three different variable $pg1, $pg2 and $pg3. Now on page 1 there was value which states that page three has to be repeated twice then after first time adding page three you can do a check and again add the third page.

$i = 1;
${“pg” . $i} = “Content of the page”;

The above code will be needed as this allows you to create variables on the fly.

Hope this helps,

Cheers,
Maneet Puri