convert json to pdf

How to convert JSON to PDF with .NET Cloud SDK.

JSON with its ubiquity in modern data interchange, provides a flexible and lightweight structure for representing information. Similarly, the PDF is renowned for its universal accessibility and consistent layout, offers a stable and visually appealing representation for sharing, printing, and archival purposes. However, there arises a crucial juncture where the dynamic and nested data of JSON needs to transcend its digital form and manifest in a more tangible, standardized format. This is where the imperative for JSON to PDF conversion emerges.

In this article, we explore the pressing need for this conversion, dissecting the intricacies of how it not only bridges the gap between these two formats, but also empowers you to elevate their data visualization practices to new heights.

JSON to PDF Conversion REST API

The conversion of JSON to PDF is at your fingertips with the robust capabilities of Aspose.Cells Cloud SDK for .NET. This versatile SDK empowers developers to seamlessly integrate and streamline the conversion process, ensuring that JSON data transforms into polished and professional PDF documents with precision.

In order to leverage the capabilities of this SDK in .NET application, first we need to search Aspose.Cells-Cloud in NuGet packages manager and click the Add Package button. Secondly, obtain your client credentials from cloud dashboard. If you do not have an existing account, simply create a free account by following the instructions specified in the quick start article.

Convert JSON to PDF in C# .NET

The intuitive API calls leverage the power of Aspose.Cells Cloud to handle complex JSON structures and efficiently render them into visually appealing PDFs. In this section, we are going to convert the JSON to PDF using C# .NET.

CellsApi cellsInstance = new CellsApi(clientID, clientSecret);

Create an object of CellsApi class where we pass client credentials as arguments.

using (var file = System.IO.File.OpenRead(input_JSON))

Read the input JSON into stream instance.

cellsInstance.CellsWorkbookPutConvertWorkbook(file, format: "PDF", outPath: resultant_file);

Finally, call the API to convert JSON to PDF and upload the resultant file to cloud storage.

json to pdf online

A preview of JSON to PDF conversion.

The input Excel workbook and the resultant JSON file generated above can be downloaded from:

JSON to PDF Online using cURL Commands

The JSON to PDF conversion can also be simplified through the powerful combination of Aspose.Cells Cloud and cURL commands. By harnessing cURL, you can interact seamlessly with the Aspose.Cells Cloud API, initiating the conversion process effortlessly. This method not only offers the flexibility to integrate into various development environments but also guarantees a consistent and reliable process for JSON to PDF conversion.

The first step in this approach is to generate a JWT access token using the following command:

curl -v "https://api.aspose.cloud/connect/token" \
 -X POST \
 -d "grant_type=client_credentials&client_id=921363a8-b195-426c-85f7-7d458b112383&client_secret=2bf81fca2f3ca1790e405c904b94d233" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Please execute the following command to convert the JSON to PDF format. The following request requires the input JSON to be already available in the cloud storage.

curl -v "https://api.aspose.cloud/v3.0/cells/{sourceFile}?format=JSON&isAutoFit=true&onlySaveTable=true&outPath={output}&checkExcelRestriction=true" \
-X GET \
-H  "accept: application/json" \
-H  "authorization: Bearer {accessToken}" \
-d {}

Replace sourceFile with the name of source JSON, output with the name of resultant PDF file and accessToken with a JWT access token generated above.

Conclusion

In conclusion, the dynamic landscape of data transformation accommodates two powerful approaches to convert JSON to PDF, using the feature-rich Aspose.Cells Cloud SDK for .NET and the scriptable efficiency of cURL commands. Whether you opt for the comprehensive toolkit and granular control offered by Aspose.Cells Cloud SDK, or the simplicity and cross-platform compatibility of cURL commands. Nonetheless, both approaches provide a seamless transformation of JSON data into polished and universally accessible PDF documents.

We highly recommend visiting the following blogs: