XBRL (eXtensible Business Reporting Language) file provides digital business reporting to exchange business information. It provides a way to communicate business and financial data such as balance sheets, cash flow statements, ledgers, etc. In various cases, we may need to extract and share XBRL data in PDF format. In this article, we will learn how to convert XBRL to PDF using C#.
The following topics shall be covered in this article:
C# API to Convert XBRL to PDF
For converting XBRL to PDF documents, we will follow a two-step procedure. Firstly, we will be using the Aspose.Finance for .NET to convert XBRL to XLSX, and then we will convert the XLSX to a PDF document using Aspose.Cells for .NET APIs. Please either download the DLLs of the APIs or install them using NuGet.
PM> Install-Package Aspose.Finance PM> Install-Package Aspose.Cells
Convert XBRL to PDF in C#
We can easily convert the XBRL file (.xbrl) to a PDF document by following the steps given below:
- Firstly, load the XBRL file using the XbrlDocument class.
- Next, create an instance of the SaveOptions class and set the SaveFormat as XLSX.
- Then, convert XBRL to XLSX and save in a FileStream object using XbrlDocument.Save() method.
- After that, open the XLSX FileStream object using the Workbook class.
- Finally, call the Workbook.Save() method to save the document in PDF format. It takes the output file path and the SaveFormat type (PDF) as arguments.
The following code sample demonstrates how to convert XBRL to a PDF using C#.
Convert XBRL XML to PDF using C#
We can also convert the XBRL data from an XML file (.xml) to a PDF document by following the steps mentioned earlier. However, we just need to input the .xml file instead of the .xbrl file in the first step.
The following code sample demonstrates how to convert an XML file to a PDF document using C#.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
In this article, we have learned how to convert an XBRL file to a PDF document. We have also seen how to save XBRL data from an XML file to a PDF document programmatically. Besides, you can learn more about Aspose.Finance for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.