To convert a PDF to TIFF in C#, register OneImage’s PDF format, load the document and save it with a .tif extension. Every page becomes a page of one multipage TIFF. The rendering, TIFF encoding and compression are all managed .NET code, with no PDFium, Ghostscript or other native binaries to deploy, so the same code runs on Windows, Linux, macOS and in containers. This page covers the resolution, gray and black-and-white output, page ranges, one file per page, and an ASP.NET Core endpoint. Every sample was run against OneImage 1.10.2 on .NET 10.
dotnet add package RecursiveAI.OneImage dotnet add package RecursiveAI.OneImage.Pdf
OneImage targets .NET 10. The examples convert the IRS Form W-9 (fw9.pdf), a six-page US government form.
Convert a PDF to a multipage TIFF
using OneImage; using OneImage.Pdf; // Register the PDF format; pages are drawn at 150 dpi by default. var options = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat()), }; // Every page becomes a frame, and TIFF stores every frame as a page. // Pages are drawn on opaque white, so the alpha channel can go. Image.Load("fw9.pdf", options).RemoveAlpha().Save("fw9.tif"); ImageInfo tiff = Image.Identify("fw9.tif"); Console.WriteLine($"{tiff.Frames.Count} pages, {tiff.Width}x{tiff.Height}, {new FileInfo("fw9.tif").Length / 1024:N0} KB");
This printed 6 pages, 1275x1650, 4,084 KB: a letter-size page at the default 150 dpi is 1275×1650 pixels. Pages are drawn as the TIFF is written, and the encoder compresses them with LZW unless you choose otherwise.
PDF pages are drawn on opaque white, but they come out with an alpha channel, since a page can also be drawn on a transparent Background. RemoveAlpha() drops that channel, so the TIFF stores plain RGB. Here that made the file 19% smaller: 4,084 KB against 5,017 KB with alpha.
Convert a PDF to TIFF at 300 dpi, in gray or black and white
Archives and document workflows often ask for 300 dpi, and many want gray or pure black and white to keep files small:
using OneImage; using OneImage.Pdf; var options = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat(new PdfRenderOptions { Dpi = 300 })), }; Image pdf = Image.Load("fw9.pdf", options).RemoveAlpha(); // 300 dpi in color, LZW (the default). pdf.Save("fw9-300.tif"); // 300 dpi in 8-bit gray, Deflate. pdf.Grayscale(toGrayFormat: true).Save("fw9-300-gray.tif", new SaveOptions { EncoderOptions = new TiffEncoderOptions { Compression = TiffCompression.Deflate }, }); // 300 dpi, pure black and white. pdf.Grayscale(toGrayFormat: true).Threshold(0.5).Save("fw9-300-bw.tif"); foreach (string file in new[] { "fw9-300.tif", "fw9-300-gray.tif", "fw9-300-bw.tif" }) { ImageInfo info = Image.Identify(file); Console.WriteLine($"{file}: {info.Frames.Count} pages, {info.Width}x{info.Height}, {info.Frames[0].Format}, {new FileInfo(file).Length / 1024:N0} KB"); }
fw9-300.tif: 6 pages, 2550x3300, Rgb/U8/None, 10,905 KB fw9-300-gray.tif: 6 pages, 2550x3300, Gray/U8/None, 5,252 KB fw9-300-bw.tif: 6 pages, 2550x3300, Gray/U8/None, 1,401 KB
At 300 dpi a letter page is 2550×3300 pixels. Gray about halves the color file, and black and white, where every pixel is 0 or 255, brings the six pages down to 1,401 KB. Threshold(0.5) sets the cut-off: raise it to keep fainter lines. For scans of uneven paper, AdaptiveThreshold() works better, as our page on grayscale and black and white in C# shows.
The Dpi option sets the pixel size of each page: points × dpi ÷ 72. At 600 dpi a letter page is 5100×6600 pixels, about 34 million pixels, which is still within the default limit of 228 pixels per page.
Convert a range of pages
using OneImage; using OneImage.Pdf; // Pages 2 to 4 only. FirstPage counts from 0. var options = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat(new PdfRenderOptions { FirstPage = 1, PageCount = 3, })), }; Image.Load("fw9.pdf", options).RemoveAlpha().Save("fw9-pages-2-4.tif"); Console.WriteLine($"{Image.Identify("fw9-pages-2-4.tif").Frames.Count} pages");
FirstPage counts from 0, so FirstPage = 1, PageCount = 3 selects pages 2, 3 and 4, and this printed 3 pages. Pages outside the range aren’t drawn at all. A range that runs past the end of the document stops at the last page.
Convert each page to its own TIFF
using OneImage; using OneImage.Pdf; var options = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat(new PdfRenderOptions { Dpi = 200 })), }; Image pdf = Image.Load("fw9.pdf", options).RemoveAlpha(); // One single-page TIFF per PDF page: fw9-1.tif, fw9-2.tif, ... for (int i = 0; i < pdf.FrameCount; i++) { pdf.Frames[i].ToImage().Save($"fw9-{i + 1}.tif"); }
This wrote six single-page TIFFs of 1700×2200 pixels, the page size at 200 dpi. Frames[i].ToImage() turns one page into an ordinary image that you can also resize, crop or save as PNG or JPEG.
Count the pages before converting
using OneImage; using OneImage.Pdf; var options = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat(new PdfRenderOptions { Dpi = 300 })), }; // Reads the document structure only: no page is drawn. ImageInfo info = Image.Identify("fw9.pdf", options); Console.WriteLine($"{info.Frames.Count} pages; page 1 at 300 dpi is {info.Frames[0].Width}x{info.Frames[0].Height}");
This printed 6 pages; page 1 at 300 dpi is 2550x3300 without drawing anything. Use it to reject documents with too many pages before you spend time on them, or to work out the output size.
Convert an uploaded PDF to TIFF in ASP.NET Core
using OneImage; using OneImage.Pdf; var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); // Only PDF is registered, so any other upload fails to load. var pdfOnly = new LoadOptions { Configuration = new ImageConfiguration().Add(new PdfFormat(new PdfRenderOptions { Dpi = 200 })), }; app.MapPost("/pdf-to-tiff", async (IFormFile file) => { try { await using Stream upload = file.OpenReadStream(); Image pdf = Image.Load(upload, pdfOnly); var tiff = new MemoryStream(); await pdf.RemoveAlpha().SaveAsync(tiff, TiffFormat.Instance); tiff.Position = 0; return Results.File(tiff, "image/tiff", Path.ChangeExtension(file.FileName, ".tif")); } catch (ImageException) { return Results.BadRequest("The file is not a PDF that can be converted."); } }).DisableAntiforgery(); app.Run();
Posting fw9.pdf to /pdf-to-tiff returned a six-page TIFF of 1700×2200 pages as fw9.tif, and posting a JPEG returned 400. Because the configuration registers only the PDF format, any other file fails to load with an ImageException. The TIFF is built in memory, so for very long documents write it to a temporary file instead, or convert a range at a time. Size limits are checked before pages are drawn: the frame size, the file size (1 GiB by default) and at most 1,000 pages per load.
What gets drawn
The PDF is interpreted by our OnePDF library and drawn by OneImage’s own engine: text from embedded and standard fonts, vector graphics, JPEG, JPEG 2000 and JBIG2 images, shadings, transparency groups and soft masks, and form fields and annotations. Filled-in form fields are drawn with their values. Encrypted documents open with Password in PdfRenderOptions. Our guide to converting PDF pages to PNG and JPG covers the rest of the render options, thumbnails and running in a plain container.
Other ways to convert PDF to TIFF in C#
- Commercial PDF SDKs such as Aspose.PDF, IronPDF and Nutrient document PDF to TIFF conversion, under their vendors’ license terms. They are broader PDF toolkits that also create and edit documents.
- Ghostscript is a command-line renderer with several TIFF output devices. Artifex licenses it under the GNU AGPLv3 or a commercial license, and calling it from .NET means deploying the binary and managing processes and temporary files.
To work with the TIFF afterwards, for example to split it again or convert pages to PNG, see splitting a multipage TIFF in C#. For everything else OneImage reads and writes, start at the OneImage overview.