JSON files are commonly used to export, import, or transport data within or between the applications. JSON format requires less formatting and provides a lightweight data storage mechanism. In various cases, you may need to convert the JSON files to PDF for sharing, printing, or other purposes. To achieve it programmatically, this article covers how to convert JSON to PDF via C#.
- C# API to Convert JSON to PDF - Free Download
- Steps to Convert JSON to PDF in C#
- Convert JSON Data to PDF in C#
C# API for JSON to PDF Conversion - Free Download
In order to convert JSON files to PDF format, we will use Aspose.Cells for .NET. It is a powerful API that allows you to generate spreadsheet documents from scratch. In addition, it lets you process and convert existing Excel files from within your .NET applications. You can either download the API or install it using NuGet.
PM> Install-Package Aspose.Cells
How to Convert JSON to PDF in C#
Aspose.Cells for .NET makes it quite easier for you to convert a JSON file to PDF, which can be performed in a couple of steps. The following steps are required to save a JSON file as PDF in C# using Aspose.Cells for .NET.
- Create an Excel file.
- Load data from JSON file into the Excel sheet.
- Set additional conversion options for JSON to PDF.
- Save JSON data as PDF.
The following section demonstrates how to perform the above-mentioned steps for JSON to PDF conversion in C# code.
Convert JSON to PDF in C#
The following are the steps to convert a JSON file to PDF using C#.
- Create an instance of the Workbook class.
- Select the default Worksheet from the Worksheets collection.
- Load JSON data from file using File.ReadAllText(string) method.
- Create an instance of JsonLayoutOptions and set options.
- Import data from JSON to worksheet using JsonUtility.ImportData method with reference to Worksheet object and JSON data.
- Convert JSON to PDF by saving the workbook as PDF using Workbook.Save(string, SaveFormat.Auto) method.
The following code sample shows how to convert a JSON file to PDF in C#.
API to Export JSON to PDF in C# - Get a Free License
You can use Aspose.Cells for .NET without evaluation limitations using a temporary license.
In this article, you have learned how to convert JSON data to PDF via C#. The steps and code sample have demonstrated how to load the JSON data and save it as PDF dynamically in C#. You can use the provided code sample within your .NET, .NET Core, Mono or Xamarin based applications. In addition, you can explore the documentation of Aspose.Cells for .NET. Also, you can post your queries on our forum.