- Use multiple licenses
- PDF to grayscale TIFF C#
- Convert PDF with layers to image
- Convert PDF to an image using a dither matrix
- Render PDF to EMF
- Render PDF with ResolveFont event handler
- Change colors of black-and-white TIFF after converting from PDF
- Convert PDF to PNG using WPF
- Convert multiple PDF pages to bitmap
- Convert PDF to multipage TIFF in C# .NET
- Display PDF in a WPF app and stay responsive - the code
- Convert PDF to XPS
- Convert PDF to JPG in C#
- C# Print PDF documents from a WPF application
- Render a PDF to bitmap
- C# Print document | Code Sample | Tall Components PDF C# samples
- How to use a system font for rendering text
- Font mapping
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");
}
}