I tried to convert my SVG files to PDF files on Windows Server with a software, but it moves some sub-graphics randomly, and it makes some lines shorter in the output PDF. So it's output is useless, because the graphics looks completely different.
I tried opening the SVG in Google Chrome and printing it to PDF, but it distorts all the colors, and it also removes some elements. (The SVG appears fine on screen, but it's already bad in the print preview and the generated PDF is also bad.)
I don't want to rasterize or render the SVG. A solution which converts the SVG to a bitmap image and then creates a PDF with the image embedded is not an answer to my question.
What other options do I have?
Customer
--------------------------------
Thanks for your message, VeryUtils has a SVG to PDF Converter Command Line software, this software supports Windows system, it does convert SVG files to vector PDF files, you can integrate it into your web applications easily on your Windows Server. You may download it from this web page to try,
https://veryutils.com/svg-to-pdf-converter-command-line
After you download it, you can run following command lines to convert your SVG files to PDF files,
svg2pdf.exe -$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d _verypdf001.pdf verypdf001.svg
svg2pdf.exe -$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d _verypdf002.pdf verypdf002.svg
svg2pdf.exe -$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d _verypdf003.pdf verypdf003.svg
svg2pdf.exe -$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d _verypdf004.pdf verypdf004.svg
"XXXX-XXXX-XXXX-XXXX" is your trial license key, after you purchase the software, you will get a license key, please use that license key to replace the trial license key, the demo watermark will be removed from generated PDF files.
You can call svg2pdf.exe from PHP source code easily with shell_exec() function, for example,
<?php
// Use ls command to shell_exec
// function
$output = shell_exec('D:\\VeryUtils\\svg2pdf.exe -$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d D:\\VeryUtils\\output.pdf D:\\VeryUtils\\input.svg');
// Display the output message
echo "<pre>$output</pre>";
?>
You may also call svg2pdf.exe from your C# source code to convert SVG files to PDF files, for example,
using System.Diagnostics;
class Program
{
static void Main()
{
LaunchCommandLineApp();
}
static void LaunchCommandLineApp()
{
// Part 1: use ProcessStartInfo class.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "D:\\VeryUtils\\svg2pdf.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Part 2: set arguments.
startInfo.Arguments = "-$ XXXX-XXXX-XXXX-XXXX -dpi 72 -d D:\\VeryUtils\\output.pdf D:\\VeryUtils\\input.svg";
try
{
// Part 3: start with the info we specified.
// ... Call WaitForExit.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
}
If you encounter any problem with VeryUtils SVG to PDF Converter Command Line software, please feel free to let us know, we are glad to assist you asap.