How to Open an Existing PDF Document

This sample shows how to open an existing PDF and re-save it using PDFMosaic library.

C# :

using PDFMosaic;
using System;

namespace OpenAndReSave
{
class OpenAndReSave
{
static void Main(string[] args)
{
// Open existing pdf document
PDFDocument document = new PDFDocument(“any_document.pdf”); // Open existing PDF document

// Gets the number of pages in the collection
System.Windows.Forms.MessageBox.Show(“The document contains “ + document.Pages.Count + ” pages”);

// Change the compression of document
document.Compression = PDFCompression.Flate;

document.Save(“OpenAndReSave.pdf”, true);
}
}
}

Visual Basic.NET :

Imports PDFMosaic
Imports System

Module OpenAndReSave
Sub Main()
‘ Open existing PDF document
Dim document As New PDFDocument(any_document.pdf")

' Gets the number of pages in the collection
System.Windows.Forms.MessageBox.Show("The document contains " & document.Pages.Count & " pages")

' Change the compression of document
document.Compression = PDFCompression.Flate

document.Save("OpenAndReSave.pdf", True)
End Sub
End Module