Convert SVG to PDF – Cloud SDKs and REST API


PDF is a static document format that supports text, images, form fields, media, digital signatures, hyperlinks, etc. Converting SVG to PDF preserves the original layout and formatting, allowing for offline access, sharing, and printing. PDF files maintain the visual integrity of SVG content, making them suitable for viewing on various devices without an Internet connection. PDFs’ extensive interoperability and security features enhance document sharing and protection of sensitive information.

Converting SVG to PDF leverages PDF’s strengths as a versatile, secure, and universally accepted document format while maintaining SVG’s high-quality vector graphics. Aspose.HTML Cloud v4.0 offers a simple API for fast, high-quality conversion of SVG documents to PDF format.

The article explains in a set of code examples how to convert an SVG document to PDF using Aspose.HTML Cloud client SDKs and REST API. SDKs are available in PHP, C++, Python, C#, Ruby, Java, Android, Swift, and Node.js. We will consider various scenarios of SVG to PDF conversion:

  • Converting a local SVG file to PDF and saving the result in your local file system. In this scenario, we will explore both conversions with default conversion parameters and with explicitly specified parameters.
  • Converting SVG to PDF in cloud storage with default conversion parameters.

Examples of SVG to PDF Conversion

A common use case for Aspose.HTML Cloud SDK functions is file processing and conversion. The Cloud SDK enables you to retrieve an SVG document from storage by its name or from a local file on your drive, convert it to a specified format, and save it back to storage or your local drive. The following code examples demonstrate how to convert SVG to PDF using various SDKs and cURL for different scenarios.

Example 1. Convert SVG to PDF with default save options

Here’s an example of converting a local SVG file to a PDF and saving the result to the local file system using default conversion options.

SVG to PDF conversion occurs with the default conversion options: the resulting PDF document’s width and height correspond to A4, and all margins have zero value.

Example 2. Convert SVG to PDF with explicitly specified options

The example below demonstrates how to convert an SVG file from a local file system to PDF with explicitly specified options and save the result back to the local file system.

More details about available conversion parameters for SVG files are in the SDK Conversion Options article.

Example 3. Convert SVG to PDF inside cloud storage

Aspose.HTML Cloud lets you retrieve an SVG file from your cloud storage, convert it, and save the result back to cloud storage. The conversion occurs with default conversion options.

See Also