6. Convert to PDF Formats

GroupDocs.Conversion Cloud REST API allows to convert the supported document formats to PDF Formats and returns the output document storage URL and also support to get result as a stream.

Convert to PDF Formats

You can convert the supported document formats to PDF Formats and get output as storage URL.

Resource

The following GroupDocs.Conversion Cloud REST API resource has been used in the convert to PDF format example.

cURL example

curl -X POST "https://api.groupdocs.cloud/v2.0/conversion" -H  "accept: application/json" -H  "authorization: Bearer [Access Token]" -H  "Content-Type: application/json" -d "{  \"Storage\": \"MyStorage\",  \"FilePath\": \"conversions/password-protected.docx\",  \"Format\": \"pptx\",  \"LoadOptions\": {\"DocxLoadOptions\": {\"Password\": \"password\"  }},  \"ConvertOptions\": {\"PdfConvertOptions\": {\"BookmarksOutlineLevel\": \"1\",                        \"CenterWindow\" :\"true\",  \"CompressImages\": \"false\",   \"DisplayDocTitle\":  \"true\", \"Dpi\":\"1024\",  \"ExpandedOutlineLevels\": \"1\",   \"FitWindow\": \"false\",\"FromPage\" \"1\",   \"Grayscale\": \"false\",  \"HeadingsOutlineLevels\": \"1\",   \"ImageQuality\": \"100\",                        \"Linearize\": \"false\",   \"MarginTop\": \"5\",   \"MarginLeft\": \"5\", \"Password\": \"password\",  \"UnembedFonts\": \"true\",  \"RemoveUnusedStreams\": \"true\",  \"RemoveUnusedObjects\": \"true\", \"RemovePdfaCompliance\": \"false\", \"Height\": \"1024\"}  },  \"OutputPath\": \"converted/topdf\"}"
  {
    "name": "sample.pptx",
    "size": 68540,
    "url": "MyStorage:converted/topdf/password-protected.pdf"
  }

SDK examples

The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list here.

Convert to PDF Formats with Stream Output

You can convert the supported document formats to PDF Formats and get output as stream.

Resource

The following GroupDocs.Conversion Cloud REST API resource has been used in the convert to PDF format example.

cURL example

curl -X POST "https://api.groupdocs.cloud/v2.0/conversion" -H  "accept: application/json" -H  "authorization: Bearer [Access Token]" -H  "Content-Type: application/json" -d "{  \"Storage\": \"MyStorage\",  \"FilePath\": \"conversions/password-protected.docx\",  \"Format\": \"pptx\",  \"LoadOptions\": {\"DocxLoadOptions\": {\"Password\": \"password\"  }},  \"ConvertOptions\": {\"PdfConvertOptions\": {\"BookmarksOutlineLevel\": \"1\",                        \"CenterWindow\" :\"true\",  \"CompressImages\": \"false\",   \"DisplayDocTitle\":  \"true\", \"Dpi\":\"1024\",  \"ExpandedOutlineLevels\": \"1\",   \"FitWindow\": \"false\",\"FromPage\" \"1\",   \"Grayscale\": \"false\",  \"HeadingsOutlineLevels\": \"1\",   \"ImageQuality\": \"100\",                        \"Linearize\": \"false\",   \"MarginTop\": \"5\",   \"MarginLeft\": \"5\", \"Password\": \"password\",  \"UnembedFonts\": \"true\",  \"RemoveUnusedStreams\": \"true\",  \"RemoveUnusedObjects\": \"true\", \"RemovePdfaCompliance\": \"false\", \"Height\": \"1024\"}  },  \"OutputPath\": \""}"
File contents

SDK examples

The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list here.

Convert to PDF with Advanced Options

This example demonstrates how to convert word processing documents into pdf documents with advanced conversion options.

There are steps that usage of GroupDocs.Conversion Cloud consists of:

  1. Upload input document into cloud storage
  2. Convert document
  3. Download converted document from storage

Steps 1 and 3 are storage operations, please refer to this GroupDocs.Conversion Cloud Storage Operations for usage details.

Step 3 is not needed if the “OutputPath” option is not provided: the convert API method will return the converted document in the response body.

Resource

HTTP POST ~/conversion

Swagger UI lets you call this REST API directly from the browser.

cURL example


# First get JSON Web Token
# Please get your Client Id and Client Secret from https://dashboard.groupdocs.cloud/applications. Kindly place Client Id in "client_id" and Client Secret in "client_secret" argument.
curl -v "https://api.groupdocs.cloud/connect/token" \
-X POST \
-d "grant_type#client_credentials&client_id#xxxx&client_secret#xxxx" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

# cURL example to convert document
curl -v "https://api.groupdocs.cloud/v2.0/conversion/conversion" \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer <jwt token>"
-d "{
        'FilePath': 'WordProcessing/password-protected.docx',
        'Format': 'pdf',
        'LoadOptions': {'Password': 'password'},
        'ConvertOptions': {
            'FromPage': 1,
            'Dpi': 1024,
            'UnembedFonts': true
        },
        'OutputPath': 'Output'
    }"

[
  {
    "name": "password-protected.pdf",
    "size": 4434,
    "path": "Output/password-protected.pdf",
    "url": "https://api.groupdocs.cloud/v2.0/conversion/storage/file/Output/password-protected.pdf"
  }
]

SDK examples

The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list here.