tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.11k stars 1.5k forks source link

Huge SVG files parsing error #616

Open Simulator88 opened 1 year ago

Simulator88 commented 1 year ago

Hi all,

When handling huge SVG images, I get the error:

xml_parse(): SVG Error: No memory at line 8

It is a known limitation to xml parser, it could not work with files bigger than 10 mb.

This could be solved by reading the SVG images in chunks, like here, but it is still not implemented. I tried to do it in my own way, but no luck, is there somebody who tried to fix this?

My code:

$fopen = fopen($svgdata, "r"); while($fileContents = fread($fopen, 102410245)) { if (!xml_parse($parser, $fileContents, feof($fopen))) { $error_message = sprintf('SVG Error : %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)); $this->Error($error_message); } }

FIY: $svgdata is now the path to the SVG file.

Thank you.

williamdes commented 1 year ago

Hi @Simulator88 This has nothing to do with the tcpdf project, you should post this on stackoverflow.com