Output encoding
Control how the PDF is encoded in the API response by specifying binary or base64 format
The output_encoding
parameter allows you to specify how the PDF should be encoded in the API response.
Overview
When rendering a PDF synchronously, you can choose how the generated PDF is encoded in the response. The output_encoding
parameter lets you specify whether to return raw binary data or a base64-encoded string.
Parameter Details
Specifies how the PDF should be encoded in the API response
Available options: binary
, base64
Usage
Behavior
binary
: Returns the PDF as raw binary data in the response body. This is the default behavior.base64
: Returns the PDF as a base64-encoded string in the response body.
Use Cases
This parameter is particularly useful for:
-
Direct downloads: Use
binary
when you want to directly download or stream the PDF to the client. -
API integration: Use
base64
when integrating with systems that expect base64-encoded data or when you need to include the PDF in a JSON response. -
Browser compatibility: Use
base64
when working with JavaScript in browsers where handling binary data might be challenging.
Example
Binary Response Handling (Node.js)
Base64 Response Handling (JavaScript)
Never include your API key directly in client-side code as it can be exposed to users. Always use a backend service to make API calls that require authentication.