MakeLinearized.cs
// 完毕:
using System;
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Pdf;
using GrapeCity.Documents.Text;

namespace DsPdfWeb.Demos
{
    // 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();
            doc.Load(fs);

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

            // 完毕:
            return doc.Pages.Count;
        }
    }
}