本文整理汇总了PHP中FPDI::SetAutoPageBreak方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::SetAutoPageBreak方法的具体用法?PHP FPDI::SetAutoPageBreak怎么用?PHP FPDI::SetAutoPageBreak使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::SetAutoPageBreak方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: merge
/**
* Merge multiple documents.
*
* @return Dhl_Intraship_Helper_Pdf $this
* @throws Dhl_Intraship_Helper_Pdf_Exception
*/
public function merge()
{
// Include required fpdi library.
if (!class_exists('FPDF', false)) {
require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdf.php';
}
if (!class_exists('FPDI', false)) {
require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdi.php';
}
// Try to merge documents via FPDI.
try {
// Create new FPDI document
$this->_document = new FPDI('P', 'mm', $this->getConfig()->getFormat());
$this->_document->SetAutoPageBreak(false);
$page = 1;
foreach ($this->_collection as $document) {
$pages = $this->_document->setSourceFile($document->getFilePath());
for ($i = 1; $i <= $pages; $i++) {
$this->_document->addPage();
$this->_document->useTemplate($this->_document->importPage($i, '/MediaBox'));
$page++;
}
}
} catch (Exception $e) {
throw new Dhl_Intraship_Helper_Pdf_Exception('pdf merging failed. service temporary not available', $e->getCode());
}
return $this;
}
示例2: 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++;
}
}
示例3: emarking_import_pdf_into_pdf
function emarking_import_pdf_into_pdf(FPDI $pdf, $pdftoimport)
{
$originalpdfpages = $pdf->setSourceFile($pdftoimport);
$pdf->SetAutoPageBreak(false);
// Add all pages in the template, adding the header if it corresponds
for ($pagenumber = 1; $pagenumber <= $originalpdfpages; $pagenumber++) {
// Adding a page
$pdf->AddPage();
$template = $pdf->importPage($pagenumber);
$pdf->useTemplate($template, 0, 0, 0, 0, true);
}
}
示例4: createScreeningPdf
public function createScreeningPdf($hash)
{
$screening_entry_model = ScreeningEntry::findOne(['hash' => $hash]);
$screening_form_model = ScreeningForm::findOne(['id' => $screening_entry_model->screening_form_id]);
$subject_model = Subject::findOne(['id' => $screening_entry_model->subject_id]);
$count = 1;
//$permissions = \SetaPDF_Core_SecHandler::PERM_DIGITAL_PRINT ;
$this->_font = 'Helvetica';
//class_exists('TCPDF', true); // trigger Composers autoloader to load the TCPDF class
$pdf = new \FPDI();
$pdf->SetAutoPageBreak(true);
// add a page
$pdf->SetTopMargin(30);
$pdf->AddPage();
$pdf->setSourceFile(\yii::$app->basePath . "/../letterhead-mini-header.pdf");
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useTemplate($tplIdx, 0, 0);
$pdf->SetFont($this->_font, '', 9);
$pdf->SetXY(10, 6);
$pdf->Cell(0, 3, 'Confidential - Participant screening form');
$pdf->SetFont($this->_font, '', 12);
$pdf->SetXY(10, 14);
$pdf->MultiCell(150, 3, yii::$app->DateComponent->timestampToUkDate($screening_entry_model->created_at), 0, 'R');
$pdf->MultiCell(100, 3, $screening_entry_model->screening_form_title, 0, '');
$pdf->Ln();
$pdf->SetFont($this->_font, '', 9);
$pdf->Cell(100, 4, sprintf('Participant: %s %s (dob %s)', $screening_entry_model->subject->first_name, $screening_entry_model->subject->last_name, yii::$app->DateComponent->isoToUkDate($screening_entry_model->subject->dob)));
$pdf->Cell(50, 4, sprintf('Identifier: %s', $screening_entry_model->subject->cubric_id), 0, '', 'R');
$pdf->Ln();
$pdf->Cell(100, 4, sprintf('Researcher: %s %s (project %s)', $screening_entry_model->researcher->first_name, $screening_entry_model->researcher->last_name, $screening_entry_model->project->code));
$pdf->Cell(50, 4, sprintf('Resource: %s', $screening_entry_model->resource_title), 0, '', 'R');
$pdf->SetXY(10, 38);
$pdf->SetFont($this->_font, '', 12);
$pdf->Cell(150, 4, sprintf('Responses'));
$pdf->SetFont($this->_font, '', 9);
$pdf->Ln();
foreach (yii::$app->screeningresponse->getResponses($hash) as $response) {
if (strlen($response['caption']) > 0) {
$pdf->Ln();
$pdf->MultiCell(180, 4, sprintf('%s ', $response['caption']), 0, 'U');
$count = 1;
}
$pdf->MultiCell(180, 4, sprintf('%s. %s ', $count, $response['content']));
$pdf->SetFont($this->_font, 'B', 9);
if ($response['response'] === null) {
$response['response'] = 'Not specified / Unknown.';
}
$pdf->MultiCell(180, 4, sprintf('%s ', $response['response']));
$pdf->SetFont($this->_font, '', 9);
$count++;
$pdf->Ln();
}
$pdf->Ln();
$pdf->SetFont($this->_font, '', 12);
$pdf->Cell(180, 4, sprintf('Signatures'));
$pdf->Ln();
$pdf->Ln();
$pdf->SetFont($this->_font, '', 9);
$pdf->Cell(100, 4, 'Participant ');
$pdf->Cell(100, 4, 'Researcher ');
$pdf->Ln();
$pdf->Ln();
$currentX = $pdf->GetX();
$currentY = $pdf->GetY();
$pdf->Image(sprintf('/tmp/subject-%s.png', $hash), $currentX, $currentY);
$currentX = $pdf->GetX();
$pdf->Image(sprintf('/tmp/researcher-%s.png', $hash), $currentX + 100, $currentY);
// now write some text above the imported page
// NOW SET ScreeningEntry::progress_id = PUBLISHED so it cannot be edited again.
// $pdfData = $pdf->Output('S');
// create a writer
// create a Http writer
//$writer = new \SetaPDF_Core_Writer_Http("fpdf-sign-demo.pdf", true);
// load document by filename
//$document = new \SetaPDF_Core_Document::loadByString($pdfData, $writer);
//$document = new \SetaPDF_Core_Reader_File($pdf->Output(), $writer);
$writer = new \SetaPDF_Core_Writer_File("/Users/Spiro/tmp/myPDF.pdf");
$document = \SetaPDF_Core_Document::loadByString($pdf->Output("S"), $writer);
// let's prepare the temporary file writer:
\SetaPDF_Core_Writer_TempFile::setTempDir("/tmp/");
// create a signer instance for the document
$signer = new \SetaPDF_Signer($document);
// add a field with the name "Signature" to the top left of page 1
$signer->addSignatureField(\SetaPDF_Signer_SignatureField::DEFAULT_FIELD_NAME, 1, \SetaPDF_Signer_SignatureField::POSITION_LEFT_BOTTOM, array('x' => 10, 'y' => 10), 180, 50);
// set some signature properties
$signer->setReason('Integrity');
$signer->setLocation('CUBRIC');
$signer->setContactInfo('+44 2920 703859');
// ccreate an OpenSSL module instance
$module = new \SetaPDF_Signer_Signature_Module_OpenSsl();
// set the sign certificate
$module->setCertificate(file_get_contents("/Users/spiro/Sites/projects/certs/certificate.pem"));
// set the private key for the sign certificate
$module->setPrivateKey(array(file_get_contents("/Users/spiro/Sites/projects/certs/key.pem"), ""));
// create a Signature appearance
$visibleAppearance = new \SetaPDF_Signer_Signature_Appearance_Dynamic($module);
// choose a document to get the background from and convert the art box to an xObject
$backgroundDocument = \SetaPDF_Core_Document::loadByFilename(Yii::getAlias('@frontend/web/img/cubric-logo.pdf'));
$backgroundXObject = $backgroundDocument->getCatalog()->getPages()->getPage(1)->toXObject($document);
//.........这里部分代码省略.........
示例5: executeBatchPrintBadge
public function executeBatchPrintBadge(sfWebRequest $request)
{
$ids = $request->getParameter('ids');
// initiate FPDI
$pdf = new FPDI('P', 'pt');
// set the sourcefile
$pdf->setSourceFile(sfConfig::get('sf_upload_dir') . '/badges/ID_new.pdf');
foreach ($ids as $id) {
$this->employee = EmployeePeer::retrieveByPk($id);
// import page 1
$tplIdx = $pdf->importPage(1);
// add a new page based on size of the badge
$s = $pdf->getTemplatesize($tplIdx);
$pdf->AddPage('P', array($s['w'], $s['h']));
$pdf->useTemplate($tplIdx);
$pdf->setMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(false);
if ($this->employee->getPicture()) {
$pdf->Image(sfConfig::get('sf_upload_dir') . '/' . sfConfig::get('app_employee_images_dir') . '/' . $this->employee->getPicture(), 29.5, 25.5, 60.3, 74.3);
} else {
$pdf->Image(sfConfig::get('sf_upload_dir') . '/badges/picture_missing.jpg', 29.5, 25.5, 60.3, 74.3);
}
// now write some text above the imported page
$pdf->SetFont('freesans', 'B', 12);
$pdf->SetTextColor(82, 78, 134);
$pdf->SetXY(22, 110);
$pdf->Cell(0, 12, $this->employee->getFullName());
$pdf->Ln();
$pdf->SetX(22);
$pdf->SetFont('freesans', 'BI', 10);
$pdf->Cell(0, 14, $this->employee->getJob());
$pdf->SetDisplayMode('real');
}
return $pdf->Output('newpdf.pdf', 'D');
}
示例6: array
function schedule_retirement_pay($date_retired = '', $employee_id = '1')
{
$data = array();
$data['msg'] = '';
$this->load->library('fpdf');
if (!defined('FPDF_FONTPATH')) {
define('FPDF_FONTPATH', $this->config->item('fonts_path'));
}
$this->load->library('fpdi');
// initiate FPDI
$pdf = new FPDI('L', 'mm', 'Legal');
$pdf->SetAutoPageBreak(FALSE);
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('dtr/template/leave/schedule_retirement_pay.pdf');
// select the first page
$tplIdx = $pdf->importPage(1);
// use the page we imported
$pdf->useTemplate($tplIdx);
$e = new Employee_m();
$e->get_by_employee_id($employee_id);
// set font, font style, font size.
$pdf->SetFont('Times', '', 10);
$pdf->SetTextColor(89, 89, 89);
// set initial placement
$pdf->SetXY(142, 20.5);
$personal = new Personal_m();
$personal->where('employee_id', $e->id);
$personal->get(1);
$this->load->helper('date');
$o = new Office_m();
$o->get_by_office_id($e->office_id);
$period = 'January 1, 2012 May 10, 2012';
$office_name = $o->office_name;
$lgu_name = Setting::getField('lgu_name');
//var_dump($date_retired);
$date_retired_diff = $date_retired;
$date_birth = convert_long_date($personal->birth_date, TRUE);
$first_day_of_service = convert_long_date($e->first_day_of_service);
$date_retired = convert_long_date($date_retired, TRUE);
$salary = $this->Salary_grade->get_monthly_salary($e->salary_grade, $e->step);
//$pdf->SetX(114);
$pdf->Write(0, $period);
$pdf->Ln(10);
$pdf->SetX(63);
$pdf->Write(0, $office_name);
$pdf->Ln(5);
$pdf->SetX(63);
$pdf->Write(0, $lgu_name);
$pdf->SetFont('Times', 'B', 10);
$pdf->Ln(21.5);
$pdf->SetX(14);
$pdf->Write(0, $e->fname . ' ' . substr($e->mname, 0, 1) . '. ' . $e->lname);
$pdf->SetFont('Times', '', 10);
$pdf->SetX(65);
$pdf->Write(0, $date_birth);
$pdf->SetX(88);
$pdf->Write(0, $date_retired);
$date1 = new DateTime("1970-7-01");
$date2 = new DateTime("2011-11-16");
$date1 = new DateTime($e->first_day_of_service);
$date2 = new DateTime($date_retired_diff);
$interval = $date1->diff($date2);
//echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";
if ($interval->y != 0) {
$pdf->SetX(114);
$pdf->Write(0, $interval->y . " years");
}
if ($interval->m != 0) {
$pdf->Ln(5);
$pdf->SetX(114);
$pdf->Write(0, $interval->m . " months");
}
if ($interval->d != 0) {
$pdf->Ln(5);
$pdf->SetX(114);
$pdf->Write(0, $interval->d . " days");
}
// Salary
$pdf->SetXY(145, 53);
$pdf->Cell(20, 8, number_format($salary, 2), '', 0, 'C', FALSE);
$total_leave = $this->Leave_card->get_total_leave_credits($employee_id);
$vacation_leave = $total_leave['vacation'];
$sick_leave = $total_leave['sick'];
$total = $vacation_leave + $sick_leave;
$terminal_leave = $salary * $total * 0.0478087;
// vacation leave
$pdf->SetXY(203, 58);
$pdf->Cell(20, 8, number_format($vacation_leave, 3), '', 0, 'R', FALSE);
// sick leave
$pdf->SetXY(203, 63);
$pdf->Cell(20, 8, number_format($sick_leave, 3), '', 0, 'R', FALSE);
// total
$pdf->SetXY(203, 68);
$pdf->Cell(20, 8, number_format($total, 3), '', 0, 'R', FALSE);
// terminal leave
$pdf->SetX(274);
$pdf->Cell(20, 8, number_format($terminal_leave, 2), '', 0, 'R', FALSE);
$pdf->SetFont('Times', 'B', 10);
//.........这里部分代码省略.........
示例7: header
header("location: index.php?app=print");
die;
} else {
$items = $_REQUEST['item'];
$conf = $_REQUEST['conf'];
}
ini_set("memory_limit", "64M");
require_once 'class/data.php';
require_once 'class/build.php';
require_once 'tcpdf/tcpdf.php';
require_once 'tcpdf/tcpdf_addons.php';
require_once 'FPDI/fpdi.php';
$print_data = new print_data_class($_camp->id);
$print_build = new print_build_class($print_data);
$pdf = new FPDI('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->SetAutoPageBreak(true);
$pdf->SetAuthor('ecamp2.pfadiluzern.ch');
$pdf->SetSubject('J&S - Programm');
$pdf->SetTitle('J&S - Programm');
foreach ($items as $nr => $item) {
if ($item == "title") {
$print_build->cover->build($pdf);
}
if ($item == "picasso") {
$print_build->picasso->set_orientation($conf[$nr]);
$print_build->picasso->build($pdf);
}
if ($item == "allevents") {
if ($conf[$nr] == "true") {
$print_build->daylist->build($pdf);
}
示例8: FPDI
$return = "templates/18px_up-red.png";
} else {
$return = "";
}
return $return;
}
}
// just require FPDI afterwards
require_once './FPDI-1.4.4/fpdi.php';
// Page in is in mm -- 215.9 wide, by 279.4 = 8.5 x 11 inches
// initiate PDF
$pdf = new FPDI("P", "mm", "letter");
// Shortcut so we don't have to write $this_border so much;
$b = $pdf->border;
// Set page break distance from bottom
$pdf->SetAutoPageBreak(false, 30);
// Load the dynamic content from the post
$content = json_decode(utf8_encode($_POST['content']));
$pdf->content = $content;
// Note - Don't add all the fonts. They all get embedded in the PDF wether you use them or not.
// Add some Unicode font (uses UTF-8)
// Hairline
$pdf->AddFont('Lato-100', '', 'Lato-Hai.ttf', true);
// Regular
$pdf->AddFont('Lato', '', 'Lato-Lig.ttf', true);
// Bold
$pdf->AddFont('Lato', 'B', 'Lato-Reg.ttf', true);
// Really Bold
$pdf->AddFont('Lato-700', '', 'Lato-Bol.ttf', true);
//
$pdf->SetFont('Lato', '', 10);
示例9: resizePdf
/**
* resizePdf
*
* @return void
*/
public function resizePdf()
{
try {
if (false === class_exists('FPDF', false)) {
require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdf.php';
}
if (false === class_exists('FPDI', false)) {
require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdi.php';
}
// Create new FPDI document
$document = new FPDI('P', 'mm', $this->getConfig()->getFormat());
$margins = $this->getConfig()->getMargins();
$document->SetAutoPageBreak(false);
$pages = $document->setSourceFile($this->getPathToPdf());
for ($i = 1; $i <= $pages; $i++) {
$document->addPage();
$document->useTemplate($document->importPage($i, '/MediaBox'), $margins['left'], $margins['top']);
}
$document->Output($this->getPathToPdf(), 'F');
} catch (Exception $e) {
throw new Dhl_Intraship_Helper_Pdf_Exception('pdf resizing failed. service temporary not available. ' . $e->getMessage(), $e->getCode());
}
}
示例10: Output
function Output($type)
{
$type = strtolower($type);
//Initialize PDF object so all subclasses can access it.
//Loop through all objects and combine the output from each into a single document.
if ($type == 'pdf') {
if (!class_exists('tcpdf')) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->tcpdf_dir . DIRECTORY_SEPARATOR . 'tcpdf.php';
}
if (!class_exists('fpdi')) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->fpdi_dir . DIRECTORY_SEPARATOR . 'fpdi.php';
}
$pdf = new FPDI('P', 'pt');
$pdf->setMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(FALSE);
$pdf->setFontSubsetting(FALSE);
foreach ($this->objs as $obj) {
$obj->setPDFObject($pdf);
$obj->Output($type);
}
return $pdf->Output('', 'S');
} elseif ($type == 'efile') {
foreach ($this->objs as $obj) {
return $obj->Output($type);
}
} elseif ($type == 'xml') {
//Since multiple XML sections may need to be joined together,
//We must pass the XML object between each form and build the entire XML object completely
//then output it all at once at the end.
$xml = NULL;
$xml_schema = NULL;
foreach ($this->objs as $obj) {
if (is_object($xml)) {
$obj->setXMLObject($xml);
}
$obj->Output($type);
if (isset($obj->xml_schema)) {
$xml_schema = $obj->getClassDirectory() . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $obj->xml_schema;
}
if ($xml == NULL and is_object($obj->getXMLObject())) {
$xml = $obj->getXMLObject();
}
}
if (is_object($xml)) {
$output = $xml->asXML();
$xml_validation_retval = $this->validateXML($output, $xml_schema);
if ($xml_validation_retval !== TRUE) {
Debug::text('XML Schema is invalid! Malformed XML!', __FILE__, __LINE__, __METHOD__, 10);
//$output = FALSE;
$output = $xml_validation_retval;
}
} else {
Debug::text('No XML object!', __FILE__, __LINE__, __METHOD__, 10);
$output = FALSE;
}
return $output;
}
}
示例11: Output
function Output($type)
{
$type = strtolower($type);
//Initialize PDF object so all subclasses can access it.
//Loop through all objects and combine the output from each into a single document.
if ($type == 'pdf') {
if (!class_exists('tcpdf')) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->tcpdf_dir . DIRECTORY_SEPARATOR . 'tcpdf.php';
}
if (!class_exists('fpdi')) {
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->fpdi_dir . DIRECTORY_SEPARATOR . 'fpdi.php';
}
$pdf = new FPDI('P', 'pt');
$pdf->setMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(FALSE);
foreach ($this->objs as $obj) {
$obj->setPDFObject($pdf);
$obj->Output($type);
}
return $pdf->Output('', 'S');
}
}
示例12: generatepdfAction
public function generatepdfAction(command $commande)
{
$request = $this->get('request');
$tools = $this->get('tools.utils');
$session = $request->getSession();
if ($session->has('tpl')) {
$tpl = $commande->getToprint();
$pdffile = "";
foreach ($tpl as $key => $elemnt) {
foreach ($elemnt as $val) {
$prod = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($val['id']);
$template = $prod->getTpl();
$tplpdf = str_replace("../", "", $template->getPdf());
$pdffile = $this->get('kernel')->getRootDir() . '/../web/' . $tplpdf;
}
}
$custom_layout = array(85, 55);
$orientation = 'L';
$pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->SetMargins(0, 0, 0);
$pdf->SetAutoPageBreak(true, 0);
$pdf->setFontSubsetting(false);
$pdf->AddPage($orientation);
// echo "<pre>";print_r($pdf->getMargins());exit;
$pdf->setSourceFile($pdffile);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, 0, 0, 85, 55, true);
$idd = "";
$i = 0;
$oldx = 0;
$oldy = 0;
foreach ($elemnt as $value) {
//if($i==0)
if ($idd != $value['id'] && $value['value'] != "") {
$pdf->SetPageMark();
if (substr($value['value'], 0, 4) != "/tmp") {
//$tools->dump($value);
$align = strtoupper(substr($value['align'], 0, 1));
$color = $this->hex2rgb($value['color']);
$pdf->SetTextColor($color[0], $color[1], $color[2]);
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$y2 = $param->getX1() / 5;
$x1 = $param->getY1() / 5;
//$x1 = 10;$y2 = 8;
$w = $param->getX2() / 5;
$h = $param->getY2() / 5;
$oldx = $x1;
$oldy = $y2;
$pdf->SetX($x1, false);
$pdf->SetY($y2, false);
//$pdf->SetXY($x1, $y2,true);
$pdf->SetFont(null, '', $param->getSize() * 0.6);
//$param->getPolice()
// echo $opt->getFontsize()."\n";
$pdf->Cell($w, $h, $value["value"], 0, 0, $align);
} else {
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$img = $this->getParameter('base_url') . $value['value'];
$pdf->Image($img, $param->getX1() / 4.5, $param->getY1() / 4.55, $param->getX2() / 4.55, $param->getY2() / 4.5, '', '', '', true);
}
}
$idd = $value['id'];
$i++;
}
//$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
// echo $template->getId();
$pdf->Output($this->get('kernel')->getRootDir() . '/../web/pdf.pdf');
}
return new Response("");
}
示例13: test
public function test()
{
// $rgb_arr = sscanf('rgb(243, 243, 243)', "rgb(%d, %d, %d)");
// print_r($this->rgbToCmyk($rgb_arr[0], $rgb_arr[1], $rgb_arr[2]));
// exit();
//
$img = new Imagick('test.jpg');
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setresolution(300, 300);
$img->setimageformat('pdf');
$img->writeimage('test.pdf');
include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
include_once APPPATH . 'libraries/tcpdf/fpdi.php';
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile('test.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);
$pdf->setCellHeightRatio(1);
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->setCellMargins(1, 1, 1, 1);
$pdf->SetAutoPageBreak(false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->Image('qwe.png', 30, 30, 20, '', '', '', '', false, 300);
$pdf->SetTextColor(0, 0, 0, 100);
$pdf->SetFont('helvetica', 'BI', 10, '', 'false');
$pdf->Text(12, 9, 'Black CMYK');
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/uploads/fynal.pdf', 'F');
$im = new Imagick();
$im->setResolution(300, 300);
$im->readimage('uploads/fynal.pdf[0]');
$im->setImageFormat('jpeg');
$im->resizeimage(538, 360, Imagick::FILTER_LANCZOS, 1);
$im->writeImage('uploads/fynal.jpg');
$im->clear();
$im->destroy();
// include_once APPPATH . 'libraries/drawer.php';
//
// $drawer = new Drawer();
// $drawer->init();
// $drawer->setLayout();
// $drawer->setBackground('test.jpg');
// $drawer->drawImage('test.jpg', 10, 10, 30);
// $drawer->drawText('Maxim', 10, 10, 'TimesNewRoman', 20, 'rgb(77, 77, 77)');
// $drawer->savePdf($_SERVER['DOCUMENT_ROOT'] . '/1.pdf');
// $drawer->makePreview($_SERVER['DOCUMENT_ROOT'] . '/1.pdf', $_SERVER['DOCUMENT_ROOT'] . '/1.jpg');
}
示例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: generatepdfAction
public function generatepdfAction($id)
{
$width = 320;
$height = 450;
$pdfmerge = $this->getDoctrine()->getRepository('PrintBundle:Pdfmerge')->find($id);
$elementwidth = $pdfmerge->getWidth();
$elementheight = $pdfmerge->getHeight();
$marge = $pdfmerge->getMarge();
$singlewidth = $elementwidth + $marge;
$singleheight = $elementheight + $marge;
// test occupation
$test1 = (int) ($height / $singleheight) * (int) ($width / $singlewidth);
$test2 = (int) ($width / $singleheight) * (int) ($height / $singlewidth);
if ($test1 >= $test2) {
$width = 320;
$height = 450;
$orientation = "P";
} else {
$width = 450;
$height = 320;
$orientation = "L";
}
// calculate margin
$nbrX = (int) ($width / $singlewidth);
$nbrY = (int) ($height / $singleheight);
$marginleft = ($width - $nbrX * $singlewidth) / 2;
$margintop = ($height - $nbrY * $singleheight) / 2;
//print_r(array($orientation, $marginleft, $margintop));
$custom_layout = array($width, $height);
$pdf = new \FPDI($orientation, 'mm', 'SRA3', true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins($marginleft, 40, $marginleft);
$pdf->SetAutoPageBreak(true, 40);
$pdf->setFontSubsetting(false);
// add a page
$pdf->AddPage($orientation);
$i = 0;
$path = $this->get('kernel')->getRootDir() . '/../web/';
$toaddheight = $margintop;
$face = array();
$j = 0;
foreach ($pdfmerge->getPdflist() as $list) {
for ($k = 0; $k < $list->getRepeat(); $k++) {
if ($i == $nbrX) {
$i = 0;
$j++;
$toaddheight += $singleheight;
}
$toaddwidth = $i * $singlewidth + $marginleft;
$face[$toaddheight][$toaddwidth] = $list->getFile();
$i++;
}
}
$reverse = array();
foreach ($face as $y => $value) {
foreach ($value as $x => $fichier) {
$file = $path . $fichier;
$pdf->setSourceFile($file);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, $x, $y, 85);
$reverse[$y][$x] = $fichier;
}
}
//echo "<pre>";print_r($face);exit;
$this->repert($pdf, $face, $marginleft, $margintop, $singlewidth, $singleheight, $height, $width);
if ($pdfmerge->getNbpage() == 2) {
$pdf->AddPage($orientation);
foreach ($reverse as $y => $value) {
foreach ($value as $x => $fichier) {
$file = $path . $fichier;
$pdf->setSourceFile($file);
$_tplIdx = $pdf->importPage(2);
$size = $pdf->useTemplate($_tplIdx, $x, $y, 85);
$reverse[$y][$x] = $fichier;
}
}
$this->repert($pdf, $face, $marginleft, $margintop, $singlewidth, $singleheight, $height, $width);
}
$pdf->Output("aaa.pdf", 'I');
}