projects
/
pear
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8fe4baf
)
fix svgtopdf
author
Alan
<alan@roojs.com>
Tue, 27 Feb 2024 09:11:47 +0000
(17:11 +0800)
committer
Alan
<alan@roojs.com>
Tue, 27 Feb 2024 09:11:47 +0000
(17:11 +0800)
FpdfAlt.php
patch
|
blob
|
history
FpdfAlt/Chinese.php
patch
|
blob
|
history
XML/SvgToPdfAlt.php
patch
|
blob
|
history
XML/SvgToPdfAlt/G.php
patch
|
blob
|
history
XML/SvgToPdfAlt/Text.php
patch
|
blob
|
history
XML/SvgToPdfAlt/Tspan.php
patch
|
blob
|
history
diff --git
a/FpdfAlt.php
b/FpdfAlt.php
index
5886633
..
2aa0b90
100644
(file)
--- a/
FpdfAlt.php
+++ b/
FpdfAlt.php
@@
-484,7
+484,7
@@
function Rect($x,$y,$w,$h,$style='')
\r
function AddFont($family,$style='',$file='')
\r
{
\r
\r
function AddFont($family,$style='',$file='')
\r
{
\r
- //Add a TrueType or Type1 font
\r
+ //
var_dump(array($family, $style, $file));//
Add a TrueType or Type1 font
\r
$family=strtolower($family);
\r
if($family=='arial')
\r
$family='helvetica';
\r
$family=strtolower($family);
\r
if($family=='arial')
\r
$family='helvetica';
\r
diff --git
a/FpdfAlt/Chinese.php
b/FpdfAlt/Chinese.php
index
909e06b
..
adcd675
100644
(file)
--- a/
FpdfAlt/Chinese.php
+++ b/
FpdfAlt/Chinese.php
@@
-111,7
+111,7
@@
class FpdfAlt_Chinese extends FpdfAlt
$c=$s[$i];
if(ord($c)<128)
{
$c=$s[$i];
if(ord($c)<128)
{
- $l+=
$cw[$c]
;
+ $l+=
isset($cw[$c]) ? $cw[$c] : 0
;
$i++;
}
else
$i++;
}
else
@@
-320,7
+320,8
@@
class FpdfAlt_Chinese extends FpdfAlt
function _putfonts()
{
function _putfonts()
{
- $nf=$this->n;
+ print_R($this->fonts);
+ $nf=$this->n;
foreach($this->diffs as $diff)
{
//Encodings
foreach($this->diffs as $diff)
{
//Encodings
@@
-328,6
+329,8
@@
class FpdfAlt_Chinese extends FpdfAlt
$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
$this->_out('endobj');
}
$this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>');
$this->_out('endobj');
}
+
+
foreach($this->FontFiles as $file=>$info)
{
//Font file embedding
foreach($this->FontFiles as $file=>$info)
{
//Font file embedding
@@
-336,6
+339,7
@@
class FpdfAlt_Chinese extends FpdfAlt
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
$size=filesize($file);
if(defined('FPDF_FONTPATH'))
$file=FPDF_FONTPATH.$file;
$size=filesize($file);
+
if(!$size)
$this->Error('Font file not found');
$this->_out('<</Length '.$size);
if(!$size)
$this->Error('Font file not found');
$this->_out('<</Length '.$size);
@@
-389,7
+393,7
@@
class FpdfAlt_Chinese extends FpdfAlt
$this->_out('endobj');
if($font['type']!='core')
{
$this->_out('endobj');
if($font['type']!='core')
{
- //Widths
+
//Widths
$this->_newobj();
$cw=&$font['cw'];
$s='[';
$this->_newobj();
$cw=&$font['cw'];
$s='[';
@@
-409,7
+413,7
@@
class FpdfAlt_Chinese extends FpdfAlt
$this->_out('endobj');
}
}
$this->_out('endobj');
}
}
- }
+ }
}
function _putType0($font)
}
function _putType0($font)
@@
-452,4
+456,3
@@
class FpdfAlt_Chinese extends FpdfAlt
$this->_out('endobj');
}
}
$this->_out('endobj');
}
}
-?>
diff --git
a/XML/SvgToPdfAlt.php
b/XML/SvgToPdfAlt.php
index
f71ece2
..
de9498f
100644
(file)
--- a/
XML/SvgToPdfAlt.php
+++ b/
XML/SvgToPdfAlt.php
@@
-92,9
+92,9
@@
class XML_SvgToPDFAlt {
);
$tree = $x->getTreeFromFile();
);
$tree = $x->getTreeFromFile();
-
- //echo '<PRE>'.htmlspecialchars(print_r($tree,true));exit;
+
+ ///echo '<PRE>'.htmlspecialchars(print_r($tree,true));exit;
$tree = $t->buildobject($tree);
//echo '<PRE>'.htmlspecialchars(print_r($tree,true));
$tree = $t->buildobject($tree);
//echo '<PRE>'.htmlspecialchars(print_r($tree,true));
@@
-133,6
+133,7
@@
class XML_SvgToPDFAlt {
$pdf->addPage();
$tree->writePDF($pdf,$data);
$t->debug($tree);
$pdf->addPage();
$tree->writePDF($pdf,$data);
$t->debug($tree);
+
return $pdf;
}
return $pdf;
}
@@
-161,7
+162,7
@@
class XML_SvgToPDFAlt {
$tree->writePDF($pdf,$page_data);
}
$tree->writePDF($pdf,$page_data);
}
- $t->debug($tree);
+ $t->debug($tree
, true
);
return $pdf;
}
return $pdf;
}
diff --git
a/XML/SvgToPdfAlt/G.php
b/XML/SvgToPdfAlt/G.php
index
32ed5a1
..
16c36ed
100644
(file)
--- a/
XML/SvgToPdfAlt/G.php
+++ b/
XML/SvgToPdfAlt/G.php
@@
-21,7
+21,7
@@
class XML_SvgToPDFAlt_G extends XML_SvgToPDFAlt_Base {
$isDynamic = false;
foreach(array_keys($this->children) as $k) {
$isDynamic = false;
foreach(array_keys($this->children) as $k) {
- if (!is_a($this->children[$k], 'XML_SvgToPDF_Text')) {
+ if (!is_a($this->children[$k], 'XML_SvgToPDF
Alt
_Text')) {
continue;
}
continue;
}
@@
-51,7
+51,7
@@
class XML_SvgToPDFAlt_G extends XML_SvgToPDFAlt_Base {
//look for the bounding box..
$boundingbox = false;
foreach(array_keys($this->children) as $k) {
//look for the bounding box..
$boundingbox = false;
foreach(array_keys($this->children) as $k) {
- if (!is_a($this->children[$k], 'XML_SvgToPDF_Rect')) {
+ if (!is_a($this->children[$k], 'XML_SvgToPDF
Alt
_Rect')) {
continue;
}
if (@$this->children[$k]->nonprintable == 'true') {
continue;
}
if (@$this->children[$k]->nonprintable == 'true') {
@@
-128,12
+128,12
@@
class XML_SvgToPDFAlt_G extends XML_SvgToPDFAlt_Base {
$kmax = count($keys);
//XML_SvgToPDF::debug(array($x,$y,$w,$h));
//XML_SvgToPDF::debug($keys);
$kmax = count($keys);
//XML_SvgToPDF::debug(array($x,$y,$w,$h));
//XML_SvgToPDF::debug($keys);
- XML_SvgToPDF::debug($this->settings);
+ XML_SvgToPDF
Alt
::debug($this->settings);
for($r=0;$r<$this->settings['rows'];$r++) {
$yy = $y + ($r*$h);
for($c=0;$c<$this->settings['cols'];$c++) {
$xx = $x + ($c*$w);
for($r=0;$r<$this->settings['rows'];$r++) {
$yy = $y + ($r*$h);
for($c=0;$c<$this->settings['cols'];$c++) {
$xx = $x + ($c*$w);
- XML_SvgToPDF::debug(array($xx,$yy));
+ XML_SvgToPDF
Alt
::debug(array($xx,$yy));
foreach(array_keys($this->children) as $k) {
if (!$this->children[$k]) {
continue;
foreach(array_keys($this->children) as $k) {
if (!$this->children[$k]) {
continue;
diff --git
a/XML/SvgToPdfAlt/Text.php
b/XML/SvgToPdfAlt/Text.php
index
e617646
..
a26e9b7
100644
(file)
--- a/
XML/SvgToPdfAlt/Text.php
+++ b/
XML/SvgToPdfAlt/Text.php
@@
-110,7
+110,7
@@
class XML_SvgToPDFAlt_Text extends XML_SvgToPDFAlt_Base {
$xx = isset($c->x) ? $c->x + @$this->xx : $x;
$yy = isset($c->y) ? $c->y + @$this->yy : $y + ($lineno * $size * 1.3);
$lineno++;
$xx = isset($c->x) ? $c->x + @$this->xx : $x;
$yy = isset($c->y) ? $c->y + @$this->yy : $y + ($lineno * $size * 1.3);
$lineno++;
- $val =
@$c->content
;
+ $val =
isset($c->content) ? $c->content : ''
;
if (isset($c->args)) {
if (isset($c->args)) {
@@
-131,7
+131,7
@@
class XML_SvgToPDFAlt_Text extends XML_SvgToPDFAlt_Base {
$val = vsprintf($val,$args);
$val = vsprintf($val,$args);
-
if ($has_template && ($font == 'Big5')) {
+ if ($has_template && ($font == 'Big5')) {
require_once 'Text/ZhDetect.php';
$detect = new Text_zhDetect;
$type = $detect->guess($val);
require_once 'Text/ZhDetect.php';
$detect = new Text_zhDetect;
$type = $detect->guess($val);
@@
-142,12
+142,14
@@
class XML_SvgToPDFAlt_Text extends XML_SvgToPDFAlt_Base {
$weight,
$size);
} else {
$weight,
$size);
} else {
+ $vv = $val;
$val = @iconv('utf8', 'BIG5//IGNORE', $val);
$val = @iconv('utf8', 'BIG5//IGNORE', $val);
+ //var_dump(array($vv, $val));
$pdf->setFont('Big5' ,
$weight,
$size);
}
$pdf->setFont('Big5' ,
$weight,
$size);
}
- }
+
}
/*
/*
@@
-165,14
+167,12
@@
class XML_SvgToPDFAlt_Text extends XML_SvgToPDFAlt_Base {
}
$talign = $align;
}
$talign = $align;
- if ((
!@$this->children[$i+1] || !strlen(trim(@
$this->children[$i+1]->content))) && ($align == 'J')) {
+ if ((
empty($this->children[$i+1]) || !isset($this->children[$i+1]->content) || !strlen(trim(
$this->children[$i+1]->content))) && ($align == 'J')) {
$talign = 'L';
}
$talign = 'L';
}
-
-
-
+
@@
-288,7
+288,7
@@
class XML_SvgToPDFAlt_Text extends XML_SvgToPDFAlt_Base {
function multiLine(&$pdf,$lines,$x,$y,$h,$align) {
// now dealing with mm
function multiLine(&$pdf,$lines,$x,$y,$h,$align) {
// now dealing with mm
- XML_SvgToPDFAlt::debug("MULTILINE
" .implode("\n",$lines) . "
$x, $y, $h");
+ XML_SvgToPDFAlt::debug("MULTILINE
'" .implode("\n",$lines) . "'
$x, $y, $h");
$yoffset = 0;
$line = -1;
foreach ($lines as $l=>$v) {
$yoffset = 0;
$line = -1;
foreach ($lines as $l=>$v) {
diff --git
a/XML/SvgToPdfAlt/Tspan.php
b/XML/SvgToPdfAlt/Tspan.php
index
4e217fb
..
bb48c4f
100644
(file)
--- a/
XML/SvgToPdfAlt/Tspan.php
+++ b/
XML/SvgToPdfAlt/Tspan.php
@@
-26,12
+26,15
@@
class XML_SvgToPDFAlt_Tspan extends XML_SvgToPDFAlt_Base {
$this->content = preg_replace_callback(
'/&#(\d+);/m',
$this->content = preg_replace_callback(
'/&#(\d+);/m',
- function($m) { return chr($m[1]); } ,$this->content);
+ function($m) {
+
+ return mb_chr($m[1]);
+ } ,$this->content);
}
if (@$node->language) {
// todo - other conversions....
}
if (@$node->language) {
// todo - other conversions....
- $this->content = mb_convert_encoding($this->content,'BIG-5','UTF-8');
+
//
$this->content = mb_convert_encoding($this->content,'BIG-5','UTF-8');
}
}