Watermark
Watermark PDF files - stamp a PDF with the text, image, or another fileExplore the product
The ConvertAPI C# Client offers a simple and efficient way to integrate powerful file conversion capabilities into your .NET Framework, .NET Core, and .NET projects. With support for a wide range of formats, it allows you to seamlessly convert documents, images, spreadsheets, and more. Additionally, the library provides advanced PDF manipulations such as redacting, merging, encrypting, splitting, repairing, and decrypting files.
It is easy to start converting documents using C# in a few simple steps:
Sign up for free and receive 250 conversions to try and evaluate our service. You will receive a free trial with no credit card required upon registration!
On your account dashboard you will access an intuitive UI tool that allows you to set up the conversion, adjust the parameters, and try the conversion online with zero code.
Once you have set up the conversion parameters and are happy with the conversion results, you will receive an auto-generated C# code snippet with your custom parameters!
High-performance and unbeatable accuracy document converter suite with support for over 300+ conversion.
Generate dynamic DOCX and PDF documents like invoices, contracts, reports, on the fly.
Protect, redact, compare, watermark, flatten, compress and modify your documents using ConvertAPI .NET SDK.
Protect and unprotect PDFs, MS Office Powerpoint and MS Office Word documents.
Built to scale with your business, whether you're handling a few conversions or thousands.
Reduce file sizes without losing quality. Archive converters are designed to handle over 100 different file formats.
Configure your file conversion directly online using our intuitive interface. Select the desired parameters and see the results in real-time. Once you're satisfied, we’ll automatically generate the C# code for you, making integration into your project effortless. No need to start from scratch - just copy the code and implement it seamlessly into your .NET application!
Get started now
Converting documents using our .NET SDK has never been easier. Whether converting or manipulating documents, the ConvertAPI library simplifies the process with minimal code and maximum efficiency. First, you want to install the ConvertAPI NuGet library by run this line from Package Manager Console:
Install-Package ConvertApi
After installing the library and obtaining your authentication token, you can access all our converters and tools!
In just a few lines of code, you can specify your source file and fine-tune the conversion by enabling or disabling various features such as markups, tags, metadata, headings, bookmarks, and table-of-contents updates. The library handles all the complexity under the hood, allowing you to focus on seamlessly integrating document conversion into your application’s workflow.
This example demonstrates how to convert a file using in-memory streams without saving to disk. This is ideal for scenarios where files are received from or sent to external systems via streams, such as web APIs or cloud storage.
It is super efficient for applications that handle files dynamically without intermediate storage.
var convertApi = new ConvertApi("api_key");
const string htmlString = "<!DOCTYPE html><html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>";
var stream = new MemoryStream(Encoding.UTF8.GetBytes(htmlString));
var convertToPdf = await convertApi.ConvertAsync("html", "pdf",
new ConvertApiFileParam(stream, "test.html")
);
var outputStream = await convertToPdf.Files.First().FileStreamAsync();
Console.Write(new StreamReader(outputStream).ReadToEnd());
Console.WriteLine("End of file stream.");
The following example illustrates how to convert a file directly from a remote URL. This approach is useful when the source file is hosted online and doesn't need to be downloaded manually.
It is useful for automating conversions of files available on public URLs.
var convertApi = new ConvertApi("api_key");
var sourceFile = new Uri("https://cdn.convertapi.com/public/files/demo.pptx");
Console.WriteLine($"Converting online PowerPoint file {sourceFile} to PDF...");
var convertToPdf = await convertApi.ConvertAsync("pptx", "pdf", new ConvertApiFileParam(sourceFile));
var outputFileName = convertToPdf.Files[0];
var fileInfo = await outputFileName.SaveFileAsync(Path.Combine(Path.GetTempPath(), outputFileName.FileName));
Console.WriteLine("The PDF saved to " + fileInfo);
The following example illustrates how to convert a file from a remote URL to PDF. This approach is useful when the source file is hosted online and doesn't need to be downloaded manually.
It is ideal for creating PDF snapshots of web pages for record-keeping or offline access.
var convertApi = new ConvertApi("api_key");
Console.WriteLine("Converting web page https://en.wikipedia.org/wiki/Data_conversion to PDF...");
var response = await convertApi.ConvertAsync("web", "pdf",
new ConvertApiParam("Url", "https://en.wikipedia.org/wiki/Data_conversion"),
new ConvertApiParam("FileName", "web-example"));
var fileSaved = await response.Files.SaveFilesAsync(Path.GetTempPath());
Console.WriteLine("The web page PDF saved to " + fileSaved.First());
Let's demonstrate a multi-step conversion process, such as converting a PDF file to JPG and then compressing multiple JPG files to a ZIP archive. This example showcases how to chain multiple conversions seamlessly.
This use case is beneficial for complex workflows requiring multiple file transformations.
var convertApi = new ConvertApi("api_key");
Console.WriteLine("Converting PDF to JPG and compressing result files with ZIP");
var fileName = Path.Combine(Path.GetTempPath(), "test.pdf");
var firstTask = await convertApi.ConvertAsync("pdf", "jpg", new ConvertApiFileParam(fileName));
Console.WriteLine($"Conversions done. Cost: {firstTask.ConversionCost}. Total files created: {firstTask.FileCount()}");
var secondsTask = await convertApi.ConvertAsync("jpg", "zip", new ConvertApiFileParam(firstTask));
var saveFiles = await secondsTask.Files.SaveFilesAsync(Path.GetTempPath());
Console.WriteLine($"Conversions done. Cost: {secondsTask.ConversionCost}. Total files created: {secondsTask.FileCount()}");
Console.WriteLine($"File saved to {saveFiles.First().FullName}");
Below is an example of how to handle exceptions and errors during the conversion process. This ensures that applications can gracefully handle issues like invalid inputs or network errors. The ConvertApiException class is thrown when an error occurs during the conversion process. You can read the detailed error message from the response body as well as the status code.
Proper exception handling is essential for building robust applications that can manage and log errors effectively.
try
{
var convertApi = new ConvertApi("api_token");
const string sourceFile = @"..\..\..\TestFiles\test.docx";
var convert = await convertApi.ConvertAsync("pdf", "split",
new ConvertApiFileParam(sourceFile));
}
//Catch exceptions and write details
catch (ConvertApiException e)
{
Console.WriteLine("Status Code: " + e.StatusCode);
Console.WriteLine("Response: " + e.Response);
}
Using our C# library, you can seamlessly access over 300+ converters and document management tools from a single, centralized interface.
Whether you prefer to convert documents by providing a URL, working directly with file streams, or simply supplying file paths from your local machine, our library offers flexible input options that adapt to your workflow.
To explore more advanced techniques and customization strategies, be sure to browse our GitHub examples folder.
Take control of your documents with our C# document management SDK. From basic conversions to full workflow automation, we provide the expertise and tools you need to manage your documents efficiently.
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
We ensure that all document processing is handled securely in the cloud, adhering to industry-leading standards like ISO 27001, GDPR, and HIPAA. To enhance security even further, we can ensure that no files or data are stored on our servers and never leave your country.
Learn more about securityHighest rated File Conversion API on major B2B software listing platforms: Capterra, G2, and Trustpilot.
"ConvertAPI has been a game-changer for our document automation workflows. Their conversion accuracy and API reliability are unmatched in the industry for over 7 years."
"ConvertAPI is a reliable, cost-effective solution with a proven track record of stability. It has grown significantly in maturity, adopting enterprise-grade practices over the years."
"We've integrated ConvertAPI across our entire document processing platform. The performance is exceptional and the support team is always responsive. Highly recommended!"
The ConvertAPI .NET C# SDK allows developers to integrate powerful file conversion, manipulation, and management features directly into their .NET applications. From converting PDFs to merging documents and extracting text, it supports hundreds of file formats and operations.
Yes. The SDK is designed to handle large documents efficiently. However, performance may vary depending on file size, complexity, and your server’s resources. You can also use asynchronous calls and workflows to optimize performance for large-scale conversions.
You can easily install the SDK via NuGet. Just run Install-Package ConvertApi in the Package Manager Console, or search for “ConvertApi” in the NuGet Package Manager GUI.
The SDK supports over 300+ file formats, including PDF, DOCX, XLSX, PPTX, JPG, PNG, HTML, and many others. This makes it ideal for a wide range of document conversion and processing tasks.
Absolutely. You can fine-tune various parameters, such as resolution, quality, page ranges, and metadata, depending on the file format and conversion type. The SDK’s flexible parameters let you tailor the output to your exact requirements.
Visit our GitHub repository for code samples, advanced scenarios, and best practices. The repository is continually updated, ensuring you have the latest guidance for maximizing the SDK’s potential.