Skip to content
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ Step 3: **Add required namespaces**: Include the following namespaces in your `P
Step 4: **Implement PDF compression**: Use the following code snippet in `Program.cs` to compress PDF files:

```csharp
// Open a file stream to read the input PDF file
// Open a file stream to read the input PDF file
using (FileStream fileStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
// Load the PDF document from the file stream
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileStream))
{
// Create a new PdfCompressionOptions object
PdfCompressionOptions options = new PdfCompressionOptions();

// Enable image compression and set the image quality
options.CompressImages = true;
options.ImageQuality = 50;

// Enable font optimization
options.OptimizeFont = true;

// Enable page content optimization
options.OptimizePageContents = true;

// Remove metadata from the PDF
options.RemoveMetadata = true;

// Compress the PDF document
loadedDocument.Compress(options);

// Save the document into a memory stream
using (MemoryStream outputStream = new MemoryStream())
{
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, "Signature");

// Set signature information
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(200, 100));
signature.Bounds = new RectangleF(227.6355f, 675.795044f, 150.57901f, 32.58f);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am the author of this document.";
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading