2017-10-09 6 views
0

J'ai un fichier SVG.J'essaie de télécharger en format PDF en utilisant TCPDF. SVG est en train de convertir en PDF s'il n'y a pas # dans le fichier SVG.Le problème est le fichier "#". S'il vous plaît me suggérer ce qu'il faut faire.La variable SVG affiche un index non défini lors de la conversion au format PDF en utilisant TCPDF

canvas.svg:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1140" height="600" viewBox="0 0 1140 600" xml:space="preserve"> 
<desc>Created with Fabric.js 1.7.17</desc> 
<defs> 
</defs> 
<rect x="0" y="0" width="1140" height="600" fill="#ffffff"></rect> 
<g clip-path="url(#clipCircle)"> 
<image xlink:href="http://localhost/canvas/560.jpg" x="-235" y="-280" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" width="470" height="560" preserveAspectRatio="none" transform="translate(235 280)"></image> 
</g> 
<clipPath id="clipCircle"><rect x="50" y="120" width="670" height="320" rx="40" ry="40"></rect></clipPath></svg> 

pdf.php:

Ceci est le fichier que j'utilise pour télécharger le fichier au format PDF.

require_once('tcpdf_include.php'); 

// create new PDF document 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
$pdf->SetPrintHeader(false); 
$pdf->SetPrintFooter(false); 
$pdf->SetMargins(10, 10, 10, true); 
// set font 
$pdf->SetFont('helvetica', '', 10); 

// add a page 
$pdf->AddPage(); 



$pdf->ImageSVG($file='images/canvas.svg', $x=30, $y=100, $w='', $h=100, $link='', $align='', $palign='', $border=0, $fitonpage=false); 


//Close and output PDF document 
$pdf->Output('canvasoutput.pdf', 'D'); 

Erreur:

Notice: Undefined index: clipCircle dans D: \ xampp \ htdocs \ toile \ TCPDF \ tcpdf.php en ligne 23043

Attention: Invalid argument supplied for foreach() dans D: \ xampp \ htdocs \ canvas \ TCPDF \ tcpdf.php sur la ligne 23044 TCPDF ERREUR: certaines données ont déjà été émises, impossible d'envoyer le fichier PDF

Répondre

0

Le fichier svg fonctionne dans la page Web mais n'a pas quand je convertis en PDF.J'ai trouvé le problème. En fait clipPath devrait être inclus dans defs. C'est la solution préférée. Elle fonctionne également dans TCPDF.

canvas.svg:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1140" height="600" viewBox="0 0 1140 600" xml:space="preserve"> 
<desc>Created with Fabric.js 1.7.17</desc> 
<defs> 
//added Here 
<clipPath id="clipCircle"><rect x="50" y="120" width="670" height="320" rx="40" ry="40"></rect></clipPath> 
</defs> 
<rect x="0" y="0" width="1140" height="600" fill="#ffffff"></rect> 
<g clip-path="url(#clipCircle)"> 
<image xlink:href="http://localhost/canvas/560.jpg" x="-235" y="-280" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" width="470" height="560" preserveAspectRatio="none" transform="translate(235 280)"></image> 
</g> 
</svg>