ByteScout Premium 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 Premium Suite – C# – Rendering pdf to image in background thread with pdf renderer sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium 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# using ByteScout Premium Suite

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

These source code samples are assembled by their programming language and functions they use. ByteScout Premium Suite helps with rendering pdf to image in background thread with pdf renderer sdk in C#. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.

C# code snippet like this for ByteScout Premium Suite works best when you need to quickly implement rendering pdf to image in background thread with pdf renderer sdk in your C# application. Just copy and paste this C# sample code to your C# application’s code editor, add a reference to ByteScout Premium Suite (if you haven’t added yet) and you are ready to go! These C# sample examples can be used in one or many applications.

On our website you may get trial version of ByteScout Premium Suite for free. Source code samples are included to help you with your C# application.

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 Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium 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 Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next