本文整理汇总了PHP中FPDI::Image方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::Image方法的具体用法?PHP FPDI::Image怎么用?PHP FPDI::Image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::Image方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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");
}
示例3: view_sign_pce
public function view_sign_pce(){
require_once('./assets/fpdf17/fpdf.php');
require_once('./assets/fpdf17/fpdi.php');
$pce_id=$this->uri->segment(3,'');
// init pce data
$pce_dat=$this->m_pce->get_pce_by_id($pce_id);
$project=$this->m_project->get_project_by_id($pce_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;
}
$client_service_sign_dat=$this->m_user->get_user_by_login_name($pce_dat->csd_sign);
$client_service_sign_filename="no";
if (isset($client_service_sign_dat->sign_filename)) {
$client_service_sign_filename=$client_service_sign_dat->sign_filename;
}
$finance_sign_dat=$this->m_user->get_user_by_login_name($pce_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/".$pce_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');
$all_three_sign=0;
if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) {
$pdf->Image("./media/sign_photo/".$finance_sign_filename,152,242,40,0);
$c_time=$pce_dat->fc_sign_time;
$pdf->SetXY(162,269);
$pdf->Cell(30,5,iconv( 'UTF-8','cp874' , date("d",$c_time)." ".date("m",$c_time)." ".date("Y",$c_time)),0,0);
$all_three_sign+=1;
}
if ($client_service_sign_filename!="no"&&$client_service_sign_filename!=""&&$client_service_sign_filename!=null) {
$pdf->Image("./media/sign_photo/".$client_service_sign_filename,86,242,40,0);
$c_time=$pce_dat->csd_sign_time;
$pdf->SetXY(96,269.5);
$pdf->Cell(30,5,iconv( 'UTF-8','cp874' , date("d",$c_time)." ".date("m",$c_time)." ".date("Y",$c_time)),0,0);
$all_three_sign+=1;
}
if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) {
$pdf->Image("./media/sign_photo/".$ae_sign_filename,20,242,40,0);
$c_time=$pce_dat->cs_sign_time;
$pdf->SetXY(30,270);
$pdf->Cell(30,5,iconv( 'UTF-8','cp874' , date("d",$c_time)." ".date("m",$c_time)." ".date("Y",$c_time)),0,0);
$all_three_sign+=1;
}
//if ($all_three_sign==3) {
$pdf->Image("./img/Client_Approval_Tag.png",110,204.2,35,0);
//}
//$pdf->Image("images/play.png",100,100,100,0);
}
$new_filename=$pce_dat->pce_no."_A.pdf";
// Output the new PDF
//@unlink("./media/real_pdf/".$new_filename);
$pdf->Output($new_filename,"I");
//redirect("media/real_pdf/".$new_filename);
}
示例4: pdfImg
public function pdfImg($file)
{
require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdf/fpdf.php';
require_once $_SERVER['DOCUMENT_ROOT'] . 'tyj_oa/Public/fpdi/fpdi.php';
$pdf = new FPDI();
$pageCount = $pdf->setSourceFile($file);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$templateId = $pdf->importPage($pageNo);
$size = $pdf->getTemplateSize($templateId);
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
if ($pageNo == $pageCount) {
$img = $_SERVER['DOCUMENT_ROOT'] . get_save_url() . D('user')->where('id = ' . get_user_id())->getField('pic_yin');
$pdf->Image($img, 150, 250, 0, 20);
}
$pdf->useTemplate($templateId);
$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
}
$pdf->Output($file);
}
示例5:
$pdf->Cell(0, 0, $row["NROFACTURA"]);
$pdf->Ln(5.8);
$pdf->Cell(80);
$pdf->Cell(0, 0, $row["MONTOIMPONIBLE"]);
$pdf->Ln(5.8);
$pdf->Cell(80);
$pdf->Cell(0, 0, $row["ALICUOTA"]);
$pdf->Ln(5.2);
$pdf->Cell(80);
$pdf->Cell(0, 0, $row["RETENCION"]);
$pdf->Ln(5.2);
$pdf->Cell(80);
$pdf->Cell(0, 0, $row["RETENCION"]);
$pdf->SetFont("Arial", "", 10);
$pdf->Ln(40);
$pdf->Cell(150);
$pdf->Cell(0, 0, $rowFirmante["FI_FIRMANTE"]);
$pdf->Ln(5);
$pdf->Cell(148.4);
$pdf->Cell(0, 0, $rowFirmante["FI_CARACTER"]);
$pdf->Image("http://extranet-desa.artprov.com.ar/modules/usuarios_registrados/agentes_comerciales/comisiones/images/firma.jpg", 156, 176, 34, 31); //336, 313
$pdf->Output();
?>
示例6: 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);
//.........这里部分代码省略.........
示例7: FPDI
$contrat_PDF->CellFit( 70 , $hauteur_ligne , To::pdf('Exemplaire à conserver') , 1 /*bordure*/ , 2 /*br*/ , 'C' /*alignement*/ , TRUE /*remplissage*/ );
}
// référence du connecteur
$contrat_PDF->SetXY(40,116);
$contrat_PDF->CellFit( 100 , $hauteur_ligne , To::pdf($connecteur_ref) , 0 /*bordure*/ , 2 /*br*/ , 'L' /*alignement*/ , FALSE /*remplissage*/ );
// connecteur
$contrat_PDF->SetXY(93,142);
$contrat_PDF->CellFit( 100 , $hauteur_ligne , To::pdf('"'.$DB_ROW['connexion_nom'].'"') , 0 /*bordure*/ , 2 /*br*/ , 'L' /*alignement*/ , FALSE /*remplissage*/ );
// date fin
$contrat_PDF->SetXY(90,216.5);
$contrat_PDF->CellFit( 100 , $hauteur_ligne , To::pdf(convert_date_mysql_to_french($DB_ROW['convention_date_fin']).'.') , 0 /*bordure*/ , 2 /*br*/ , 'L' /*alignement*/ , FALSE /*remplissage*/ );
// date création
$contrat_PDF->SetXY(121,237.5);
$contrat_PDF->CellFit( 80 , $hauteur_ligne , To::pdf(convert_date_mysql_to_french($DB_ROW['convention_creation']).'.') , 0 /*bordure*/ , 2 /*br*/ , 'L' /*alignement*/ , FALSE /*remplissage*/ );
// signature
$contrat_PDF->Image( CHEMIN_DOSSIER_WEBSERVICES.'sesamath_ent_conventions_sacoche_etablissement_signature.png' , 30 /*x*/ , 254 /*y*/ , 254*0.2 /*largeur*/ , 158*0.2 /*hauteur*/ , 'PNG' );
// ajouter une page ; y importer la page 2 ; l'utiliser comme support
$contrat_PDF->AddPage();
$tplIdx = $contrat_PDF->importPage(2);
$contrat_PDF->useTemplate($tplIdx);
}
// On enregistre la sortie PDF
$contrat_fichier_nom = 'convention_contrat_'.fabriquer_fin_nom_fichier__date_et_alea().'.pdf';
FileSystem::ecrire_sortie_PDF( CHEMIN_DOSSIER_EXPORT.$contrat_fichier_nom , $contrat_PDF );
//
// Imprimer la facture.
//
$facture_PDF = new FPDI( NULL /*make_officiel*/ , 'portrait' /*orientation*/ , 15 /*marge_gauche*/ , 15 /*marge_droite*/ , 10 /*marge_haut*/ , 15 /*marge_bas*/ , 'oui' /*couleur*/ , 'non' /*legende*/ , NULL /*filigrane*/ );
$facture_PDF->setSourceFile(CHEMIN_DOSSIER_WEBSERVICES.'sesamath_ent_convention_sacoche_etablissement_facture.pdf');
// ajouter une page ; y importer la page 1 ; l'utiliser comme support
$facture_PDF->AddPage();
示例8: unset
$logo = $dir_fax_temp . '/' . $remote_filename;
} else {
unset($logo);
}
} else {
$logo = $dir_fax_temp . '/' . $remote_filename;
}
} else {
unset($logo);
}
}
$display_logo = true;
}
}
if ($display_logo) {
$pdf->Image($logo, 0.5, 0.4, 2.5, 0.9, null, null, 'N', true, 300, null, false, false, 0, true);
} else {
//set position for header text, if enabled
$pdf->SetXY($x + 0.5, $y + 0.4);
}
//header
if ($fax_header != '') {
$pdf->SetLeftMargin(0.5);
$pdf->SetFont($pdf_font, "", 10);
$pdf->Write(0.3, $fax_header);
}
//fax, cover sheet
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont($pdf_font, "B", 55);
$pdf->SetXY($x + 4.55, $y + 0.25);
$pdf->Cell($x + 3.5, $y + 0.4, $text['label-fax-fax'], 0, 0, 'R', false, null, 0, false, 'T', 'T');
示例9: FPDI
$contrat_PDF->CellFit(70, $hauteur_ligne, To::pdf('Exemplaire à conserver'), 1, 2, 'C', TRUE);
}
// référence du connecteur
$contrat_PDF->SetXY(40, 116);
$contrat_PDF->CellFit(100, $hauteur_ligne, To::pdf($connecteur_ref), 0, 2, 'L', FALSE);
// connecteur
$contrat_PDF->SetXY(93, 142);
$contrat_PDF->CellFit(100, $hauteur_ligne, To::pdf('"' . $DB_ROW['connexion_nom'] . '"'), 0, 2, 'L', FALSE);
// date fin
$contrat_PDF->SetXY(90, 216.5);
$contrat_PDF->CellFit(100, $hauteur_ligne, To::pdf(convert_date_mysql_to_french($DB_ROW['convention_date_fin']) . '.'), 0, 2, 'L', FALSE);
// date création
$contrat_PDF->SetXY(121, 237.5);
$contrat_PDF->CellFit(80, $hauteur_ligne, To::pdf(convert_date_mysql_to_french($DB_ROW['convention_creation']) . '.'), 0, 2, 'L', FALSE);
// signature
$contrat_PDF->Image(CHEMIN_DOSSIER_WEBSERVICES . 'sesamath_ent_conventions_sacoche_etablissement_signature.png', 30, 254, 254 * 0.2, 158 * 0.2, 'PNG');
// ajouter une page ; y importer la page 2 ; l'utiliser comme support
$contrat_PDF->AddPage();
$tplIdx = $contrat_PDF->importPage(2);
$contrat_PDF->useTemplate($tplIdx);
}
// On enregistre la sortie PDF
$contrat_fichier_nom = 'convention_contrat_' . fabriquer_fin_nom_fichier__date_et_alea() . '.pdf';
FileSystem::ecrire_sortie_PDF(CHEMIN_DOSSIER_EXPORT . $contrat_fichier_nom, $contrat_PDF);
//
// Imprimer la facture.
//
$facture_PDF = new FPDI(NULL, 'portrait', 15, 15, 10, 15, 'oui', 'non', NULL);
$facture_PDF->setSourceFile(CHEMIN_DOSSIER_WEBSERVICES . 'sesamath_ent_convention_sacoche_etablissement_facture.pdf');
// ajouter une page ; y importer la page 1 ; l'utiliser comme support
$facture_PDF->AddPage();
示例10: FlyerRendering
//.........这里部分代码省略.........
// Output-Dasteiname zusammenbauen
$outputFile = $outputPostfix . "-" . $inputFile;
// initiate FPDI
$pdf = new FPDI();
echo "Input: {$inputFile}\n";
$pageCount = $pdf->setSourceFile($inputFile);
// Importiere Vorder- und Rueckseite
$Vorderseite = $pdf->ImportPage(1);
$Rueckseite = $pdf->ImportPage(2);
// Seitenabmessungen holen
$size = $pdf->getTemplateSize($Vorderseite);
$dokumentBreite = round($size['w'], 2);
$dokumentHoehe = round($size['h'], 2);
echo "Dokumenten Breite: {$dokumentBreite} mm\n";
echo "Dokumenten Hoehe: {$dokumentHoehe} mm\n";
echo "Anschnitt: {$anschnitt} mm\n";
// Vorderseite uebernehmen
// Anfang eines bloeden Hacks wegen des FooterZeilen-Textes.
// Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist.
// Keine Ahnung warum!
$pdf->AddPage('L');
$tplVorderseite = $pdf->importPage(1);
$pdf->useTemplate($tplVorderseite);
//Margin ist wegen der Rand-Platzierung des Community Names wichtig.
$pdf->SetMargins(0, 0, 0);
// erstmal alle Fonts laden
echo "Lade Fonts...\n";
$pdf->AddFont('lato-bold');
$pdf->AddFont('lato-regular');
$pdf->AddFont('alternategothic');
// Rendern Titel Text
echo "Verarbeite Titel Text...\n";
$pdf->SetFont('lato-bold');
$pdf->SetFontSize($kontaktTitelFontSize);
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $kontaktTitelText));
// Rendern Info Text
echo "Verarbeite Info Text...\n";
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetFontSize($kontaktInfoFontSize);
foreach ($kontaktInfoTexte as $a) {
$pdf->SetFont('lato-bold');
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0]));
$pdf->SetFont('lato-regular');
$pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1]));
$kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY;
}
// Rendern Community Logo
echo "Verarbeite Logo...\n";
$pdf->Image($kontaktLogoDateiName, $kontaktLogoPositionX + $anschnitt, $kontaktLogoPositionY + $anschnitt, $kontaktLogoWidth, 0);
// Rendern Fusszeilen Text
echo "Verarbeite Fusszeile...\n";
$pdf->SetFont('lato-regular');
$pdf->SetFontSize($kontaktFooterFontSize);
$pdf->SetTextColor(255, 255, 255);
//weiss
$pdf->SetXY($kontaktFooterPositionX + $anschnitt, $kontaktFooterPositionY + $anschnitt);
$pdf->Cell($kontaktFooterWidth, 0, iconv('UTF-8', 'windows-1252', $kontaktFusszeileText), 0, 0, 'C');
// Rendern Community Name
echo "Verarbeite Community Name...\n";
$pdf->SetFont('alternategothic');
$pdf->SetFontSize($communityNameFontSize);
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetXY($communityNamePositionX + $anschnitt, $communityNamePositionY + $anschnitt);
$pdf->MultiCell($wRechts, 10, iconv('UTF-8', 'windows-1252', $communityNameText), 0, 'C');
// Das war's mit dem Editieren
// Original PDF Rueckseit uebernehmen
$pdf->AddPage('L', array($dokumentBreite, $dokumentHoehe));
$tplRueckseite = $pdf->importPage(2);
$pdf->useTemplate($tplRueckseite);
// und erstmal abspeichern
echo "Zwischenspeichern...\n";
$pdf->Output($outputFile);
// Hier geht jetzt der Hack wegen der Footerzeile weiter
// Die gerade abgespeicherte Datei wird erneut eingelesen
// um dann im Seiten-Format der Ursprungsdatei erneut abgespeichert zu werden.
// Is' doof, muss aber sein
$pdf_2 = new FPDI();
echo "Erneut laden...\n";
$pageCount = $pdf_2->setSourceFile($outputFile);
echo "Feinschliff...\n";
$Vorderseite_2 = $pdf_2->ImportPage(1);
$Rueckseite_2 = $pdf_2->ImportPage(2);
$pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe));
$tplForderseite = $pdf_2->importPage(1);
$pdf_2->useTemplate($tplForderseite);
$pdf_2->AddPage('L', array($dokumentBreite, $dokumentHoehe));
$tplRueckseite = $pdf_2->importPage(2);
$pdf_2->useTemplate($tplRueckseite);
echo "Output: {$outputFile}\n";
$pdf_2->Output($outputFile);
unset($pdf);
unset($pdf_2);
}
示例11: 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("");
}
示例12: generatePDF
function generatePDF($id_invoice, $introduction_letter = false, $target = 'file', $docs = false)
{
if (!is_numeric($id_invoice)) {
error_log('$id_invoice not defined');
exit(1);
}
if (!defined('EURO')) {
define('EURO', chr(128));
}
$facture = Facture::getInfos($id_invoice);
foreach (array(LC_MESSAGES, LC_TIME, LC_MONETARY, LC_CTYPE) as $locale) {
setlocale($locale, $facture->language . ".UTF-8") or die("locale {$locale} language failed {$facture->language}");
}
bindtextdomain('webfinance', dirname(__FILE__) . '/../../lang') or die("Set gettext bindtextdomain language failed\n");
textdomain('webfinance') or die("Set gettext textdomain language failed\n");
$type_doc = $facture->type_doc;
if ($facture->language == 'en_US' and $facture->type_doc == 'facture') {
$type_doc = 'invoice';
}
if ($facture->language == 'en_US' and $facture->type_doc == 'devis') {
$type_doc = 'quote';
}
// Generate PDF filename
$filename = sys_get_temp_dir() . '/' . ucfirst($type_doc) . ' ' . preg_replace('/[^a-z0-9éàçùî\\._-]/i', ' ', $facture->num_facture . ' ' . $facture->nom_client) . '.pdf';
foreach ($facture as $n => $v) {
if (!is_array($v)) {
$facture->{$n} = preg_replace("/€/", "EUROSYMBOL", $facture->{$n});
// FPDF ne support pas l'UTF-8
$facture->{$n} = utf8_decode($facture->{$n});
$facture->{$n} = preg_replace("/EUROSYMBOL/", chr(128), $facture->{$n});
$facture->{$n} = preg_replace("/\\\\EUR\\{([0-9.,]+)\\}/", "\\1 " . chr(128), $facture->{$n});
}
}
$pdf = new FPDI('P', 'mm', 'A4');
// Address
$address = "{$facture->nom_client}\n";
for ($i = 0; $i < 3; $i++) {
$n = sprintf("addr%d", $i + 1);
if ($facture->{$n} != "") {
$address .= $facture->{$n} . "\n";
}
}
$address .= "{$facture->cp} {$facture->ville}\n{$facture->pays}";
//Get docs, if needed
if ($docs !== false) {
$pagecount = $pdf->SetSourceFile(dirname(__FILE__) . '/../admin/invoice_docs/docs_' . $facture->language . '.pdf');
for ($n = 1; $n <= $pagecount; $n++) {
$tplidx = $pdf->ImportPage($n, '/MediaBox');
$pdf->AddPage();
$pdf->UseTemplate($tplidx);
}
}
$pdf->SetMargins(10, 10, 10);
$pdf->SetDisplayMode('fullwidth');
$pdf->AddPage();
$prefs = new WebfinancePreferences();
// UTF8 to ISO
$prefs->prefs['societe']->invoice_top_line1 = preg_replace("/€/", "EUROSYMBOL", $prefs->prefs['societe']->invoice_top_line1);
// FPDF ne support pas l'UTF-8
$prefs->prefs['societe']->invoice_top_line1 = utf8_decode($prefs->prefs['societe']->invoice_top_line1);
$prefs->prefs['societe']->invoice_top_line1 = preg_replace("/EUROSYMBOL/", chr(128), $prefs->prefs['societe']->invoice_top_line1);
// Save the logo to a temp file since fpdf cannot read from a var
$tempfile_logo = tempnam(sys_get_temp_dir(), 'logo') . '.png';
$logo_tmp = fopen($tempfile_logo, "w");
fwrite($logo_tmp, $prefs->prefs['logo']);
fclose($logo_tmp);
// Logo
$pdf->Image($tempfile_logo, 90, 5, 25, 0, 'PNG');
// Display text headers
$pdf->SetFont('Arial', '', 5);
$logo_size = getimagesize($tempfile_logo);
$logo_height = $logo_size[1] * 25 / $logo_size[0];
$pdf->SetXY(10, $logo_height + 5);
$pdf->Cell(190, 5, $prefs->prefs['societe']->invoice_top_line1, 0, 0, "C");
$pdf->SetLineWidth(0.3);
$pdf->SetXY(10, $logo_height + 8);
$pdf->Cell(190, 5, utf8_decode($prefs->prefs['societe']->invoice_top_line2), "B", 0, "C");
// Address
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetXY(115, 50);
$pdf->Cell(80, 5, $facture->nom_client, 0, 0);
$pdf->SetFont('Arial', '', 11);
$y = 54;
for ($i = 0; $i < 3; $i++) {
$n = sprintf("addr%d", $i + 1);
if ($facture->{$n} != "") {
$pdf->SetXY(115, $y);
$pdf->Cell(80, 5, $facture->{$n}, 0, 0);
$y += 5;
}
}
$pdf->SetXY(115, $y);
$pdf->Cell(80, 4, $facture->cp . " " . $facture->ville, 0, 0);
$pdf->SetXY(115, $y + 5);
$pdf->Cell(80, 4, $facture->pays, 0, 0);
// Donnees factures
$pdf->SetXY(10, 19 + $logo_height);
$pdf->SetFont('Arial', 'B', 14);
$pdf->Cell(60, 4, ucfirst($type_doc) . utf8_decode(_(' #')) . $facture->num_facture);
$pdf->SetFont('Arial', '', 9);
//.........这里部分代码省略.........
示例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: FlyerRendering
function FlyerRendering($config, $inputFile, $outputPath, $outputPostfix, $anschnitt = 0.0)
{
// Breite der einzelnen Seiten
$wRechts = 99.0;
//mm
$wMitte = 98.0;
//mm
$wLinks = 97.0;
//mm
// Community Name
$communityNamePositionX = $wLinks + $wMitte + $config['communityNamePositionOffsetX'];
//mm
$communityNamePositionY = 12.2 + $config['communityNamePositionOffsetY'];
//mm
// Kontakt Titel
$kontaktTitelPositionX = $wLinks + 3.975;
//mm
$kontaktTitelPositionY = 10.425;
//mm
$kontaktTitelFontSize = 15.0;
//pt
// Kontakt Info
$kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0;
//mm
$kontaktInfoPositionY = $kontaktTitelPositionY + 7.0;
//mm
$kontaktInfoZeilenOffsetY = 4.7;
//mm
$kontaktInfoFontSize = 10.9;
//pt
// Kontakt Logo
$kontaktLogoPositionX = $wLinks + $wMitte / 2 - $config['kontaktLogoWidth'] / 2;
// Kontakt Footer
$kontaktFooterPositionX = $wLinks;
//mm
$kontaktFooterPositionY = 95.40000000000001;
//mm
$kontaktFooterWidth = $wMitte;
//mm
$kontaktFooterFontSize = 10.9;
//pt
// Output-Dasteiname zusammenbauen
$outputFile = $outputPath . DIRECTORY_SEPARATOR . $outputPostfix . '_' . basename($inputFile);
// initiate FPDI
$pdf = new FPDI();
echo 'Input: ' . basename($inputFile) . PHP_EOL;
$pageCount = $pdf->setSourceFile($inputFile);
// Importiere Vorder- und Rueckseite
$Vorderseite = $pdf->ImportPage(1);
$Rueckseite = $pdf->ImportPage(2);
// Seitenabmessungen holen
$size = $pdf->getTemplateSize($Vorderseite);
$dokumentBreite = round($size['w'], 2);
$dokumentHoehe = round($size['h'], 2);
echo 'Dokumenten Breite: ' . $dokumentBreite . 'mm' . PHP_EOL;
echo 'Dokumenten Hoehe: ' . $dokumentHoehe . 'mm' . PHP_EOL;
echo 'Anschnitt: ' . $anschnitt . 'mm' . PHP_EOL;
// Vorderseite uebernehmen
// Anfang eines bloeden Hacks wegen des FooterZeilen-Textes.
// Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist.
// Keine Ahnung warum!
$pdf->AddPage('L');
$tplVorderseite = $pdf->importPage(1);
$pdf->useTemplate($tplVorderseite);
//Margin ist wegen der Rand-Platzierung des Community Names wichtig.
$pdf->SetMargins(0, 0, 0);
// erstmal alle Fonts laden
echo 'Lade Fonts...' . PHP_EOL;
$pdf->AddFont('lato-bold');
$pdf->AddFont('lato-regular');
$pdf->AddFont('alternategothic');
// Rendern Titel Text
echo 'Verarbeite Titel Text...' . PHP_EOL;
$pdf->SetFont('lato-bold');
$pdf->SetFontSize($kontaktTitelFontSize);
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $config['kontaktTitelText']));
// Rendern Info Text
echo 'Verarbeite Info Text...' . PHP_EOL;
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetFontSize($kontaktInfoFontSize);
foreach ($config['kontaktInfoTexte'] as $a) {
$pdf->SetFont('lato-bold');
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0]));
$pdf->SetFont('lato-regular');
$pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1]));
$kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY;
}
// Rendern Community Logo
echo 'Verarbeite Logo...' . PHP_EOL;
$pdf->Image($config['kontaktLogoDateiName'], $kontaktLogoPositionX + $anschnitt, $config['kontaktLogoPositionY'] + $anschnitt, $config['kontaktLogoWidth'], 0);
// Rendern Fusszeilen Text
echo 'Verarbeite Fusszeile...' . PHP_EOL;
$pdf->SetFont('lato-regular');
$pdf->SetFontSize($kontaktFooterFontSize);
//.........这里部分代码省略.........
示例15: emarking_download_exam
//.........这里部分代码省略.........
if ($current > count($pdffileshash) - 1) {
$current = 0;
}
$newfile = emarking_get_path_from_hash($filedir, $pdffileshash[$current]['hash']);
$path = $filedir . "/" . str_replace(' ', '-', $pdffileshash[$current]['filename']);
$cp = $pdf->setSourceFile($path);
}
$pdf->SetAutoPageBreak(false);
for ($i = 1; $i <= $cp + $downloadexam->extrasheets; $i = $i + 1) {
$h = rand(1, 999999);
$img = $fileimg . "/qr" . $h . "_" . $rut[$k] . "_" . $i . "_" . $hash . ".png";
$imgrotated = $fileimg . "/qr" . $h . "_" . $rut[$k] . "_" . $i . "_" . $hash . "r.png";
// Se genera QR con id, curso y número de página
$qrstring = "{$moodleid[$k]} - {$downloadexam->course} - {$i}";
QRcode::png($qrstring, $img);
// se inserta QR
QRcode::png($qrstring . " - R", $imgrotated);
// se inserta QR
$gdimg = imagecreatefrompng($imgrotated);
$rotated = imagerotate($gdimg, 180, 0);
imagepng($rotated, $imgrotated);
$pdf->AddPage();
// Agrega una nueva página
if ($i <= $cp) {
$tplIdx = $pdf->importPage($i);
// Se importan las páginas del documento pdf.
$pdf->useTemplate($tplIdx, 0, 0, 0, 0, $adjustPageSize = true);
// se inserta como template el archivo pdf subido
}
/*
* Ahora se escribe texto sobre las páginas ya importadas. Se fija la fuente, el tipo y el tamaño de la letra. Se señala el título. Se da el nombre, apellido y rut del alumno al cual pertenece la prueba. Se indica el curso correspondiente a la evaluación. Se introduce una imagen. Esta corresponde al QR que se genera con los datos
*/
if ($CFG->emarking_includelogo && $logoisconfigured) {
$pdf->Image($logofilepath, 2, 8, 30);
}
$left = 58;
$top = 8;
$pdf->SetFont('Helvetica', '', 12);
$pdf->SetXY($left, $top);
$pdf->Write(1, core_text::strtoupper($downloadexam->name));
$pdf->SetFont('Helvetica', '', 9);
$top += 5;
$pdf->SetXY($left, $top);
$pdf->Write(1, core_text::strtoupper(get_string('name') . ": " . $nombre[$k]));
$top += 4;
if ($rut[$k] && strlen($rut[$k]) > 0) {
$pdf->SetXY($left, $top);
$pdf->Write(1, get_string('idnumber', 'mod_emarking') . ": " . $rut[$k]);
$top += 4;
}
$pdf->SetXY($left, $top);
$pdf->Write(1, core_text::strtoupper(get_string('course') . ": " . $course->fullname));
$top += 4;
if (file_exists($userimg[$k])) {
$pdf->Image($userimg[$k], 35, 8, 15, 15, "PNG", null, "T", true);
}
$totals = new stdClass();
$totals->identified = $i;
$totals->total = $cp + $downloadexam->extrasheets;
$pdf->SetXY($left, $top);
$pdf->Write(1, core_text::strtoupper(get_string('page') . ": " . get_string('aofb', 'mod_emarking', $totals)));
$pdf->Image($img, 176, 3, 34);
// y antes era -2
$pdf->Image($imgrotated, 0, $pdf->getPageHeight() - 35, 34);
unlink($img);
unlink($imgrotated);