Как заставить TCPDF генерировать только одну / первую страницу? - PullRequest
0 голосов
/ 24 марта 2019

Я создаю PDF из веб-формы для подачи тезисов. Форма имеет поля, такие как заголовок, текст, ссылки и т. Д. Я хочу, чтобы TCPDF генерировал только одну / первую страницу, чтобы пользователи могли писать короткие рефераты. Сейчас он генерирует столько страниц, сколько нужно для отображения всего контента.

// Include the main TCPDF library (search for installation path).
require_once('{tcpdf_path}');

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('{conf_title}');
$pdf->SetTitle('{title}');
$pdf->SetSubject('{conf_title} Abstracts');
$pdf->SetKeywords('{conf_title}, Abstract');

// set default header data
$pdf->SetHeaderData('','', '', '{conf_title}');
$pdf->setPrintHeader(true);

// set header and footer fonts
$pdf->setHeaderFont(Array('freeserif', '', 8));

// set margins
$pdf->SetMargins(20, 15, 20);


// set line height
$pdf->setCellHeightRatio(0.7);

// set image scale factor
$pdf->setImageScale(1.5);

// }

// ---------------------------------------------------------

// set font
$pdf->SetFont('freeserif', '', 11);

// add a page
$pdf->AddPage();

/* NOTE:
 * *********************************************************
 * You can load external XHTML using :
 *
 * $html = file_get_contents('/path/to/your/file.html');
 *
 * External CSS files will be automatically loaded.
 * Sometimes you need to fix the path of the external CSS.
 * *********************************************************
 */

// define some HTML content with style
$html = <<<EOF
<!-- html goes here - I've removed it for the question -->
EOF;

// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');

// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

//Close and output PDF document
$pdf->Output('pdf_{entry_id}.pdf', 'I');
exit;
//============================================================+
// END OF FILE
//============================================================+
?>
...