Skip to content

Commit 982b056

Browse files
Merge pull request #533 from telerik/new-kb-convert-pdf-to-tiff-radpdfprocessing-net-core-6c26bb94ca8f41f3a3831360b1c7350f
Added new kb article convert-pdf-to-tiff-radpdfprocessing-net-core
2 parents eb7026a + 7e04008 commit 982b056

File tree

2 files changed

+113
-1
lines changed

2 files changed

+113
-1
lines changed

knowledge-base/convert-pdf-to-multipage-tiff-radpdfprocessing.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Converting a PDF Document to a Multipage TIFF Image
2+
title: Converting a PDF Document to a Multipage TIFF Image in .NET Framework
33
description: Learn how to transform PDF documents into multipage TIFF files using RadPdfProcessing from the Document Processing libraries.
44
type: how-to
55
page_title: How to Convert PDF Documents to Multipage TIFF with RadPdfProcessing
@@ -90,3 +90,4 @@ private static void Main(string[] args)
9090
- [TiffBitmapEncoder Class Documentation](https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.tiffbitmapencoder)
9191
- [Using SkiaImageFormatProvider]({%slug radpdfprocessing-formats-and-conversion-image-using-skiaimageformatprovider%})
9292
- [Converting Multi-page TIFF Images to PDF]({%slug convert-tiff-to-pdf-radpdfprocessing%})
93+
- [Converting PDF to TIFF with RadPdfProcessing in .NET Standard]({%slug convert-pdf-to-tiff-radpdfprocessing-net-core%})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: Converting PDF to TIFF with RadPdfProcessing in .NET Standard
3+
description: This article demonstrates how to convert PDF documents to TIFF images in .NET Standard applications using RadPdfProcessing.
4+
type: how-to
5+
page_title: How to Convert PDF Documents to TIFF Images Using RadPdfProcessing in .NET Standard
6+
slug: convert-pdf-to-tiff-radpdfprocessing-net-core
7+
tags: radpdfprocessing, document, processing, pdf, tiff, conversion, net, standard
8+
res_type: kb
9+
ticketid: 1682497
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| ---- | ---- | ---- |
16+
| 2025.1.205| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
Learn how to convert PDF documents to TIFF format in .NET Standard.
21+
22+
## Solution
23+
24+
To convert PDF documents to TIFF images in .NET Standard, follow these steps:
25+
26+
1. Use the [SkiaImageFormatProvider]({%slug radpdfprocessing-formats-and-conversion-image-using-skiaimageformatprovider%}) to export the PDF pages to images.
27+
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.
28+
29+
Here's an example code snippet demonstrating the process:
30+
31+
```csharp
32+
using System.Diagnostics;
33+
using System.Drawing;
34+
using System.Drawing.Imaging;
35+
using Telerik.Documents.Fixed.FormatProviders.Image.Skia;
36+
using Telerik.Windows.Documents.Fixed.FormatProviders.Pdf;
37+
using Telerik.Windows.Documents.Fixed.Model;
38+
using System.IO;
39+
40+
namespace PdfToTIFFNetCore
41+
{
42+
internal class Program
43+
{
44+
[STAThread]
45+
static void Main(string[] args)
46+
{
47+
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
48+
RadFixedDocument fixedDocument = pdfFormatProvider.Import(File.ReadAllBytes("your-pdf-file.pdf"), TimeSpan.FromSeconds(10));
49+
SkiaImageFormatProvider imageProvider = new SkiaImageFormatProvider();
50+
string exportedFileName = "Exported.tiff";
51+
using (FileStream fileStream = new FileStream(exportedFileName, FileMode.Create))
52+
{
53+
System.Drawing.Imaging.Encoder encoder = System.Drawing.Imaging.Encoder.SaveFlag;
54+
ImageCodecInfo codecInfo = GetEncoderInfo("image/tiff");
55+
EncoderParameters encoderParams = new EncoderParameters(1);
56+
encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.MultiFrame);
57+
58+
Bitmap firstImage = null;
59+
bool firstFrame = true;
60+
61+
foreach (RadFixedPage page in fixedDocument.Pages)
62+
{
63+
byte[] resultImage = imageProvider.Export(page, TimeSpan.FromSeconds(10));
64+
using (MemoryStream ms = new MemoryStream(resultImage))
65+
{
66+
using (Bitmap bitmap = new Bitmap(ms))
67+
{
68+
if (firstFrame)
69+
{
70+
firstImage = new Bitmap(bitmap);
71+
firstImage.Save(fileStream, codecInfo, encoderParams);
72+
firstFrame = false;
73+
}
74+
else
75+
{
76+
encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.FrameDimensionPage);
77+
firstImage.SaveAdd(bitmap, encoderParams);
78+
}
79+
}
80+
}
81+
}
82+
83+
encoderParams.Param[0] = new EncoderParameter(encoder, (long)EncoderValue.Flush);
84+
firstImage.SaveAdd(encoderParams);
85+
}
86+
87+
Process.Start(new ProcessStartInfo() { FileName = exportedFileName, UseShellExecute = true });
88+
}
89+
90+
private static ImageCodecInfo GetEncoderInfo(string mimeType)
91+
{
92+
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
93+
foreach (ImageCodecInfo codec in codecs)
94+
{
95+
if (codec.MimeType == mimeType)
96+
{
97+
return codec;
98+
}
99+
}
100+
return null;
101+
}
102+
}
103+
}
104+
```
105+
106+
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.
107+
108+
## See Also
109+
110+
- [Converting a PDF Document to a Multipage TIFF Image]({%slug convert-pdf-to-multipage-tiff-radpdfprocessing%})
111+

0 commit comments

Comments
 (0)