MakeLinearized.cs
  1. //
  2. // This code is part of Document Solutions for PDF demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using GrapeCity.Documents.Pdf;
  9. using GrapeCity.Documents.Text;
  10.  
  11. namespace DsPdfWeb.Demos
  12. {
  13. // This sample shows how to linearize an arbitrary existing PDF.
  14. public class MakeLinearized
  15. {
  16. public int CreatePDF(Stream stream)
  17. {
  18. // Load an arbitrary non-linearized PDF into a GcPdfDocument:
  19. using var fs = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf"));
  20. var doc = new GcPdfDocument();
  21. doc.Load(fs);
  22.  
  23. // Save the PDF as linearized:
  24. doc.Save(stream, SaveMode.Linearized);
  25.  
  26. // Done:
  27. return doc.Pages.Count;
  28. }
  29. }
  30. }
  31.