Edit SVG file with PHP - php

I want to open and manipulate a SVG graphic with PHP. I found there is a PEAR class XML_SVG. This looks great, but seems to only create new files. I did not find any load_svg() function that loads an existing SVG from file or string.
Is there a way to load an existing SVG file and then manipulate it with Pear XML_SVG?

There is not. I went through all the files.
https://github.com/pear/XML_SVG

Related

Converting DOCX to PDF with PHPWord and DomPDF

I'm running a web only server (So no server access and no things like Composer or LibreOffice) and I want to convert a DOCX template to PDF. I have succesfully processed my template with PHPWord (Downloaded using php-download.com since I can't use composer), everything fine there, but when I try to use DomPDF (also downloaded through phpdownload) to convert my docx file to a PDF file, PHP throws me "Class 'Dompdf\Dompdf' not found"...
I created a seperate file to just convert an already known docx file just to exclude any environmental issues
This is my code:
require_once("includes/PHPWord/vendor/autoload.php");
$inputfile = "files/temp/offerte_Hankie-Pankie.docx";
$path = realpath(realpath(__DIR__) . '/includes/dompdf');
echo "realpath: " . $path;
\PhpOffice\PhpWord\Settings::setPdfRendererPath($path);
\PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF);
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load($inputfile);
//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save('result.pdf');
Using the echo I confirmed the folder is set properly: "/home/myusername/domains/mydomain.nl/public_html/projects/pdftemplate/includes/dompdf"
So i tried parsing the subfolders "src" or "lib" without success, I tried parsing the actual autoloader file "autoload.inc.php" and didn't work either. I tried all of the above paths with and without ending "/" (Just to be sure) and still class not found... Even though I'm using exact copies of code found to be (presumably) working on the internet.
I tried finding it in the PHPWord documentation, which didn't give me any solutions. I also tried excluding PHPWord and just using DomPDF, but since DomPDF only accepts html as input, and I don't know how (And didn't want spend another hour trying that) to convert docx to HTML, this was also a dead end.
Just as a reference, here is my file structure:
Work dir
CodeIsInThisFile.php
includes
dompdf
lib
src
Autoloader.php
autoloader.inc.php
PHPWord
vendor
autoload.php
So either I messed something up in my file structure because of the manual downloads (Which seems the most likely to me), or my code is wrong (Also likely)...
First download the dompdf library using composer or using git.
Use the realpath() or try to use the absolute path for PDF rendering library.

PHP ZipArchive can't read more then 21797 files inside

I need to extract from zip file data.zip only one file for example 188139.xml
File contains folder with more than 88000 files. But after open - it shows me 21797 files and can't open file with big index (which is truly there). But opens 1.xml, 200.xml etc.
So it looks like limitation. Is there any suggestions how to open needed file?
Looks like it a bug of library. Fixed with alternative use of execute() function.

Change working directory in PHP doesn't affect HTML src

I have a php script in a folder "root/test/index.php" which calls another php script located in "root/app/run.php"
In the run.php file I change the php's working directory with a call to chdir to simplify my require_once paths
All the php includes work fine, however HTML paths are totally messed up.
To make my style.css works I have to use a path relative to "root/test/" even if my style.css is in "root/app/".
This works:
<link rel="stylesheet" type="text/css" href="../app/style.css">
and that goes on for all HTML sources like img etc.
How can I change HTML working directory too?
I looked in php/HTML documentation, but I have find no good solution.
Any clue?
Thanks in advance.
HTML don't know anything about the working directory of your PHP script.
The HTML is sent to the client who can't know what was the working directory.
You could add some redirection in an .htaccess file (if you are using apache) to redirect root/test/ to root/app or something like that.
Here is how it works :
You browser ask for /root/test/index.php
Your server handle all his things and then output HTML file
Your browser parse the HTML file
If it find something like that it will search the image here : /root/test/images/cat.png because you are viewing the /root/test/index.php file and you provide a relative path
Add a comment if you have more questions.

Where is PHPExcel.php file located

I want to create an excel file in my phalcon php app. I've downloaded PHPExcel, but I am not able to find where the PHPExcel.php file is located. Could anyone tell me where it is?
You can put the library folder (PHPExcel/Classes/) phalcon_project/app/library/.
To use the class, you must use the method of registerDirs \Phalcon\Loader
See more in create Excel file in Phalcon php framework
In the downloaded zip file PHPExcel_1.7.9_doc.zip, there is a folder called Classes, there you can find PHPExcel.php. You only need to insert the whole Classes folder and include PHPExcel.php for a correct implementation.

Loading Markdownify in CodeIgniter

I downloaded Markdownify from http://milianw.de/projects/markdownify/ and extracted it to my application/libraries/ directory.
I did a:
$this->load->library('markdownify');
echo $this->markdownify->parseString('<b>Test</b>');
But the output is the same html markup. It didn’t work. How do I get it working?
Have you tried renaming it to markdownify_helper.php, place it in your application/helpers/ directory and loading it so:
$this->load->helper('markdownify');

Categories