ByteScout PDF Suite - C# - Rendering pdf to image in background thread with pdf renderer sdk - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF Suite – C# – Rendering pdf to image in background thread with pdf renderer sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Suite – C# – Rendering pdf to image in background thread with pdf renderer sdk

rendering pdf to image in background thread with pdf renderer sdk in C# and ByteScout PDF Suite

rendering pdf to image in background thread with pdf renderer sdk in C#

ByteScout tutorials describe the stuff for programmers who use C#. Rendering pdf to image in background thread with pdf renderer sdk in C# can be applied with ByteScout PDF Suite. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript.

C# code snippet like this for ByteScout PDF Suite works best when you need to quickly implement rendering pdf to image in background thread with pdf renderer sdk in your C# application. To use rendering pdf to image in background thread with pdf renderer sdk in your C# project or application just copy & paste the code and then run your app! These C# sample examples can be used in one or many applications.

Visit our website to get a free trial version of ByteScout PDF Suite. Free trial contains many of source code samples to help you with your C# project.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

Program.cs
      
using System; using System.IO; using System.Threading; using Bytescout.PDFRenderer; namespace RenderingInBackgroundThread { class Program { private static ManualResetEvent _doneEvent = new ManualResetEvent(false); // synchronization event private static int _counter; // thread counter static void Main(string[] args) { // Get all PDF files in current directory string[] pdfFiles = Directory.GetFiles(".", "*.pdf"); _counter = pdfFiles.Length; // Render PDF files in separate threads foreach (string pdfFile in pdfFiles) { Thread backgroundThread = new Thread(BackgroundThreadProc); backgroundThread.Start(pdfFile); Console.WriteLine(pdfFile + " - conversion started."); } // Wait until threads finished _doneEvent.WaitOne(); Console.WriteLine("Done."); Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } // Rendering thread function private static void BackgroundThreadProc(object data) { string fileName = (string) data; try { // Create renderer using (RasterRenderer renderer = new RasterRenderer()) { renderer.LoadDocumentFromFile(fileName); // Setup rendering RenderingOptions renderingOptions = new RenderingOptions(); renderingOptions.JPEGQuality = 90; float renderingResolution = 300; // Render document pages for (int i = 0; i < renderer.GetPageCount(); i++) { renderer.Save(fileName + ".page" + i + ".jpg", RasterImageFormat.JPEG, i, renderingResolution, renderingOptions); } } Console.WriteLine(fileName + " - successfully converted."); } catch (Exception exception) { Console.WriteLine(exception.ToString()); } if (Interlocked.Decrement(ref _counter) == 0) { // Set event if all threads finished _doneEvent.Set(); } } } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout PDF Suite Home Page

Explore ByteScout PDF Suite Documentation

Explore Samples

Sign Up for ByteScout PDF Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next