tags:

views:

39

answers:

3

I used the FPDF class to create a multi-page PDF document and then I used an iframe to display the multi-page document.

Here is an example of the result: Picture of iframe with multi-page PDF

I want to do the same thing on another page, except a bit different. Instead of displaying one multi-page PDF document, I would like to let the user upload two separate PDF's and then I display the two PDF's within the same iframe.

How can I make two different PDF files appear in the same iframe

+5  A: 

The PDF plugin will take full control over the iframe, and can not deal with multiple files.

What you could do to work around it:

Two IFRAMEs

One easy solution that comes to mind is having a HTML page in the iframe, that in turn contains two iframes or even frames.

You'd have to find out whether this works for you - the devil will be in the detail here, for example, it will not be possible to synchronize the scroll positions or zoom levels, which is probably what you want.

Merge PDFs

The only real way to do this that I can think of is to generate a PDF that merges the two PDFs next to each other. This is not entirely trivial. Check out the following questions for example:

there are more on SO when searching for "PHP PDF merge".

Pekka
Damn, 17 seconds too slow. +1
ILMV
Will it be possible to unmerge the PDF back into multiple pdf's if I merge them?
zeckdude
@zeckdude I doubt it. But why would you need that? Just store the separate versions elsewhere.
Pekka
@Pukka - Good Point! Thanks for the suggestions!
zeckdude
+1  A: 

I don't think you can, the users PDF reader may (if it's set to do so) display the PDF inline, therefore you can only have one per iframe...

But! What about having two iframes? This way You can display two PDFs easily.

ILMV
A: 

I would go with the merge, as suggested by Pekka. The plugin rendering the PDF is afaik only capable of having one PDF.

ZeissS