本文整理匯總了PHP中TCPDF::ImageSVG方法的典型用法代碼示例。如果您正苦於以下問題:PHP TCPDF::ImageSVG方法的具體用法?PHP TCPDF::ImageSVG怎麽用?PHP TCPDF::ImageSVG使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TCPDF
的用法示例。
在下文中一共展示了TCPDF::ImageSVG方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
// NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library.
//$pdf->setRasterizeVectorImages(true);
$pdf->ImageSVG($file = '../images/testsvg.svg', $x = 15, $y = 30, $w = '', $h = '', $link = 'http://www.tcpdf.org', $align = '', $palign = '', $border = 1, $fitonpage = false);
$pdf->ImageSVG($file = '../images/tux.svg', $x = 30, $y = 100, $w = '', $h = 100, $link = '', $align = '', $palign = '', $border = 0, $fitonpage = false);
$pdf->SetFont('helvetica', '', 8);
$pdf->SetY(195);
$txt = '© The copyright holder of the above Tux image is Larry Ewing, allows anyone to use it for any purpose, provided that the copyright holder is properly attributed. Redistribution, derivative work, commercial use, and all other use is permitted.';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_058.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+
示例2: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 058');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 058', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
// NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library.
//$pdf->setRasterizeVectorImages(true);
$pdf->ImageSVG($file = 'tests/images/testsvg.svg', $x = 15, $y = 30, $w = '', $h = '', $link = 'http://www.tcpdf.org', $align = '', $palign = '', $border = 1, $fitonpage = false);
$pdf->ImageSVG($file = 'tests/images/tux.svg', $x = 30, $y = 100, $w = '', $h = 100, $link = '', $align = '', $palign = '', $border = 0, $fitonpage = false);
$pdf->SetFont('helvetica', '', 8);
$pdf->SetY(195);
$txt = '© The copyright holder of the above Tux image is Larry Ewing, allows anyone to use it for any purpose, provided that the copyright holder is properly attributed. Redistribution, derivative work, commercial use, and all other use is permitted.';
$pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// ---------------------------------------------------------
$this->comparePdfs($pdf);
}
示例3: prepareStockStatusReport
function prepareStockStatusReport($conn)
{
$lan = $_POST['lan'];
if ($lan == 'en-GB') {
$MonthList = array('1' => 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December');
} else {
$MonthList = array('1' => 'Janvier', '2' => 'F�vrier', '3' => 'Mars', '4' => 'Avril', '5' => 'Mai', '6' => 'Juin', '7' => 'Juillet', '8' => 'Ao�t', '9' => 'Septembre', '10' => 'Octobre', '11' => 'Novembre', '12' => 'D�cembre');
}
require_once 'tcpdf/tcpdf.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
$pdf->SetFont('dejavusans', '', 12);
$pdf->AddPage();
ini_set('magic_quotes_gpc', 'off');
$html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
$html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
$alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
$alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
$filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/stock_status.svg';
if (file_exists($filePath)) {
unlink($filePath);
}
$file = fopen($filePath, "w");
fwrite($file, $html);
fclose($file);
$pdf->ImageSVG($file = 'pdfslice/stock_status.svg', $x = 8, $y = 20, $w = 180, $h = '', $link = '', $align = 'left', $palign = 'center', $border = 0, $fitonpage = false);
$html2 = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
</style>
<body>
<div id="barchartlegend">
{$alavel}
</div>
</body>
EOF;
echo $html2;
$pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 0, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'C', $autopadding = true);
$filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/StockStatusChart.pdf';
if (file_exists($filePath)) {
unlink($filePath);
}
$pdf->Output('pdfslice/StockStatusChart.pdf', 'F');
}
示例4: prepareFundingStatusReport
function prepareFundingStatusReport($conn)
{
require_once 'tcpdf/tcpdf.php';
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf = new TCPDF('L', PDF_UNIT, 'Letter', true, 'UTF-8', false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
$pdf->SetFont('dejavusans', '', 7);
$pdf->AddPage($orientation = L, $format = 'Letter', $keepmargins = true, $tocpage = false);
ini_set('magic_quotes_gpc', 'off');
$html = htmlentities($_POST['html'], ENT_QUOTES, "UTF-8");
$html = html_entity_decode($html, ENT_QUOTES, "UTF-8");
$alavel = htmlentities($_POST['alavel'], ENT_QUOTES, "UTF-8");
$alavel = html_entity_decode($alavel, ENT_QUOTES, "UTF-8");
$filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/funding_status.svg';
if (file_exists($filePath)) {
unlink($filePath);
}
$file = fopen($filePath, "w");
fwrite($file, $html);
fclose($file);
$pdf->ImageSVG($file = 'pdfslice/funding_status.svg', $x = 3, $y = 20, $w = 1291, $h = 400, $link = '', $align = '', $palign = 'center', $border = 0, $fitonpage = false);
$html2 = <<<EOF
<!-- EXAMPLE OF CSS STYLE -->
<style>
</style>
<body>
<div id="barchartlegend">
{$alavel}
</div>
</body>
EOF;
echo $html2;
$pdf->writeHTMLCell($w = 150, $h = 30, $x = 15, $y = 130, $html2, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = 'middle', $autopadding = true);
$filePath = SITEDOCUMENT . 'administrator/components/com_jcode/source/report/pdfslice/FundingStatusChart.pdf';
if (file_exists($filePath)) {
unlink($filePath);
}
$pdf->Output('pdfslice/FundingStatusChart.pdf', 'F');
}
示例5: fromSvg
public function fromSvg($svgFile, $outputFile)
{
// Include the main TCPDF library (search for installation path).
require_once dirname(__DIR__) . '/vendor/tcpdf/tcpdf.php';
// create new PDF document
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Bixie');
$pdf->SetTitle('');
$pdf->SetSubject('');
$pdf->SetKeywords('');
// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 058', PDF_HEADER_STRING);
// set header and footer fonts
// $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
// $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(0, 0, 0);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
// NOTE: Uncomment the following line to rasterize SVG image using the ImageMagick library.
//$pdf->setRasterizeVectorImages(true);
$pdf->ImageSVG($svgFile, $x = 0, $y = 0, $w = '', $h = '', $link = '', $align = '', $palign = '', $border = 0, $fitonpage = false);
// $pdf->SetFont('helvetica', '', 8);
// $pdf->SetY(195);
// $txt = '© The copyright holder of the above Tux image is Larry Ewing, allows anyone to use it for any purpose, provided that the copyright holder is properly attributed. Redistribution, derivative work, commercial use, and all other use is permitted.';
// $pdf->Write(0, $txt, '', 0, 'L', true, 0, false, false, 0);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output($outputFile, 'F');
}
示例6: dirname
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
// HTML content
$html = '<div style="text-align:center; color: #33CC33"><h1>Comparaison consommation de deux mois</h1></div>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->ImageSVG($file = 'img/img.svg', $x = 25, $y = 50, $w = '', $link = '', $h = '', $palign = '', $border = 1, $fitonpage = false);
$pdf->Ln(140);
$pdf->lastPage();
//Close and output PDF document
$pdf->Output('Recapitulatif consommation.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
示例7: create_pdf_from_dataurl
public function create_pdf_from_dataurl()
{
if (!isset($_POST['order_id']) || !isset($_POST['data_strings'])) {
exit;
}
check_ajax_referer('fpd_ajax_nonce', '_ajax_nonce');
if (!class_exists('TCPDF')) {
require_once FPD_PLUGIN_ADMIN_DIR . '/inc/tcpdf/tcpdf.php';
}
//register_shutdown_function( array( &$this, 'get_server_errors' ) );
$order_id = trim($_POST['order_id']);
$item_id = trim($_POST['item_id']);
//if memory limit is too small, a fatal php error will thrown here
$data_strings = json_decode(stripslashes($_POST['data_strings']));
$width = trim($_POST['width']);
$height = trim($_POST['height']);
$image_format = trim($_POST['image_format']);
$orientation = trim($_POST['orientation']);
$dpi = isset($_POST['dpi']) ? intval($_POST['dpi']) : 300;
//create fancy product orders directory
if (!file_exists(FPD_ORDER_DIR)) {
wp_mkdir_p(FPD_ORDER_DIR);
}
//create pdf dir
$pdf_dir = FPD_ORDER_DIR . 'pdfs/';
$pdf_path = $pdf_dir . $order_id . '_' . $item_id . '.pdf';
if (!file_exists($pdf_dir)) {
wp_mkdir_p($pdf_dir);
}
//shortcode order
if (empty($item_id)) {
$pdf_dir = FPD_ORDER_DIR . 'pdfs/_shortcode/';
$pdf_path = $pdf_dir . $order_id . '.pdf';
if (!file_exists($pdf_dir)) {
wp_mkdir_p($pdf_dir);
}
}
$pdf = new TCPDF($orientation, 'mm', array($width, $height), true, 'UTF-8', false);
// set document information
$pdf->SetCreator(get_site_url());
$pdf->SetTitle($order_id);
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
foreach ($data_strings as $data_str) {
$pdf->AddPage();
if ($image_format == 'svg') {
if (!class_exists('SVGDocument')) {
require_once FPD_PLUGIN_ADMIN_DIR . '/inc/svglib/svglib.php';
}
//$svg_doc = new SVGDocument($svg_data);
//$svg_doc->asXML($svg_path);
$pdf->ImageSVG('@' . $data_str);
} else {
$data_str = base64_decode(substr($data_str, strpos($data_str, ",") + 1));
$pdf->Image('@' . $data_str, '', '', 0, 0, '', '', '', false, $dpi);
}
}
$pdf->Output($pdf_path, 'F');
$pdf_url = content_url(substr($pdf_path, strrpos($pdf_path, '/fancy_products_orders')));
header('Content-Type: application/json');
echo json_encode(array('code' => 201, 'url' => $pdf_url));
die;
}
示例8: TCPDF
$type = $_POST['type'];
$svg = $_POST['svg'];
// create new PDF document
$pdf = new TCPDF('Landscape', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Loiane Groner');
$pdf->SetTitle('Export Chart');
$pdf->SetSubject('Mastering Ext JS Book');
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
$pdf->setLanguageArray($l);
// ---------------------------------------------------------
// add a page
$pdf->AddPage();
$pdf->ImageSVG($file = '@' . $svg, $x = 10, $y = 10, $w = $width, $h = $height, $link = '', $align = 'T', $palign = 'C', $border = 0, $fitonpage = true);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('chart.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
示例9: foreach
break;
case 'height':
$height = $value;
break;
case 'width':
$width = $value;
break;
case 'angle':
$pdf->Rotate(-$value, $left, $top);
break;
case 'base64':
$base64 = $value;
break;
}
}
$pdf->ImageSVG('@' . $base64, $left, $top, $width, $height, $link = '', $align = '', $palign = '', $border = 0, $fitonpage = false);
$text = false;
}
if ($objects[$i]["type"] == "image") {
foreach ($objects[$i] as $key => $value) {
switch ($key) {
case 'top':
$top = $value;
break;
case 'left':
$left = $value;
break;
case 'height':
$height = $value;
break;
case 'width':
示例10: dirname
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
// HTML content
$html = '<div style="text-align:center; color: #33CC33"><h1> Energie consommée</h1></div>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->ImageSVG($file = 'img/imgEnergie.svg', $x = 25, $y = 70, $w = '', $link = '', $h = '', $palign = '', $border = 1, $fitonpage = false);
$pdf->lastPage();
//add new page
$pdf->AddPage();
$html = '<div style="text-align:center; color: #33CC33"><h1> Intensité soutirée</h1></div>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->ImageSVG($file = 'img/imgIntensite.svg', $x = 25, $y = 70, $w = '', $link = '', $h = '', $palign = '', $border = 1, $fitonpage = false);
//end of page
$pdf->lastPage();
$pdf->AddPage();
$html = '<div style="text-align:center; color: #33CC33"><h1> Tension soutirée</h1></div>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->ImageSVG($file = 'img/imgTension.svg', $x = 25, $y = 70, $w = '', $link = '', $h = '', $palign = '', $border = 1, $fitonpage = false);
$pdf->lastPage();
$pdf->AddPage();
$html = '<div style="text-align:center; color: #33CC33"><h1> Puissance apparente</h1></div>';