本文整理汇总了PHP中Zend_Pdf::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Pdf::load方法的具体用法?PHP Zend_Pdf::load怎么用?PHP Zend_Pdf::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Pdf
的用法示例。
在下文中一共展示了Zend_Pdf::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRender
public function testRender()
{
$pdf = \Zend_Pdf::load(__DIR__ . '/MSWord.pdf');
$expected = \Zend_Pdf::load(__DIR__ . '/MSWordExpected.pdf');
$gemsPdf = $this->loader->getPdf();
// Start code to expose protected method
$addTokenToDocument = function (\Zend_Pdf $pdf, $tokenId, $surveyId) {
return $this->addTokenToDocument($pdf, $tokenId, $surveyId);
};
$testObject = $addTokenToDocument->bindTo($gemsPdf, $gemsPdf);
// End code to expose protected method
$testObject($pdf, "abcd-efgh", 1);
// fix the date to prevent differences
$pdf->properties['ModDate'] = 'D:' . str_replace(':', "'", date('YmdHisP', 1458048768)) . "'";
// Uncomment to update the test pdf
/*
$stream = fopen(__DIR__ . '/MSWordExpected.pdf', 'w');
$pdf->render(false, $stream);
fclose($stream);
*/
// This will trigger the warning in #812: Warning when printing a survey pdf that was created using Word
// This warning will cause the test to fail
$pdf->render();
$this->assertEquals($expected->getMetadata(), $pdf->getMetadata());
$this->assertEquals($expected->properties, $pdf->properties);
}
示例2: verPdfAction
public function verPdfAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$producto = $this->_producto->getDetalle($this->_getParam('id'));
// var_dump($producto);exit;
$pdf = new Zend_Pdf();
$pdf1 = Zend_Pdf::load(APPLICATION_PATH . '/../templates/producto.pdf');
// $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); // 595 x842
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
// $pdf->pages[] = $page;
// $page->setFont($font, 20);$page->drawText('Zend: PDF', 10, 822);
// $page->setFont($font, 12);$page->drawText('Comentarios', 10, 802);
// $pdfData = $pdf->render();
$page = $pdf1->pages[0];
$page->setFont($font, 12);
$page->drawText($producto['producto'], 116, 639);
$page->drawText($producto['precio'], 116, 607);
$page->drawText($producto['categoria'], 116, 575);
$page->drawText($producto['fabricante'], 116, 543);
$page->drawText('zEND', 200, 200);
$pdfData = $pdf1->render();
header("Content-type: application/x-pdf");
header("Content-Disposition: inline; filename=result.pdf");
$this->_response->appendBody($pdfData);
}
示例3: index
/**
* Extract data from a PDF document and add this to the Lucene index.
*
* @param string $pdfPath The path to the PDF document.
* @param Zend_Search_Lucene_Proxy $luceneIndex The Lucene index object.
* @return Zend_Search_Lucene_Proxy
*/
public static function index($pdfPath, $luceneIndex)
{
// Load the PDF document.
$pdf = Zend_Pdf::load($pdfPath);
$key = md5($pdfPath);
/**
* Set up array to contain the document index data.
* The Filename will be used to retrive the document if it is found in
* the search resutls.
* The Key will be used to uniquely identify the document so we can
* delete it from the search index.
*/
$indexValues = array('Filename' => $pdfPath, 'Key' => $key, 'Title' => '', 'Author' => '', 'Subject' => '', 'Keywords' => '', 'Creator' => '', 'Producer' => '', 'CreationDate' => '', 'ModDate' => '', 'Contents' => '');
// Go through each meta data item and add to index array.
foreach ($pdf->properties as $meta => $metaValue) {
switch ($meta) {
case 'Title':
$indexValues['Title'] = $pdf->properties['Title'];
break;
case 'Subject':
$indexValues['Subject'] = $pdf->properties['Subject'];
break;
case 'Author':
$indexValues['Author'] = $pdf->properties['Author'];
break;
case 'Keywords':
$indexValues['Keywords'] = $pdf->properties['Keywords'];
break;
case 'CreationDate':
$dateCreated = $pdf->properties['CreationDate'];
$distance = substr($dateCreated, 16, 2);
if (!is_long($distance)) {
$distance = null;
}
// Convert date from the PDF format of D:20090731160351+01'00'
$dateCreated = mktime(substr($dateCreated, 10, 2), substr($dateCreated, 12, 2), substr($dateCreated, 14, 2), substr($dateCreated, 6, 2), substr($dateCreated, 8, 2), substr($dateCreated, 2, 4), $distance);
//distance
$indexValues['CreationDate'] = date('Ymd', $dateCreated);
break;
case 'Date':
$indexValues['Date'] = $pdf->properties['Date'];
break;
}
}
/**
* Parse the contents of the PDF document and pass the text to the
* contents item in the $indexValues array.
*/
$pdfParse = new App_Search_Helper_PdfParser();
$indexValues['Contents'] = $pdfParse->pdf2txt($pdf->render());
// Create the document using the values
$doc = new App_Search_Lucene_Document($indexValues);
if ($doc !== false) {
// If the document creation was sucessful then add it to our index.
$luceneIndex->addDocument($doc);
}
// Return the Lucene index object.
return $luceneIndex;
}
示例4: extract
/** extract metadata */
public function extract($revision)
{
/** @var ItemRevisionModel $itemRevisionModel */
$itemRevisionModel = MidasLoader::loadModel('ItemRevision');
$revision = $itemRevisionModel->load($revision['itemrevision_id']);
if (!$revision) {
return;
}
$bitstreams = $revision->getBitstreams();
if (count($bitstreams) != 1) {
return;
}
$bitstream = $bitstreams[0];
$ext = strtolower(substr(strrchr($bitstream->getName(), '.'), 1));
/** @var MetadataModel $metadataModel */
$metadataModel = MidasLoader::loadModel('Metadata');
if ($ext == 'pdf') {
$pdf = Zend_Pdf::load($bitstream->getFullPath());
foreach ($pdf->properties as $name => $property) {
$name = strtolower($name);
try {
$metadataDao = $metadataModel->getMetadata(MIDAS_METADATA_TEXT, 'misc', $name);
if (!$metadataDao) {
$metadataModel->addMetadata(MIDAS_METADATA_TEXT, 'misc', $name, '');
}
$metadataModel->addMetadataValue($revision, MIDAS_METADATA_TEXT, 'misc', $name, $property);
} catch (Zend_Exception $exc) {
echo $exc->getMessage();
}
}
} else {
/** @var SettingModel $settingModel */
$settingModel = MidasLoader::loadModel('Setting');
$command = $settingModel->getValueByName(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, $this->moduleName);
exec(str_replace("'", '"', $command) . ' "' . $bitstream->getFullPath() . '"', $output);
if (!isset($output[0]) || $output[0] != 'Metadata:') {
return;
}
unset($output[0]);
foreach ($output as $out) {
$out = substr($out, 2);
$pos = strpos($out, ': ');
$name = strtolower(substr($out, 0, $pos));
$value = substr($out, $pos + 2);
try {
$metadataDao = $metadataModel->getMetadata(MIDAS_METADATA_TEXT, 'misc', $name);
if (!$metadataDao) {
$metadataModel->addMetadata(MIDAS_METADATA_TEXT, 'misc', $name, '');
}
$metadataModel->addMetadataValue($revision, MIDAS_METADATA_TEXT, 'misc', $name, $value);
} catch (Zend_Exception $exc) {
echo $exc->getMessage();
}
}
}
}
示例5: editmetaAction
public function editmetaAction()
{
// Get the form and send to the view.
$form = new Form_PdfMeta();
$this->view->form = $form;
// Get the file and send the location to the view.
$pdfPath = urldecode($this->_request->getParam('file'));
$file = substr($pdfPath, strrpos($pdfPath, SLASH) + 1);
$this->view->file = $file;
// Define what meta data we are looking at.
$metaValues = array('Title' => '', 'Author' => '', 'Subject' => '', 'Keywords' => '');
if ($this->_request->isPost()) {
// Get the current form values.
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
// Form values are valid.
// Save the contents of the form to the associated meta data fields in the PDF.
$pdf = Zend_Pdf::load($pdfPath);
foreach ($metaValues as $meta => $metaValue) {
if (isset($formData[$meta])) {
$pdf->properties[$meta] = $formData[$meta];
} else {
$pdf->properties[$meta] = '';
}
}
$pdf->save($pdfPath);
// Add to/update index.
$config = Zend_Registry::get('config');
$appLucene = App_Search_Lucene::open($config->luceneIndex);
$index = App_Search_Lucene_Index_Pdfs::index($pdfPath, $appLucene);
// Redirect the user to the list action of this controller.
return $this->_helper->redirector('list', 'pdf', '', array())->setCode(301);
} else {
// Form values are not valid send the current values to the form.
$form->populate($formData);
}
} else {
// Make sure the file exists before we start doing anything with it.
if (file_exists($pdfPath)) {
// Extract any current meta data values from the PDF document
$pdf = Zend_Pdf::load($pdfPath);
foreach ($metaValues as $meta => $metaValue) {
if (isset($pdf->properties[$meta])) {
$metaValues[$meta] = $pdf->properties[$meta];
} else {
$metaValues[$meta] = '';
}
}
// Populate the form with out metadata values.
$form->populate($metaValues);
} else {
// File doesn't exist.
}
}
}
示例6: isValid
/**
* Returns true if and only if $value meets the validation requirements
*
* If $value fails validation, then this method returns false, and
* getMessages() will return an array of messages that explain why the
* validation failed.
*
* @param mixed $value
* @return boolean
* @throws \Zend_Valid_Exception If validation of $value is impossible
*/
public function isValid($value, $context = array())
{
// Only fail when file really can't be loaded.
try {
\Zend_Pdf::load($value);
return true;
} catch (\Zend_Pdf_Exception $e) {
$this->_error(self::ERROR_INVALID_VERSION, $e->getMessage());
return false;
}
}
示例7: createPdfTemplate
/**
*
* @return Zend_Pdf
*
*/
public function createPdfTemplate()
{
if ($this->getDi()->config->get('invoice_custom_template') && ($upload = $this->getDi()->uploadTable->load($this->getDi()->config->get('invoice_custom_template')))) {
$pdf = Zend_Pdf::load($upload->getFullPath());
$this->pointer = $this->getPaperHeight() - $this->getDi()->config->get('invoice_skip', 150);
} else {
$pdf = new Zend_Pdf();
$pdf->pages[0] = $pdf->newPage($this->getDi()->config->get('invoice_format', Zend_Pdf_Page::SIZE_LETTER));
$this->pointer = $this->drawDefaultTemplate($pdf);
}
return $pdf;
}
示例8: init
public function init()
{
//On récupère l'id du document que l'on doit afficher à partir de l'indexController
$request = $this->getRequest();
//Comme nous n'avons pas Active Directory, on suppose que l'ID utilisateur est de 6
$this->user_ID = 6;
// Etat concernant les documents que nous avons utilis� dans la base de donn�e oracle
$this->etat_encours = 1;
$this->etat_surtablette = 2;
$this->etat_valide = 3;
$this->etat_refuse = 4;
$this->etat_enattente = 5;
$this->etat_demandeur = 6;
//On récupère l'ID du document que nous souhaitons afficher à partir de l'indexController
$request = $this->getRequest();
$this->id_document = $request->getParam('COURRIER_ID');
$db = Zend_Db_Table::getDefaultAdapter();
//Si l'utilisateur n'est pas habilit� � voir le document, il est renvoy� � la page d'acceuil.
// On r�cup�re le lien entre l'utilisateur et le document.
$sqlhabilitated = 'SELECT * FROM LIENINTERNE WHERE ID_COURRIER =' . $this->id_document . 'AND ID_ENTITEDESTINATAIRE = ' . $this->user_ID;
$stmthabilitated = $db->query($sqlhabilitated);
while ($rowhabilitated = $stmthabilitated->fetch()) {
$etat_habilitated[] = $rowhabilitated['ID_ETATDESTINATAIRE'];
}
if ($etat_habilitated[0] == null || $etat_habilitated[0] == 0) {
//Il n'existe de lien entre l'utilisateur et le document.
$this->_helper->redirector('index', 'index');
} else {
if ($etat_habilitated[0] != $this->etat_encours && $etat_habilitated[0] != $this->etat_surtablette && $etat_habilitated[0] != $this->etat_demandeur) {
//Le lien entre la personne et le document n'est plus valide.
$this->_helper->redirector('index', 'index');
}
}
//URL utilisé pour récupérer le document pour la liseuse
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/pdf/' . $this->id_document . '.pdf';
//Fichier PDF qui est utilisé = useful for signature and images
$this->filePath = APPLICATION_PATH . '/../public/pdf/' . $this->id_document . '.pdf';
$this->view->pdfurl = $url;
$this->pdf = new Zend_Pdf();
$this->pdf = Zend_Pdf::load($this->filePath, null, true);
}
示例9: testPageCloning
public function testPageCloning()
{
$pdf = Zend_Pdf::load(dirname(__FILE__) . '/_files/pdfarchiving.pdf');
$srcPageCount = count($pdf->pages);
try {
$newPage = clone reset($pdf->pages);
} catch (Zend_Pdf_Exception $e) {
if (strpos($e->getMessage(), 'Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported.') !== 0) {
throw $e;
}
// Exception is thrown
}
$outputPageSet = array();
foreach ($pdf->pages as $srcPage) {
$page = new Zend_Pdf_Page($srcPage);
$outputPageSet[] = $srcPage;
$outputPageSet[] = $page;
$page->saveGS();
// Create new Style
$page->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9))->setLineColor(new Zend_Pdf_Color_GrayScale(0.2))->setLineWidth(3)->setLineDashingPattern(array(3, 2, 3, 4), 1.6)->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32);
$page->rotate(0, 0, M_PI_2 / 3);
$page->drawText('Modified by Zend Framework!', 150, 0);
$page->restoreGS();
}
// Add new page generated by Zend_Pdf object (page is attached to the specified the document)
$pdf->pages = $outputPageSet;
$pdf->save(dirname(__FILE__) . '/_files/output.pdf');
unset($pdf);
$pdf1 = Zend_Pdf::load(dirname(__FILE__) . '/_files/output.pdf');
$this->assertTrue($pdf1 instanceof Zend_Pdf);
$this->assertEquals($srcPageCount * 2, count($pdf1->pages));
unset($pdf1);
unlink(dirname(__FILE__) . '/_files/output.pdf');
}
示例10: user_order_receipt
public static function user_order_receipt()
{
return function ($request, $response) {
$user_id = $request->session('id');
if ($user_id) {
$response->header('Content-Type', 'application/pdf');
$id = $request->id;
$order = Order::findById($id);
$report = Zend_Pdf::load('../pdf/trustrec.pdf');
$page = $report->pages[0];
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$page->setFont($font, 11);
$page->drawText(Time::unixToDate(time()), 460, 900);
$page->drawText(Time::unixToDate(time()), 460, 455);
$page->drawText('Order#: ' . $order->id, 400, 910);
$page->drawText('Order#: ' . $order->id, 400, 465);
$page->drawText($order->user->profile->fullname, 100, 900);
$page->drawText($order->user->profile->fullname, 100, 455);
$page->drawText($order->user->profile->address, 440, 530);
$page->drawText($order->user->profile->address, 440, 85);
$page->drawText($order->user->profile->fullname, 445, 555);
$page->drawText($order->user->profile->fullname, 445, 109);
$row = 850;
foreach ($order->items as $item) {
# code...
$page->drawText($item->product->name, 80, $row);
$page->drawText($item->product->name, 80, $row - 446);
$page->drawText($item->quantity, 45, $row);
$page->drawText($item->quantity, 45, $row - 446);
$page->drawText(money_format('%5.2n', $item->product->price), 315, $row);
$page->drawText(money_format('Php %5.2n', $item->subtotal), 370, $row);
$page->drawText(money_format('%5.2n', $item->product->price), 315, $row - 446);
$page->drawText(money_format('Php %5.2n', $item->subtotal), 370, $row - 446);
$row -= 17;
}
$page->drawText(money_format('Php %5.2n', $order->total), 370, 562);
$page->drawText(money_format('Php %5.2n', $order->total), 370, 118);
#$page->drawText( money_format('Php %5.2n', $order->total * 0.30),450,485);
echo $report->render();
} else {
$response->code(403);
}
};
}
示例11: header
<?php
header('Content-Type: application/x-pdf');
header("Content-Disposition: inline; filename=invoice-" . date("Y-m-d-H-i") . ".pdf");
header("Cache-Control: no-cache, must-revalidate");
$path = dirname(dirname(__FILE__)) . '/library';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once "Zend/Pdf.php";
$daily = Zend_Pdf::load('Daily.pdf');
$page = $daily->pages[0];
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$page->setFont($font, 11);
//echo "Height = {$page->getHeight()} \n";
//echo "Width = {$page->getWidth()} \n";
$date = 'Date: 9/19/2012';
$name = 'Jellene Q. Pastoral';
$name2 = 'Rosemarie C. Villacorta';
$name3 = 'Florefie A. Remedios';
$page->drawText($date, 460, 720);
$page->drawText($name, 54, 684);
// diff 14 pt
$page->drawText($name2, 54, 670);
$page->drawText($name3, 54, 656);
$daily->save('wewe.pdf');
示例12: testPhpVersionBug
/**
* @group ZF-8462
*/
public function testPhpVersionBug()
{
try {
$file = dirname(__FILE__) . '/_files/ZF-8462.pdf';
$pdf = Zend_Pdf::load($file);
} catch (Zend_Pdf_Exception $e) {
if (strpos($e->getMessage(), 'Cross-reference streams are not supported yet.') !== false) {
// Skip expected exception
return;
}
throw $e;
}
}
示例13: load
public static function load($source = null, $revision = null)
{
self::$file = $source;
self::$_pdf = parent::load($source);
}
示例14: pdfAction
public function pdfAction()
{
require_once '/Zend/Pdf.php';
require_once '/PS/utils.php';
if (!$this->_hasParam('id')) {
return $this->_redirect('/analysis/index/page/1');
}
$datos = new Application_Model_Analysis();
$row = $datos->getRow($this->_getParam('id'));
if ($row) {
$data = $row->toArray();
$contact = new Application_Model_Contacts();
$results = new Application_Model_Results();
$exa = $datos->BySpecialties($this->_getParam('id'));
$customer = $contact->getRow($data['applicant_id'])->toArray();
$medico = $contact->getRow($data['medic_id'])->toArray();
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//$pdf = new Zend_Pdf();
if ($data['name'] == 1) {
$pdf = Zend_Pdf::load('img/2.pdf');
} else {
$pdf = Zend_Pdf::load('img/1.pdf');
}
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
//$pdf->pages[] = $page;
$page = $pdf->pages[0];
/*
//specify color
$color = new Zend_Pdf_Color_HTML("navy");
$page->setFillColor($color);
*/
$fontT = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_TIMES);
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA), 10);
$page->drawText($customer['first_name'] . ' ' . $customer['last_name'], 125, 712);
$page->drawText(date('Y-m-d', strtotime($data['date_entered'])), 455, 712);
$page->drawText(birthday($customer['birthdate']), 125, 700);
$page->drawText($customer['gender'], 455, 700);
$page->drawText($medico['first_name'] . ' ' . $medico['last_name'], 125, 685);
$posY = 670;
foreach ($exa as $key) {
$posY -= 50;
$page->setLineWidth(0.5);
$page->drawLine(50, $posY + 15, 530, $posY + 15);
$page->setLineWidth(0.5);
$page->drawLine(50, $posY - 10, 530, $posY - 10);
$page->drawText('Examen', 50, $posY);
$page->drawText('Resultado', 280, $posY);
$page->drawText('U.M.', 360, $posY);
$page->drawText('Valores de Referencia', 400, $posY);
$page->drawText($key['name'], 50, $posY - 25);
$res = $results->getBy(array('analysis_id =?' => $key['analysis_id'], 'test_id =?' => $key['itest_id']))->toArray();
$posY -= 38.4;
foreach ($res as $keyd) {
$page->drawText($keyd['item_name'], 60, $posY);
$page->drawText($keyd['result'], 280, $posY);
$page->drawText($keyd['ref_val_unit'], 350, $posY);
$page->drawText($keyd['ref_val_value'], 420, $posY);
$posY -= 14.2;
}
$posY -= 20.2;
$page->drawText('MUESTRA:', 280, $posY);
$page->drawText('METODO DE PROCESO:', 280, $posY - 14);
}
if ($posY < 400) {
$page2 = new Zend_Pdf_Page($page);
$pdf->pages[] = $page2;
}
$page->drawText('OBSERVACIONES:', 50, 170);
$page->drawText($data['note'], 50, 155);
$this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=result.pdf')->setHeader('Content-type', 'application/x-pdf');
echo $pdf->render();
}
}
示例15: ini_set
<?php
ini_set('include_path', '/www/PHP-Library');
require_once "Zend/Exception.php";
require_once "Zend/Pdf.php";
require_once "Zend/Pdf/Exception.php";
$testPDF = 'Monte Carlo Model of Background Glutamate Spillover in the Hippocampus 2004-3291.pdf';
$ZendPDF = Zend_Pdf::load($testPDF);
print_r($ZendPDF->properties);
$ZendPDF->properties['foo'] = 'bar';
$ZendPDF->save($testPDF);