Refer to this article to compress PDF with C# REST API. You will learn to minimize PDF size with C# .NET-based API by implementing a .NET-based Cloud SDK. It will enable the applications to create smaller-sized PDF that supports faster file transfer, and improved performance on mobile and web applications.
Prerequisite
- Create an account API credentials to reduce PDF size online
- Download Aspose.PDF Cloud SDK for Dotnet for shrinking a PDF
- Setup C# project with the above SDK
Steps to Decrease PDF Size with C# REST Interface
- Create a new PdfApi instance using your API credentials so you can work with PDFs in the cloud
- Set up the local directory along with the input PDF file and the name of the optimized output file
- Open the local PDF and upload it to Aspose Cloud so it’s ready for optimization
- Print a message to let yourself know the file was successfully uploaded
- Create an OptimizeOptions object that controls how the PDF will be compressed, including image quality and font embedding
- Send the optimization request to Aspose Cloud to compress the PDF using your chosen settings by calling the PostOptimizeDocument() method
- Retrieve the optimized PDF from cloud storage and save it locally under the specified output file name
The above steps explain the process to decrease PDF file size with C# REST API. You begin by connecting to the PDF API, choosing your files, and uploading your PDF so it’s ready to be worked on. Once that’s done, you apply your optimization settings in the cloud, then download the newly compressed file and save it to your computer.
Code to Shrink PDF Size with C# RESTful Service
This code explains the process to decrease PDF file size with C# REST API. The OptimizeOptions let you choose how your PDF should be cleaned up and compressed, like reducing image quality or removing things the file no longer needs. These settings work together to make your PDF smaller and easier to share while still keeping it looking good.
This article has described the process to reduce PDF size. To flatten a PDF file, refer to the article on Flattening PDFs with C# REST API.