PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.
- How to use a system font for rendering text
- PDF to grayscale TIFF
- Display PDF in a WPF app and stay responsive - the code
- C# Print PDF documents from a WPF application
- Change colors of black-and-white TIFF after converting from PDF
- Convert PDF to PNG using WPF
- Convert PDF to an image using a dither matrix
- Font mapping
- Convert PDF with layers to image
- C# Print PDF Document
- Render PDF with ResolveFont event handler
- Render PDF to EMF
- Convert PDF to XPS
- Convert PDF to JPG in C#
- Convert PDF to multipage TIFF in C# .NET
- Convert multiple PDF pages to bitmap
- Render a PDF to bitmap
- Use multiple licenses
Convert PDF to an image using a dither matrix
This code sample shows how to convert a PDF page to a bitmap image, while applying a dither matrix to the generated image. Dithering is the processing of applying a matrix to the original image and thereby adding seemingly randomized noise. This is done to prevent color banding and other large scale patterns to occur in your image. Read more.
using (FileStream fs = new FileStream(@"..\..\input.pdf", FileMode.Open, FileAccess.Read))
{
Document d = new Document(fs);
int[][] DitherMatrix = new int[][] {
new int[] { 9, 9, 7 },
new int[] { 4, 1, 0 },
new int[] { 0, 5, 2 }};
Page page = d.Pages[0];
Bitmap bitmap = new Bitmap((int)page.Width, (int)page.Height);
ConvertToTiffOptions options = new ConvertToTiffOptions();
//set a dithering matrix
options.DitherMatrix = DitherMatrix;
using (MemoryStream ms = new MemoryStream())
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.Clear(Color.White);
page.ConvertToTiff(ms, options);
}
bitmap = new Bitmap(ms, false);
bitmap.Save(@"..\..\output.bmp");
}
}
Download PDFRasterizer.NET 3.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download
We have sent an email with a download link.