Hi, I recently experienced problems when creating pdf files from html content using the CLI. My goal would be to create pdf with a cron job (within a task) and to test my application. I have found a solution and I tried to post it to symfony TRAC, but there is no section dedicated to the plugin. So, I post my message here.
The problem arises when the html contains images. tcpfd- >openHTMLTagHandler() treats this case at lines 20964-21068. If the html provides a relative path for the image, the function tries to add $_SERVER['DOCUMENT_ROOT'], which is not available in CLI. If the link is a full http path, the function replaces (line 20978) K_PATH_URL with K_PATH_MAIN. The problem is that K_PATH_MAIN is realtive to the plugin's root (my_project/plugins/sfTCPdfPlugin), but my images are in my_project/web/images. So, the replacement won't work and the image cannot be found by tcpdf. My suggestion is to add a new K_PATH_URL_IMAGES constant, which defines the url of the images folder. Then, it is possible to change line 20978 in tcpdf.php to: $tag['attribute']['src'] = str_replace(K_PATH_URL_IMAGES, K_PATH_IMAGES, $tag['attribute']['src']); This way, one can define the real path to the images folder in the pdf_configs.yml and use the image_tag() helper with a full path when putting images in the html. With this solution I have been able to successfully create pdfs from the CLI. If the administrator (thanks COil) creates a sfTCPdfPlugin section in the TRAC, I will post my patch. Thanks, Raffaele -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en