How can I make two different PDF files appear in t

2019-07-23 11:56发布

问题:

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:

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

回答1:

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:

  • PHP - How to combine / merge multiple pdf’s

  • Need to merge multiple pdf’s into a single PDF with Table Of Contents sections

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



回答2:

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.



回答3:

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