Convert PDF to SVG in PHP
Powerful PowerPoint PHP library for converting PDF to SVG
Convert PDF to SVG in PHP
Need to convert PDF files to SVG programmatically? Using Aspose.Slides for PHP via Java any developer can convert PDF to SVG format with just a few lines of PHP code.
As a modern presentation processing API, Aspose.Slides for PHP creates SVG from PDF quickly. Test the quality of PDF to SVG conversion right in your browser . Aspose PowerPoint PPTX library allows you to convert PDF files to many popular formats.
You can install the library from Composer using the following command:
Console/Terminal
> composer require aspose/slides
How to Convert PDF to SVG in PHP
These are the steps to convert a PDF file to SVG using PHP.
Load PDF file with an instance of Presentation class
Call the
save
method while specifying output file path & SaveFormat.SVG as parametersPDF file will be saved at the specified path
System Requirements
Before running the PHP conversion sample source code, make sure that you have the following prerequisites.
- Install PHP 7, add path to PHP to system
PATH
variable and setallow_url_include
toOn
inphp.ini
file. - Install JRE 8. Set the
JAVA_HOME
enviroment variable as a path to the installed JRE location. - Install Apache Tomcat 8.0 (see more ).
This sample code shows PDF to SVG PHP Conversion
<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");
use aspose\slides\Presentation;
use aspose\slides\SaveFormat;
$pres = new Presentation();
try
{
$pres->getSlides()->removeAt(0);
$pres->getSlides()->addFromPdf("document.pdf");
for ($i = 0; $i < java_values($pres->getSlides()->size()); $i++)
{
$slide = $pres->getSlides()->get_Item($i);
$javafos = new Java("java.io.FileOutputStream", "slide_". $i .".svg");
$slide->writeAsSvg($javafos);
}
}
finally
{
if ($pres != null) $pres->dispose();
}
?>
Save PDF as SVG in PHP
Use the free app to see a demonstration of the PDF to SVG conversion process.Free App to Convert PDF to SVG
Other Supported Conversions
You can also convert PDF to many other file formats. See other supported conversions below