ByteScout PDF To HTML SDK – C# – Reduce Memory Usage

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF To HTML SDK – C# – Reduce Memory Usage

ByteScout PDF To HTML SDK – C# – Reduce Memory Usage

Program.cs

using System;
using Bytescout.PDF2HTML;

namespace ReduceMemoryUsage
{
	class Program
	{
		static void Main(string[] args)
		{
            // When processing huge PDF documents you may run into OutOfMemoryException.
			// This example demonstrates a way to spare the memory by disabling page data caching.

            // Create Bytescout.PDF2HTML.HTMLExtractor instance
            using (HTMLExtractor extractor = new HTMLExtractor("demo", "demo"))
			{
			    try
			    {
			        // Load sample PDF document
			        extractor.LoadDocumentFromFile("sample2.pdf");

					// Disable page data caching, so processed pages will be disposed automatically
					extractor.PageDataCaching = PageDataCaching.None;

					// Save result to file
                    extractor.SaveHtmlToFile("output.html");
			    }
			    catch (PDF2HTMLException exception)
                {
                    Console.Write(exception.ToString());
                }
			}

			// Open the output file in default associated application
			System.Diagnostics.Process.Start("output.html");
		}
	}
}


  Click here to get your Free Trial version of the SDK

prev
next