
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
ConvertAPI for .NET — one call to turn Office files into PDF or back again (DOCX ⇄ PDF, XLSX ⇄ PDF, PPTX ⇄ PDF). Convert HTML, images, ebooks, email, zip; merge, split, watermark, compress, OCR, redact, protect or repair PDF. Async, cross-platform, .NET Standard 2.0+ / .NET Core 5-9
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.
Below is an overview of the key functionalities:
For a complete list of supported conversions and tools, visit the ConvertAPI API Reference.
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:
Install the ConvertAPI package via NuGet Package Manager:
Install-Package ConvertApi
Or use the .NET CLI:
dotnet add package ConvertApi
You can get your credentials at https://www.convertapi.com/a/authentication
ConvertApi convertApi = new ConvertApi("api_token");
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";
Example to convert file to PDF. All supported formats and options can be found here.
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\");
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\");
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\");
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\");
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\");
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\");
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 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 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 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 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 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 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 a corrupted PDF file:
var result = await convertApi.ConvertAsync("pdf", "repair",
new ConvertApiFileParam(@"C:\files\corrupted.pdf"));
await result.SaveFilesAsync(@"C:\output\");
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\");
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 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 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 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 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 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 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 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 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 from a PDF:
var result = await convertApi.ConvertAsync("pdf", "fdf-extract",
new ConvertApiFileParam(@"C:\files\form.pdf"));
await result.SaveFilesAsync(@"C:\output\");
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 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 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 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\");
// save all result files to folder
result.SaveFilesAsync(@"\result\");
// get result files
ProcessedFile[] files = result.Files;
// get conversion cost
int cost = result.ConversionCost;
ConvertApiResponse result = await convertApi.ConvertAsync("pptx", "pdf",
new ConvertApiFileParam(new Uri("https://cdn.convertapi.com/cara/testfiles/presentation.pptx"))
);
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")
);
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;
You can find more advanced examples in the examples folder.
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");
}
Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!
The ConvertAPI .NET Library is licensed under the MIT license. Refere to the LICENSE file for more information.
FAQs
ConvertAPI for .NET — one call to turn Office files into PDF or back again (DOCX ⇄ PDF, XLSX ⇄ PDF, PPTX ⇄ PDF). Convert HTML, images, ebooks, email, zip; merge, split, watermark, compress, OCR, redact, protect or repair PDF. Async, cross-platform, .NET Standard 2.0+ / .NET Core 5-9
We found that convertapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.