ConvertApi 3.1.4
dotnet add package ConvertApi --version 3.1.4
NuGet\Install-Package ConvertApi -Version 3.1.4
<PackageReference Include="ConvertApi" Version="3.1.4" />
<PackageVersion Include="ConvertApi" Version="3.1.4" />
<PackageReference Include="ConvertApi" />
paket add ConvertApi --version 3.1.4
#r "nuget: ConvertApi, 3.1.4"
#addin nuget:?package=ConvertApi&version=3.1.4
#tool nuget:?package=ConvertApi&version=3.1.4
ConvertAPI NuGet Package
Overview
The ConvertAPI library provides a simple and efficient way to integrate the ConvertAPI service into your .NET Framework, .NET Core, and .NET projects. ConvertAPI enables you to easily convert various file formats by leveraging its robust API. Whether you need to convert documents, images, spreadsheets, or other file types, the ConvertAPI library streamlines the process with minimal code and maximum efficiency.
Features
Below is an overview of the key functionalities:
Document Conversion
- Office to PDF: Convert Word (DOC, DOCX), Excel (XLS, XLSX), and PowerPoint (PPT, PPTX) documents to PDF or PDF/A formats. Example
- PDF to Office: Transform PDFs into editable Word, Excel, and PowerPoint documents. Example
- HTML/Web to PDF: Convert HTML files or web pages to PDF using a headless Chrome browser. Example
- Image to PDF: Convert various image formats (e.g., JPG, PNG, BMP) to PDF. Example
- PDF to Image: Convert PDFs to image formats such as JPG, PNG, TIFF, SVG, and WebP. Example
- eBook Conversion: Convert DJVU and other eBook formats to PDF or images. Example
- Email Conversion: Convert EML and MSG email files to PDF or image formats. Example
Document Processing & Transformation
- Merge PDF: Combine multiple PDF documents into one PDF. Example
- Split PDF: Split PDF into several parts, by page ranges, patterns, bookmarks and etc. Example
- Rotate: Rotate pages in PDF. Example
- Delete Pages: Remove unwanted pages from PDF. Example
- Watermarking: Add text or image watermarks to PDF and images. Example
- Flatten PDFs: Flatten PDF layers to prevent further editing. Example
- Repair Documents: Recover corrupted or damaged PDF and DOCX files. Example
- Rasterize PDFs: Convert vector PDFs into raster images. Example
Security & Optimization
- Password Protection: Encrypt PDF and Office documents with passwords and AES-256 encryption. Example
- Remove Protection: Unlock password-protected PDFs. Example
- Redact PDF: Automatically detect and redact sensitive information in PDF files using AI. Example
- Compress PDF: Reduce PDF sizes by up to 90% without compromising quality. Example
- PDF/A Conversion: Convert PDFs to PDF/A format for long-term archiving. Example
- Metadata Management: Edit or remove metadata from PDF documents. Example
Data Extraction & OCR
- Text Extraction: Extract text content from PDFs, with optional OCR for scanned documents. Example
- Table Extraction: Extract tabular data from PDFs into CSV or Excel formats. Example
- Image Extraction: Extract images from PDFs into various image formats. Example
- Form Data Extraction: Extract form field data from PDFs into FDF format. Example
- Email Attachments: Extract attachments from EML and MSG email files. Example
Advanced Tools
- Document Generation: Create DOCX or PDF documents dynamically using templates and JSON data. Example
- Format Comparison: Compare DOCX documents to identify differences in content and formatting. Example
- ZIP Archiving: Create ZIP archives from multiple files, with optional password protection. Example
For a complete list of supported conversions and tools, visit the ConvertAPI API Reference.
Compatibility
The ConvertAPI .NET library is compatible with a wide range of platforms that support .NET Standard 2.0+ or .NET Framework 4.0+. Supported environments include:
- .NET Core 5, 6, 7, 8, 9, and above
- .NET Standard 2.0 and above
- .NET Framework 4.0, 4.6.1, 4.7.2, 4.8.1 and above
- Windows, Linux, macOS
- Microsoft Azure, Azure App Service, Azure Functions
- Xamarin (iOS, macOS, Android)
- Universal Windows Platform (UWP)
- Web, Console, and Desktop applications
Installation
Install the ConvertAPI package via NuGet Package Manager:
Install-Package ConvertApi
Or use the .NET CLI:
dotnet add package ConvertApi
Usage
Configuration
Set credentials
You can get your credentials at https://www.convertapi.com/a/authentication
ConvertApi convertApi = new ConvertApi("api_token");
Set conversion location (optional)
You can choose from multiple conversion locations, including the EU API location for GDPR compliance. However, this selection is optional as ConvertAPI automatically detects the nearest server using GEO DNS. For more details, visit ConvertAPI Servers Location.
ConvertApi.ApiBaseUri = "https://v2.convertapi.com";
File conversion
Example to convert file to PDF. All supported formats and options can be found here.
Office to PDF
Convert Word, Excel, and PowerPoint documents to PDF:
var result = await convertApi.ConvertAsync("docx", "pdf",
new ConvertApiFileParam(@"C:\files\document.docx"));
await result.SaveFilesAsync(@"C:\output\");
PDF to Office
Convert PDF to editable Word, Excel, or PowerPoint formats:
var result = await convertApi.ConvertAsync("pdf", "docx",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
HTML/Web to PDF
Convert HTML files or web pages to PDF:
var result = await convertApi.ConvertAsync("web", "pdf",
new ConvertApiParam("Url", "https://example.com"));
await result.SaveFilesAsync(@"C:\output\");
Image to PDF
Convert images (e.g., JPG, PNG) to PDF:
var result = await convertApi.ConvertAsync("jpg", "pdf",
new ConvertApiFileParam(@"C:\files\image.jpg"));
await result.SaveFilesAsync(@"C:\output\");
PDF to Image
Convert PDF to image formats (e.g., JPG, PNG):
var result = await convertApi.ConvertAsync("pdf", "jpg",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
eBook Conversion
Convert eBook formats (e.g., EPUB) to PDF:
var result = await convertApi.ConvertAsync("epub", "pdf",
new ConvertApiFileParam(@"C:\files\book.epub"));
await result.SaveFilesAsync(@"C:\output\");
Email Conversion
Convert EML or MSG email files to PDF:
var result = await convertApi.ConvertAsync("eml", "pdf",
new ConvertApiFileParam(@"C:\files\email.eml"));
await result.SaveFilesAsync(@"C:\output\");
Merge Documents
Merge multiple PDF files into one:
var result = await convertApi.ConvertAsync("pdf", "merge",
new ConvertApiFileParam(@"C:\files\file1.pdf"),
new ConvertApiFileParam(@"C:\files\file2.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Split PDF
Split a PDF into individual pages:
var result = await convertApi.ConvertAsync("pdf", "split",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Rotate Pages
Rotate pages in a PDF document:
var result = await convertApi.ConvertAsync("pdf", "rotate",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("RotatePage", "90"));
await result.SaveFilesAsync(@"C:\output\");
Delete Pages
Delete specific pages from a PDF:
var result = await convertApi.ConvertAsync("pdf", "delete-pages",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("PageRange", "2,4"));
await result.SaveFilesAsync(@"C:\output\");
Add Watermark
Add a text watermark to a PDF:
var result = await convertApi.ConvertAsync("pdf", "watermark",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("Text", "Confidential"));
await result.SaveFilesAsync(@"C:\output\");
Flatten PDF
Flatten a PDF to prevent further editing:
var result = await convertApi.ConvertAsync("pdf", "flatten",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Repair PDF
Repair a corrupted PDF file:
var result = await convertApi.ConvertAsync("pdf", "repair",
new ConvertApiFileParam(@"C:\files\corrupted.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Rasterize PDF
Convert a PDF to a rasterized image:
var result = await convertApi.ConvertAsync("pdf", "rasterize",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Password Protect PDF
Add password protection to a PDF:
var result = await convertApi.ConvertAsync("pdf", "protect",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("UserPassword", "secure123"));
await result.SaveFilesAsync(@"C:\output\");
Remove PDF Password
Remove password protection from a PDF:
var result = await convertApi.ConvertAsync("pdf", "unprotect",
new ConvertApiFileParam(@"C:\files\protected.pdf"),
new ConvertApiParam("Password", "secure123"));
await result.SaveFilesAsync(@"C:\output\");
Redact PDF
Redact sensitive information in a PDF:
var result = await convertApi.ConvertAsync("pdf", "redact",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("Preset", "gdpr"));
await result.SaveFilesAsync(@"C:\output\");
Compress PDF
Compress a PDF file to reduce its size:
var result = await convertApi.ConvertAsync("pdf", "compress",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("Preset", "web"));
await result.SaveFilesAsync(@"C:\output\");
Convert to PDF/A
Convert a PDF to PDF/A format for archiving:
var result = await convertApi.ConvertAsync("pdf", "pdfa",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("PdfaVersion", "pdfa2"));
await result.SaveFilesAsync(@"C:\output\");
Remove Metadata
Remove metadata from a PDF:
var result = await convertApi.ConvertAsync("pdf", "pdf",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("PdfTitle", "' '"),
new ConvertApiParam("PdfSubject", "' '"),
new ConvertApiParam("PdfAuthor", "' '"),
new ConvertApiParam("PdfCreator", "' '"),
new ConvertApiParam("PdfKeywords", "' '"));
await result.SaveFilesAsync(@"C:\output\");
Extract Text from PDF
Extract text content from a PDF:
var result = await convertApi.ConvertAsync("pdf", "txt",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Extract Tables from PDF
Extract tables from a PDF into Excel:
var result = await convertApi.ConvertAsync("pdf", "xlsx",
new ConvertApiFileParam(@"C:\files\document.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Extract Images from PDF
Extract images from a PDF:
var result = await convertApi.ConvertAsync("pdf", "extract-images",
new ConvertApiFileParam(@"C:\files\document.pdf"),
new ConvertApiParam("ImageOutputFormat", "png"));
await result.SaveFilesAsync(@"C:\output\");
Extract Form Data
Extract form data from a PDF:
var result = await convertApi.ConvertAsync("pdf", "fdf-extract",
new ConvertApiFileParam(@"C:\files\form.pdf"));
await result.SaveFilesAsync(@"C:\output\");
Extract Email Attachments
Extract attachments from an email file:
var result = await convertApi.ConvertAsync("email", "extract",
new ConvertApiFileParam(@"C:\files\email.eml"));
await result.SaveFilesAsync(@"C:\output\");
Generate Document from Template
Generate a document from a template using JSON data:
var result = await convertApi.ConvertAsync("template", "pdf",
new ConvertApiFileParam(@"C:\templates\template.docx"),
new ConvertApiParam("BindingMethod", "placeholders"),
new ConvertApiParam("JsonPayload", "[{\"Name\": \"name\", \"Value\": \"John\", \"Type\": \"string\"}]"));
await result.SaveFilesAsync(@"C:\output\");
Compare Documents
Compare two DOCX documents:
var result = await convertApi.ConvertAsync("docx", "compare",
new ConvertApiFileParam(@"C:\files\doc1.docx"),
new ConvertApiFileParam("CompareFile", @"C:\files\doc2.docx"));
await result.SaveFilesAsync(@"C:\output\");
Create ZIP Archive
Create a ZIP archive from multiple files:
var result = await convertApi.ConvertAsync("any", "zip",
new ConvertApiFileParam(@"C:\files\file1.pdf"),
new ConvertApiFileParam(@"C:\files\file2.docx"));
await result.SaveFilesAsync(@"C:\output\");
Other result operations:
// save all result files to folder
result.SaveFilesAsync(@"\result\");
// get result files
ProcessedFile[] files = result.Files;
// get conversion cost
int cost = result.ConversionCost;
Convert file url
ConvertApiResponse result = await convertApi.ConvertAsync("pptx", "pdf",
new ConvertApiFileParam(new Uri("https://cdn.convertapi.com/cara/testfiles/presentation.pptx"))
);
Additional conversion parameters
ConvertAPI accepts extra conversion parameters depending on converted formats. All conversion parameters and explanations can be found here.
ConvertApiResponse result = await convertApi.ConvertAsync("pdf", "jpg",
new ConvertApiFileParam(@"c:\source\test.pdf"),
new ConvertApiParam("ScaleImage","true"),
new ConvertApiParam("ScaleProportions","true"),
new ConvertApiParam("ImageHeight","300"),
new ConvertApiParam("ImageWidth","300")
);
User information
You can always check the remaining conversions amount and other account information by fetching user information.
ConvertApiUser user = await convert.GetUserAsync();
int conversionsTotal = user.ConversionsTotal;
int conversionsConsumed = user.ConversionsConsumed;
More examples
You can find more advanced examples in the examples folder.
Converting your first file, complete example:
ConvertAPI is designed to make converting files super easy. The following snippet shows how easy it is to get started. Let's convert the WORD DOCX file to PDF:
try
{
var convertApi = new ConvertApi("api_token");
var conversionTask = await convertApi.ConvertAsync("docx", "pdf",
new ConvertApiFileParam(@"c:\source\test.docx")
);
var fileSaved = await conversionTask.Files.SaveFilesAsync(@"c:\");
}
//Catch exceptions from asynchronous methods
catch (ConvertApiException e)
{
Console.WriteLine("Status Code: " + e.StatusCode);
Console.WriteLine("Response: " + e.Response);
if (e.StatusCode == HttpStatusCode.Unauthorized)
Console.WriteLine("Secret is not provided or no additional seconds left in the account to proceed conversion. More information https://www.convertapi.com/a");
}
Issues & Comments
Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!
License
The ConvertAPI .NET Library is licensed under the MIT license. Refere to the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.1)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
3.1.4 | 0 | 7/8/2025 |
3.1.3 | 0 | 7/8/2025 |
3.1.2 | 38,324 | 10/15/2024 |
3.1.1 | 18,717 | 8/14/2024 |
3.1.0 | 147 | 8/14/2024 |
3.0.14 | 140,852 | 9/27/2023 |
3.0.14-dev3 | 107 | 8/14/2024 |
3.0.14-dev2 | 112 | 8/14/2024 |
3.0.14-dev | 116 | 8/14/2024 |
3.0.8 | 99,966 | 9/30/2022 |
3.0.7 | 99,971 | 7/30/2021 |
3.0.6 | 6,353 | 11/19/2020 |
3.0.5 | 117,949 | 7/1/2020 |
3.0.4 | 1,241 | 6/10/2020 |
3.0.3 | 5,194 | 3/25/2020 |
3.0.2 | 1,218 | 3/9/2020 |
3.0.1 | 5,683 | 3/5/2020 |
3.0.0 | 27,582 | 12/12/2019 |
2.7.0 | 28,056 | 12/13/2018 |
2.6.0 | 1,467 | 12/13/2018 |
2.5.0 | 3,647 | 11/9/2018 |
2.4.0 | 40,166 | 8/30/2018 |
2.3.0 | 8,577 | 8/20/2018 |
2.2.0 | 1,654 | 8/13/2018 |
2.1.0.5 | 1,744 | 7/20/2018 |
2.1.0.4 | 1,904 | 7/13/2018 |
2.1.0.3 | 1,893 | 6/25/2018 |
2.0.0.2 | 1,727 | 6/19/2018 |
2.0.0 | 1,965 | 5/9/2018 |
1.3.0 | 15,705 | 4/25/2012 |
1.2.0 | 2,337 | 2/10/2012 |
1.1.0 | 4,989 | 2/1/2012 |
Added file parameter overrides to fit Watermark PDF implementation.