Open FPDF in new tab

眉间皱痕 提交于 2019-12-04 09:12:14

If you use a form you can do it by specifying target='_blank' in the -tag (next to where you should have submit='something')

Example:

This will open a new Tab (showing whatever "makepdf.php" produces) on submit.

Hope it answers the question correctly

Try $pdf->Output("OfficeForm.pdf", "I");

I simply added target="_blank" to my form opening tag and used $_SESSION[]; to pass my form to the FPDF code:

<?php session_start(); ?>

<form id ="buildPDFform" name="buildPDFform"  target="_blank" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

...some code for my form

<input type="submit" name="buildPDf" id="buildPDf" class="buildPDFbutton" value="Build the PDF">
</form>

Then when the form is submitted I gather my form items, put them in an array, create a session the array goes into and use a header("Location: testcode.php") to redirect to where my FPDF code is.

if (isset($_POST['buildPDf'])) {
    $pdfArray = array();
    foreach ($_POST as $key => $value) {

        ...gather your form items into your array

    }
    $_SESSION['pdfArray'] = $pdfArray;
    header("Location: testcode.php");
}

And don't forget in your FPDF code file (testcode.php in my case) to grab your session that has the array.

<?php
    session_start();
    $pdfArray = $_SESSION['pdfArray'];

     ... your FPDF code

    $pdf->Output('I');
?>

source: https://www.thesitewizard.com/html-tutorial/open-links-in-new-window-or-tab.shtml

use target="_blank" in your a tag to open it to new tab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!