Docotic.Pdf Library Help > Samples > Compression > Remove structure information from PDF document

This sample shows how to reduce size of a PDF document by removing structure information from it.

To remove structure information from a PDF please use PdfDocument.RemoveStructureInformation() method. This method can significantly reduce output file size.

Please note that document without structure information will be less accessible for assistive devices.

C#
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class RemoveStructureInformation
    {
        public static void Main()
        {
            const string originalFile = @"Sample Data\BRAILLE CODES WITH TRANSLATION.pdf";
            const string compressedFile = "RemoveStructureInformation.pdf";

            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            using (PdfDocument pdf = new PdfDocument(originalFile))
            {
                pdf.RemoveStructureInformation();

                pdf.Save(compressedFile);
            }

            string message = string.Format(
                "Original file size: {0} bytes;\r\nCompressed file size: {1} bytes",
                new FileInfo(originalFile).Length,
                new FileInfo(compressedFile).Length
            );
            MessageBox.Show(message);

            Process.Start(compressedFile);
        }
    }
}
VB
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Windows.Forms

Imports Microsoft.VisualBasic

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class RemoveStructureInformation
        Public Shared Sub Main()
            Const originalFile As String = "Sample Data\BRAILLE CODES WITH TRANSLATION.pdf"
            Const compressedFile As String = "RemoveStructureInformation.pdf"

            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Using pdf As New PdfDocument(originalFile)
                pdf.RemoveStructureInformation()

                pdf.Save(compressedFile)
            End Using

            Dim message As String = String.Format(
                "Original file size: {0} bytes;" & vbCr & vbLf & "Compressed file size: {1} bytes",
                New FileInfo(originalFile).Length,
                New FileInfo(compressedFile).Length
            )
            MessageBox.Show(message)

            Process.Start(compressedFile)
        End Sub
    End Class
End Namespace