// This code is part of GrapeCity Documents for PDF samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;

namespace GcPdfWeb.Samples
    // This sample shows how to linearize an arbitrary existing PDF.
    public class MakeLinearized
        public int CreatePDF(Stream stream)
            // Load an arbitrary non-linearized PDF into a GcPdfDocument:
            using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf"));
            var doc = new GcPdfDocument();

            // Save the PDF as linearized:
            doc.Save(stream, SaveMode.Linearized);

            // Done:
            return doc.Pages.Count;