Skip to content

Added new kb article convert-pdf-to-tiff-radpdfprocessing-net-core #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ private static void Main(string[] args)
- [TiffBitmapEncoder Class Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.tiffbitmapencoder)
- [Using SkiaImageFormatProvider]({%slug radpdfprocessing-formats-and-conversion-image-using-skiaimageformatprovider%})
- [Converting Multi-page TIFF Images to PDF]({%slug convert-tiff-to-pdf-radpdfprocessing%})
- [Converting PDF to TIFF with RadPdfProcessing in .NET Standard]({%slug convert-pdf-to-tiff-radpdfprocessing-net-core%})
111 changes: 111 additions & 0 deletions knowledge-base/convert-pdf-to-tiff-radpdfprocessing-net-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
title: Converting PDF to TIFF with RadPdfProcessing in .NET Standard
description: This article demonstrates how to convert PDF documents to TIFF images in .NET Standard applications using RadPdfProcessing.
type: how-to
page_title: How to Convert PDF Documents to TIFF Images Using RadPdfProcessing in .NET Standard
slug: convert-pdf-to-tiff-radpdfprocessing-net-core
tags: radpdfprocessing, document, processing, pdf, tiff, conversion, net, standard
res_type: kb
ticketid: 1682497
---

## Environment

| Version | Product | Author |
| ---- | ---- | ---- |
| 2025.1.205| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|

## Description

Learn how to convert PDF documents to TIFF format in .NET Standard.

## Solution

To convert PDF documents to TIFF images in .NET Standard, follow these steps:

1. Use the [SkiaImageFormatProvider]({%slug radpdfprocessing-formats-and-conversion-image-using-skiaimageformatprovider%}) to export the PDF pages to images.
2. Utilize the [System.Drawing.Common](https://www.nuget.org/packages/System.Drawing.Common/) library to assemble these images into a multi-page TIFF file.

Here's an example code snippet demonstrating the process:

```csharp
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using Telerik.Documents.Fixed.FormatProviders.Image.Skia;
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
using Telerik.Windows.Documents.Fixed.Model;
using System.IO;

namespace PdfToTIFFNetCore
{
internal class Program
{
[STAThread]
static void Main(string[] args)
{
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
RadFixedDocument fixedDocument = pdfFormatProvider.Import(File.ReadAllBytes("your-pdf-file.pdf"), TimeSpan.FromSeconds(10));
SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();
string exportedFileName = "Exported.tiff";
using (FileStream fileStream = new FileStream(exportedFileName, FileMode.Create))
{
System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.SaveFlag;
ImageCodecInfo codecInfo = GetEncoderInfo("image/tiff");
EncoderParameters encoderParams = new EncoderParameters(1);
encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.MultiFrame);

Bitmap firstImage = null;
bool firstFrame = true;

foreach (RadFixedPage page in fixedDocument.Pages)
{
byte[] resultImage = imageProvider.Export(page, TimeSpan.FromSeconds(10));
using (MemoryStream ms = new MemoryStream(resultImage))
{
using (Bitmap bitmap = new Bitmap(ms))
{
if (firstFrame)
{
firstImage = new Bitmap(bitmap);
firstImage.Save(fileStream, codecInfo, encoderParams);
firstFrame = false;
}
else
{
encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.FrameDimensionPage);
firstImage.SaveAdd(bitmap, encoderParams);
}
}
}
}

encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.Flush);
firstImage.SaveAdd(encoderParams);
}

Process.Start(new ProcessStartInfo() { FileName = exportedFileName, UseShellExecute = true });
}

private static ImageCodecInfo GetEncoderInfo(string mimeType)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType == mimeType)
{
return codec;
}
}
return null;
}
}
}
```

Replace `"your-pdf-file.pdf"` with the path to your PDF file. This code will create a TIFF file named `Exported.tiff` containing all the pages from the PDF document.

## See Also

- [Converting a PDF Document to a Multipage TIFF Image]({%slug convert-pdf-to-multipage-tiff-radpdfprocessing%})