The Syncfusion Essential PDF is a .NET PDF library used to optimize or compress PDF documents. Reducing the PDF file size can help you optimize bandwidth cost, network transmission, and digital storage. It is especially useful in areas like archiving or long-term preservation, emailing, and using PDF documents in web-based applications. The Syncfusion .NET PDF library will work seamlessly regardless of the document structure and content to compress PDF with just a few lines of C# code. You can resize your files according to your requirement. Essential PDF provides the following ways of optimization:
PDF files may contain many images. Removing the images from a PDF file is usually not an option as they are necessary for PDFs. Downsampling the images will decrease the number of pixels and is possibly the most effective way to reduce the PDF file size. Users can control the PDF file size with respect to the quality of the image.
Font resources will also result in large file sizes. To make the PDF smaller, remove unused glyphs and unwanted font tables from the embedded font in the PDF document.
Removing or flattening annotations can help reduce your file size. Flattening will remove annotations, but preserve its values. It will only be used when no further editing is needed.
Optimizing the page content will remove unwanted commented lines, white spaces, convert end-of-line characters to spaces, and compress all uncompressed contents.
The content of a PDF file can be updated incrementally without rewriting the entire file. Changes are appended to the end of the file, leaving its original content intact. Disabling the incremental update will rewrite the entire file, which results in a smaller PDF.
Removing or flattening form fields can help reduce your file size. Flattening will remove the form fields and preserve its values. It will only be used when no further editing is needed.
You can reduce the file size by removing the metadata in the PDF document.
Easily compressing PDF content using a few simple lines of C# code as demonstrated below. Also explore our .NET PDF Example that shows how to create and modify PDF files from C# with 5 lines of code on different platforms.
using Syncfusion.Pdf;
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Set the compression level to best
document.Compression = PdfCompressionLevel.Best;
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
//Set the font.
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
string text = "Hello World!!!";
PdfTextElement textElement = new PdfTextElement(text, font);
PdfLayoutResult result = textElement.Draw(page, new RectangleF(0, 0, font.MeasureString(text).Width, page.GetClientSize().Height));
for (int i = 0; i < 1000; i++)
{
result = textElement.Draw(result.Page, new RectangleF(0, result.Bounds.Bottom +10, font.MeasureString(text).Width, page.GetClientSize().Height));
}
//Save the document.
document.Save("Output.pdf");
//Close the document.
document.Close(true);
Imports Syncfusion.Pdf
'Create a new PDF document.
Dim document As New PdfDocument()
'Set the compression level to best
document.Compression = PdfCompressionLevel.Best
'Add a page to the document.
Dim page As PdfPage = document.Pages.Add()
'Create PDF graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Set the font.
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 20)
Dim text As String = "Hello World!!!"
Dim textElement As New PdfTextElement(text, font)
Dim result As PdfLayoutResult = textElement.Draw(page, New RectangleF(0, 0, font.MeasureString(text).Width, page.GetClientSize().Height))
For i As Integer = 0 To 999
result = textElement.Draw(result.Page, New RectangleF(0, result.Bounds.Bottom + 10, font.MeasureString(text).Width, page.GetClientSize().Height))
Next
'Save the document.
document.Save("Output.pdf")
'Close the document.
document.Close(True)
Essential Studio
Per developer 1st year
Per developer 1st year
CASE STUDY
Syncfusion’s file format components helped me create the reports I needed, fast. – J. Pereira, Software Developer.
The libraries have been built from scratch and refined for more than a decade to provide blazing-fast performance, comprehensive API, and compatibility across the latest and older versions of these files.
VIDEOS
Syncfusion File Format Libraries - Manipulate Excel, Word, PowerPoint, and PDF files
Read and write Excel, Word, PDF, and PowerPoint files. Also includes integrated visualization capabilities. Advanced features include support for pivot tables, pivot charts, mail-merge, and extensive formatting.
E-BOOK
Succinctly Series: Statistics Using Excel Succinctly
Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion is proud to hold the following industry awards.