-
Notifications
You must be signed in to change notification settings - Fork 39
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
github-actions
wants to merge
2
commits into
master
Choose a base branch
from
new-kb-convert-pdf-to-tiff-radpdfprocessing-net-core-6c26bb94ca8f41f3a3831360b1c7350f
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
knowledge-base/convert-pdf-to-tiff-radpdfprocessing-net-core.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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%}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reference kb in another article |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add "(.NET Framework)" to the title of this KB - https://docs.telerik.com/devtools/document-processing/knowledge-base/convert-pdf-to-multipage-tiff-radpdfprocessing.
Make the two KBs reference each other.