本文整理汇总了PHP中FPDI::Output方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::Output方法的具体用法?PHP FPDI::Output怎么用?PHP FPDI::Output使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::Output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_philosophy_certificate
function generate_philosophy_certificate($confirmation, $form, $entry, $ajax)
{
// print_r( $entry ); die;
if ($entry['gquiz_is_pass']) {
$upload_dir = wp_upload_dir();
// initiate FPDI
$pdf = new FPDI();
// set the sourcefile
$pdf->setSourceFile(get_template_directory() . '/library/certificate.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// get the width and height of the template
$specs = $pdf->getTemplateSize($tplIdx);
// add a page
$pdf->AddPage("L", array($specs['w'], $specs['h']));
// use the imported page as the template
$pdf->useTemplate($tplIdx, 0, 0);
// now write some text above the imported page
$pdf->SetY(101);
$pdf->SetFont("dejavuserifbi", 'I', 35);
$pdf->SetTextColor(0, 54, 99);
$text = $entry['2.3'] . " " . $entry['2.6'];
$pdf->MultiCell(260, 40, $text, 0, 'C');
// now write some text above the imported page
$pdf->SetY(165);
$pdf->SetFont("dejavuserifbi", 'I', 22);
$pdf->SetTextColor(0, 54, 99);
$text = date('F j, Y');
$pdf->MultiCell(260, 22, $text, 0, 'C');
// save the pdf out to file
$pdf->Output($upload_dir['basedir'] . '/certificates/' . $entry['id'] . '.pdf', 'F');
}
return array('redirect' => '/philosophy-results/?id=' . $entry['id']);
}
示例2: runProcessStep
public function runProcessStep($dokument)
{
$file = $dokument->getLatestRevision()->getFile();
$extension = array_pop(explode(".", $file->getExportFilename()));
#$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename());
// Print Metainfo for PDFs
if (strtolower($extension) == "pdf") {
try {
$fpdf = new FPDI();
$pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename());
$fpdf->SetMargins(0, 0, 0);
$fpdf->SetFont('Courier', '', 8);
$fpdf->SetTextColor(0, 0, 0);
$documentSize = null;
for ($i = 0; $i < $pagecount; $i++) {
$string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")";
$fpdf->AddPage();
$tpl = $fpdf->importPage($i + 1);
$size = $fpdf->getTemplateSize($tpl);
// First Page defines documentSize
if ($documentSize === null) {
$documentSize = $size;
}
// Center Template on Document
$fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true);
$fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string);
}
$this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S"));
} catch (Exception $e) {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
} else {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
}
示例3: generate_mitgliedsbescheinigung
function generate_mitgliedsbescheinigung($titleAndName, $strasse, $plz, $ort, $land, $jahr, $vorstand, $datum)
{
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile(HOME_DIRECTORY . 'alumpiHP_libraries/Mitgliedsbestaetigung_blank.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at position 0,0 with a width of 210 mm (full page)
$pdf->useTemplate($tplIdx, 0, 0, 210);
// add the font DejaVu
$pdf->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);
$pdf->AddFont('DejaVuSans-Bold', '', 'DejaVuSans-Bold.ttf', true);
// text settings
$pdf->SetTextColor(0, 0, 0);
// add address of the member
$addressString = $titleAndName . "\n";
$addressString .= $strasse . "\n";
$addressString .= $plz . " " . $ort . "\n";
$addressString .= $land;
$pdf->SetFont('DejaVuSans');
$pdf->SetFontSize(12);
$pdf->SetXY(20, 23);
$pdf->Multicell(80, 6, $addressString);
//add heading
$headingString = "Mitgliedsbescheinigung " . $jahr;
$pdf->SetFont('DejaVuSans-Bold');
$pdf->SetFontSize(16);
$pdf->SetXY(20, 80);
$pdf->Multicell(170, 6, $headingString);
// add main text
$textString = "Hiermit wird bestätigt, dass " . $titleAndName . " im Kalenderjahr " . $jahr;
$textString .= " ordentliches Mitglied des Absolventen- und Förderverein MPI Uni Bayreuth e.V. (aluMPI) ist.\n";
$textString .= "\n";
$pdf->SetFont('DejaVuSans');
$pdf->SetFontSize(12);
$pdf->SetXY(20, 100);
$pdf->Multicell(170, 6, $textString);
// add signature text
$signatureString = "Absolventen- und Förderverein MPI Uni Bayreuth e.V.\n";
$signatureString .= "1. Vorstand: " . $vorstand . "\n";
$pdf->SetXY(20, 140);
$pdf->Multicell(170, 6, $signatureString);
// add signature
$pdf->Image(HOME_DIRECTORY . 'alumpiHP_libraries/unterschrift_krinninger.png', 20, 155, 50);
// add place and date
$dateString = "Bayreuth, " . $datum;
$pdf->SetXY(20, 180);
$pdf->Multicell(170, 6, $dateString);
ob_clean();
$pdf->Output();
}
示例4: createPDF
public function createPDF(FPDI $fpdi, $filename)
{
$fpdi->setSourceFile(__DIR__ . '/A.pdf');
$template = $fpdi->importPage(1);
$size = $fpdi->getTemplateSize($template);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
$template = $fpdi->importPage(1);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
file_put_contents($filename, $fpdi->Output('', 'S'));
}
示例5: testMerge
public function testMerge()
{
$fpdi = new FPDI();
$fpdi->setSourceFile(__DIR__ . '/A.pdf');
$template = $fpdi->importPage(1);
$size = $fpdi->getTemplateSize($template);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
$template = $fpdi->importPage(1);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template);
file_put_contents(__DIR__ . '/AA.pdf', $fpdi->Output('', 'S'));
}
示例6: split_pdf
function split_pdf($filename, $end_directory = false, $num = 1)
{
require_once 'fpdf/fpdf.php';
require_once 'fpdi/fpdi.php';
$end_directory = $end_directory ? $end_directory . date("d-m-Y__H-i-s") . "/" : './';
$new_path = preg_replace('/[\\/]+/', '/', $end_directory . '/' . substr($filename, 0, strrpos($filename, '/')));
if (!is_dir($new_path)) {
// Will make directories under end directory that don't exist
// Provided that end directory exists and has the right permissions
mkdir($new_path, 0777, true);
}
$pdf = new FPDI();
$pagecount = $pdf->setSourceFile($filename);
// How many pages?
$j = 0;
// Split each page into a new PDF
$new_pdf = new FPDI();
for ($i = 1; $i <= $pagecount; $i++) {
$new_pdf->AddPage();
$new_pdf->setSourceFile($filename);
$new_pdf->useTemplate($new_pdf->importPage($i));
if ($i != 1 && $i % $num == 0 || $num == 1) {
try {
$new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . $i . ".pdf";
$new_pdf->Output($new_filename, "F");
$url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
unset($new_pdf);
$new_pdf = new FPDI();
$j = 0;
}
$j++;
}
if ($j != 0) {
try {
$new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . ($i - 1) . ".pdf";
$new_pdf->Output($new_filename, "F");
$url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
}
示例7: renderPDF
function renderPDF($id,$mode)
{
$pdf = new FPDI();
$db_catalogue_pages = new catalogue_pages;
$db_catalogue_pages->get_one_catalogue_pages($id);
$db_catalogue_pages->load();
$template_id = $db_catalogue_pages->get_pag_template();
$template = new catalogue_templates;
$template->getOne($template_id);
$template->load();
$pdf->addPage("Landscape","Letter");
$db_catalogue_objects = new catalogue_objects;
$db_catalogue_objects->get_all($id);
$pdf->SetFont('Arial','',14);
$pdf->Image("pdftemplates/".$template->get_tem_file().".jpg",0,0);
while($db_catalogue_objects->load())
{
$var = explode("_",$db_catalogue_objects->get_obj_var());
if($var[0] == "image")
{
if(file_exists($db_catalogue_objects->field->obj_image)) $pdf->Image($db_catalogue_objects->field->obj_image,($db_catalogue_objects->field->obj_posx*0.353),($db_catalogue_objects->field->obj_posy*0.353),"50","50");
}
$pdf->SetXY($db_catalogue_objects->field->obj_posx*0.353,($db_catalogue_objects->field->obj_posy*0.35) + 60);
$pdf->Write(5,$db_catalogue_objects->field->obj_text);
}
$db_catalogue_objects->close();
$db_catalogue_pages->close();
//if($mode=="I") $pdf->Output("page_".$id.".pdf", "I");
//else $pdf->Output("pages/page_".$id.".pdf", "F");
$pdf->Output("pages/page_".$id.".pdf", "F");
}
示例8: carl_merge_pdfs_fpdi
function carl_merge_pdfs_fpdi($pdffiles, $titles = array(), $metadata = array(), $metadata_encoding = 'UTF-8')
{
// FPDI throws some notices that break the PDF
$old_error = error_reporting(E_ERROR | E_WARNING | E_PARSE);
include_once INCLUDE_PATH . 'pdf/tcpdf/tcpdf.php';
include_once INCLUDE_PATH . 'pdf/fpdi/fpdi.php';
if (gettype($pdffiles) != 'array') {
trigger_error('$pdffiles must be an array');
return false;
}
if (!(class_exists('TCPDF') && class_exists('FPDI'))) {
trigger_error('You must have TCPDF/FPDI installed in order to run carl_merge_pdfs()');
return false;
}
if (empty($pdffiles)) {
return NULL;
}
$fpdi = new FPDI();
foreach ($pdffiles as $pdffile) {
if (file_exists($pdffile)) {
$count = $fpdi->setSourceFile($pdffile);
for ($i = 1; $i <= $count; $i++) {
$template = $fpdi->importPage($i);
$size = $fpdi->getTemplateSize($template);
$fpdi->AddPage('P', array($size['w'], $size['h']));
$fpdi->useTemplate($template, null, null, null, null, true);
if ($i == 1) {
if (isset($titles[$pdffile])) {
$bookmark = html_entity_decode($titles[$pdffile]);
} else {
$bookmark = $pdffile;
}
$fpdi->Bookmark($bookmark, 1, 0, '', '', array(0, 0, 0));
}
}
}
}
error_reporting($old_error);
return $fpdi->Output('ignored.pdf', 'S');
}
示例9: mkdir
function split_multi_pdf($arrayOfFiles)
{
$new_path = storage_path() . '/Macyspos';
if (!is_dir($new_path)) {
// Will make directories under end directory that don't exist
// Provided that end directory exists and has the right permissions
mkdir($new_path, 0777, true);
}
foreach ($arrayOfFiles as $file) {
$tempArrayOfPos = array();
$tempArrayOfPos = $this->getArrayOfPOs($file);
$pdf = new FPDI();
$pagecount = $pdf->setSourceFile($file);
// How many pages?
for ($i = 1; $i <= $pagecount; $i++) {
$singleItem = $tempArrayOfPos[$i - 1];
// dd($singleItem);
$tempPackingList = MacysPackingList::where('po', '=', $singleItem['PO'])->first();
if ($tempPackingList == null) {
$new_pdf = new FPDI();
$new_pdf->AddPage();
$new_pdf->setSourceFile($file);
$newPackingList = new MacysPackingList();
$newPackingList->po = trim($singleItem['PO']);
$newPackingList->shipterms = trim($singleItem['shipterms']);
$new_pdf->useTemplate($new_pdf->importPage($i));
try {
$new_filename = storage_path() . '/Macyspos/' . $singleItem['PO'] . '.pdf';
$newPackingList->pathToFile = $new_filename;
$new_pdf->Output($new_filename, "F");
$newPackingList->save();
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
}
}
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$id = $input->getArgument('id');
$pdffile = $input->getArgument('pdf');
$em = $this->getContainer()->get('doctrine');
$tab = $this->csv($pdffile);
$template = $em->getRepository('PrintBundle:Template')->find($id);
$path = $this->getContainer()->get('kernel')->getRootDir() . '/../web/uploads/pdf/' . $template->getPdffile();
$width = $template->getWidth();
$height = $template->getHeight();
$orientation = $height > $width ? 'P' : 'L';
$custom_layout = array($width, $height);
$i = 1;
foreach ($tab as $key => $value) {
$pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(true, 40);
$pdf->setFontSubsetting(false);
// add a page
$pdf->AddPage($orientation);
$pdf->setSourceFile($path);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, 0, 0, $width, true);
foreach ($template->getChildactivity() as $opt) {
$pdf->SetXY($opt->getX(), $opt->getY());
$pdf->SetFont($opt->getFont(), '', $opt->getFontsize() * 2);
// echo $opt->getFontsize()."\n";
$pdf->Cell($opt->getWidth(), $opt->getHeight(), $value[$opt->getName()]);
}
//$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
// echo $template->getId();
$pdf->Output($this->getContainer()->get('kernel')->getRootDir() . '/../web/folder/pdf' . $template->getId() . "-{$i}.pdf", 'F');
$i++;
}
}
示例11: mergeDocuments
/**
* Simple helper function which actually merges a given array of document-paths
* @param $paths
* @return string The created document's url
*/
private function mergeDocuments($paths)
{
include_once 'engine/Library/Fpdf/fpdf.php';
include_once 'engine/Library/Fpdf/fpdi.php';
$pdf = new FPDI();
foreach ($paths as $path) {
$numPages = $pdf->setSourceFile($path);
for ($i = 1; $i <= $numPages; $i++) {
$template = $pdf->importPage($i);
$size = $pdf->getTemplateSize($template);
$pdf->AddPage('P', array($size['w'], $size['h']));
$pdf->useTemplate($template);
}
}
$hash = md5(uniqid(rand()));
$pdf->Output($hash . '.pdf', "D");
}
示例12: save_ticket_data
/**
* Save post metadata when a post is saved.
*
* @param int $post_id The post ID.
* @param post $post The post object.
* @param bool $update Whether this is an existing post being updated or not.
*/
public function save_ticket_data($post_id, $post, $update)
{
global $product;
/*
* In production code, $slug should be set only once in the plugin,
* preferably as a class property, rather than in each function that needs it.
*/
$slug = 'product';
// If this isn't a 'product' post, don't update it.
if ($slug != $post->post_type) {
return;
}
$getprod = get_product($post_id);
//If it's not a ticket return aswell
if ($getprod->product_type != 'ticket') {
return;
}
$getmeta = get_post_meta($post_id, '_downloadable_files', true);
//Traverse the return array since we don't know the first key
foreach ($getmeta as $key => $value) {
$url = $value['file'];
}
$path = $_SERVER['DOCUMENT_ROOT'] . parse_url($url, PHP_URL_PATH);
//To get the dir, use: dirname($path)
require_once 'fpdf/fpdf.php';
require_once 'fpdi/fpdi.php';
//Get stuff to add to pdf :D
$getmetaall = get_post_meta($post_id);
$getcontent = get_post_meta($post_id, 'frs_woo_product_tabs', true);
$i = 1;
$pdf = new FPDI();
// $pdf->AddPage();
//Set the source PDF file
//$pagecount = $pdf->setSourceFile($path);
//Import the first page of the file
//$tpl = $pdf->importPage($i);
//Use this page as template
//$pdf->useTemplate($tpl);
#Print Hello World at the bottom of the page
//Clear all
$pdf->SetFillColor(255, 255, 255);
$pdf->SetY(1);
$pdf->SetFont('Arial', 'I', 19);
$pdf->Cell(0, $pdf->h - 2, ' ', 0, 0, 'C', true);
//Go to 1.5 cm from bottom
$pdf->SetY(1);
//Select Arial italic 8
$pdf->SetFont('Arial', 'I', 19);
//Print centered cell with a text in it
$pdf->Cell(0, 10, $post->post_title, 0, 0, 'C');
/*
$pdf->SetY(10);
$pdf->SetFont('Arial','I',16);
$pdf->Cell(0, 10, gmdate("Y-m-d", $getmetaall["wpcf-event-start-date"][0]), 0, 0, 'C');
$pdf->SetY(20);
$pdf->SetFont('Arial','I',16);
$pdf->Cell(0, 10, 'Start time: ' . $getmetaall["wpcf-event-start-time"][0], 0, 0, 'C');
$pdf->SetY(27);
$pdf->SetFont('Arial','I',16);
$pdf->Cell(0, 10, 'End time: ' . $getmetaall["wpcf-event-end-time"][0], 0, 0, 'C');
$pdf->SetY(1);
$pdf->Image('http://dancenergy.zenutech.com/production/wp-content/uploads/2014/06/Logo.png', 5, 0, 33.78);
*/
//Select Arial italic 8
$pdf->SetY(20);
$pdf->SetFont('Arial', 'I', 15);
$pdf->WriteHTML($getcontent[0]['ticket_content']);
$pdf->Output($path, "F");
/*
echo "<pre>";
var_dump( $getmetaall );
echo "</pre>";
*/
return;
}
示例13: array
//write divider
$data_footer .= '<tr><td colspan="12"><hr></td></tr>';
//add last page
if ($p >= 55) {
$pdf->AddPage('L', array($page_width, $page_height));
}
//output remaining data
$data_body_chunk = $data_start . $data_head;
foreach ($data_body as $data_body_row) {
$data_body_chunk .= $data_body_row;
}
$data_body_chunk .= $data_footer . $data_end;
$pdf->writeHTML($data_body_chunk, true, false, false, false, '');
unset($data_body_chunk);
//define file name
$pdf_filename = "cdr_" . $_SESSION['domain_name'] . "_" . date("Ymd_His") . ".pdf";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header('Content-Disposition: attachment; filename="' . $pdf_filename . '"');
header("Content-Type: application/pdf");
header('Accept-Ranges: bytes');
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// date in the past
// push pdf download
$pdf->Output($pdf_filename, 'D');
// Display [I]nline, Save to [F]ile, [D]ownload
}
示例14: save_design
public function save_design()
{
if ($this->input->post('mode') == 'edit') {
$this->db->delete('designs', array('id' => $this->input->post('design_id')));
}
$faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket'));
$backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket'));
$face = $this->input->post('face');
$back = $this->input->post('back');
// get all fonts
$query = $this->db->get('fonts');
$fonts = array();
foreach ($query->result() as $font) {
$fonts[$font->family] = $font->source;
}
// generate pdf face template name and preview name
$face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf';
$face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg';
// convert face image to pdf
$img = new Imagick($faceMacket);
$img->setresolution(300, 300);
$img->setcolorspace(Imagick::COLORSPACE_CMYK);
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setimageformat('pdf');
$img->writeimage($face_pdf);
// include TCPDF ana FPDI
include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
include_once APPPATH . 'libraries/tcpdf/fpdi.php';
include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
$fontMaker = new TCPDF_FONTS();
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->SetMargins(0, 0, 0, true);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile($face_pdf);
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->setCellHeightRatio(1);
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->setCellMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(false, 0);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
if (!empty($face)) {
// отрисуем сначала изображения лица
foreach ($face as $item) {
if ($item['type'] == 'image') {
$pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
}
}
// потом текст на лице
foreach ($face as $item) {
if ($item['type'] == 'text') {
$cmyk = $this->rgbToCmyk($item['color']);
$pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
// set font
$tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']]));
$pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
$pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
}
}
}
// сохраним пдф лица
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F');
// сделаем превью для пользователя
$im = new Imagick();
$im->setResolution(300, 300);
$im->readimage($face_pdf . '[0]');
$im->flattenimages();
$im->setImageFormat('jpg');
$im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$im->writeImage($face_preview);
$im->clear();
$im->destroy();
//exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview);
// есть ли оборот
if (!empty($backMacket)) {
// generate pdf back template name and preview name
$back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf';
$back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg';
// convert back image to pdf
$img = new Imagick($backMacket);
$img->setresolution(300, 300);
$img->setcolorspace(Imagick::COLORSPACE_CMYK);
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setimageformat('pdf');
$img->writeimage($back_pdf);
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf);
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->SetMargins(0, 0, 0, true);
//.........这里部分代码省略.........
示例15: view_sign_oc
public function view_sign_oc(){
require_once('./assets/fpdf17/fpdf.php');
require_once('./assets/fpdf17/fpdi.php');
$oc_id=$this->uri->segment(3,'');
// init pce data
$oc_dat=$this->m_oc->get_oc_by_id($oc_id);
$project=$this->m_project->get_project_by_id($oc_dat->project_id);
//init sign pic
$ae_sign_user_dat=$this->m_user->get_user_by_login_name($project->project_cs);
$ae_sign_filename="no";
if (isset($ae_sign_user_dat->sign_filename)) {
$ae_sign_filename=$ae_sign_user_dat->sign_filename;
}
$finance_sign_dat=$this->m_user->get_user_by_login_name($oc_dat->fc_sign);
$finance_sign_filename="no";
if (isset($finance_sign_dat->sign_filename)) {
$finance_sign_filename=$finance_sign_dat->sign_filename;
}
// initiate FPDI
$pdf = new FPDI();
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','','angsa.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','B','angsab.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','I','angsai.php');
// เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา กำหนด ชื่อ เป็น angsana
$pdf->AddFont('angsana','BI','angsaz.php');
// get the page count
$pageCount = $pdf->setSourceFile("./media/real_pdf/".$oc_dat->filename);
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('angsana','B',14);
$pdf->SetXY(5, 5);
//$pdf->Write(8, 'A complete document imported with FPDI');
//// temporaly disable
if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) {
//$pdf->Image("./media/sign_photo/".$finance_sign_filename,100,10,40,0);
}
if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) {
//$pdf->Image("./media/sign_photo/".$ae_sign_filename,100,110,40,0);
}
//$pdf->Image("images/play.png",100,100,100,0);
}
$new_filename=$oc_dat->oc_no."_A.pdf";
// Output the new PDF
//@unlink("./media/real_pdf/".$new_filename);
$pdf->Output($new_filename,"I");
//redirect("media/real_pdf/".$new_filename);
}