XFINIUM.PDF 5.1 brings support for native PDF to TIFF conversion. What this means is that we implemented a full TIFF encoder so that this functionality is now available on all platforms.
The conversion of a PDF file to a multi-page TIFF is implemented through the PdfDocumentRenderer
class. Once a PDF file is loaded in a PdfFixedDocument
it can be converted to multi-page TIFF with a few lines of code.
// Load the PDF file PdfFixedDocument document = new PdfFixedDocument("xfinium.pdf"); // Create a document renderer. PdfDocumentRenderer documentRenderer = new PdfDocumentRenderer(document); // Open the destination stream that will store the TIFF image. FileStream tiffStream = File.OpenWrite("xfinium.tif"); // Setup the rendering settings and convert the PDF to multi-page TIFF PdfRendererSettings settings = new PdfRendererSettings(96, 96); documentRenderer.ConvertToMultipageImage(settings, tiffStream); // Close the destination stream tiffStream.Flush(); tiffStream.Close();
' Load the PDF file Dim document As New PdfFixedDocument("xfinium.pdf") ' Create a document renderer. Dim documentRenderer As New PdfDocumentRenderer(document) ' Open the destination stream that will store the TIFF image. Dim tiffStream As FileStream = File.OpenWrite("xfinium.tif") ' Setup the rendering settings and convert the PDF to multi-page TIFF Dim settings As New PdfRendererSettings(96, 96) documentRenderer.ConvertToMultipageImage(settings, tiffStream) ' Close the destination stream tiffStream.Flush() tiffStream.Close()
By default the PDF file is converted to RGBA TIFF but grayscale and B/W TIFFs are supported.
In order to create a 1bpp B/W TIFF a black and white rendering surface must be provided as model in the rendering settings.
// Load the PDF file PdfFixedDocument document = new PdfFixedDocument("xfinium.pdf"); // Create a document renderer. PdfDocumentRenderer documentRenderer = new PdfDocumentRenderer(document); // Open the destination stream that will store the TIFF image. FileStream tiffStream = File.OpenWrite("xfinium.tif"); // Setup the rendering settings and convert the PDF to multi-page TIFF PdfRendererSettings settings = new PdfRendererSettings(96, 96); // Specify a Black and White rendering surface to generate a 1bpp B/W TIFF. settings.RenderingSurface = new PdfBlackWhiteByteRenderingSurface(); documentRenderer.ConvertToMultipageImage(settings, tiffStream); // Close the destination stream tiffStream.Flush(); tiffStream.Close();
' Load the PDF file Dim document As New PdfFixedDocument("xfinium.pdf") ' Create a document renderer. Dim documentRenderer As New PdfDocumentRenderer(document) ' Open the destination stream that will store the TIFF image. Dim tiffStream As FileStream = File.OpenWrite("xfinium.tif") ' Setup the rendering settings and convert the PDF to multi-page TIFF Dim settings As New PdfRendererSettings(96, 96) ' Specify a Black and White rendering surface to generate a 1bpp B/W TIFF. settings.RenderingSurface = New PdfBlackWhiteByteRenderingSurface() documentRenderer.ConvertToMultipageImage(settings, tiffStream) ' Close the destination stream tiffStream.Flush() tiffStream.Close()
When converting a PDF file to B/W TIFF each PDF page is initially rendered in grayscale and then the grayscale image is converted to B/W. The process of converting the grayscale image to B/W is called binarization and we implemented this process through binarization filters. The most simple filter is the threshold filter. This filter converts the values above the threshold to white and the values below the threshold to black.
Using this source PDF page the result of converting it to B/W TIFF looks like this when using the threshold filter:


As you can see a lot of details are lost during the conversion. In order to avoid this we support also several error diffusion dithering filters including the well-known Floyd-Steinberg filter.
The binarization filter is specified as an attribute of the black and white rendering surface.
// Load the PDF file PdfFixedDocument document = new PdfFixedDocument("xfinium.pdf"); // Create a document renderer. PdfDocumentRenderer documentRenderer = new PdfDocumentRenderer(document); // Open the destination stream that will store the TIFF image. FileStream tiffStream = File.OpenWrite("xfinium.tif"); // Setup the rendering settings and convert the PDF to multi-page TIFF PdfRendererSettings settings = new PdfRendererSettings(96, 96); // Specify a Black and White rendering surface with an explicit binarization filter to generate a 1bpp B/W TIFF. PdfBlackWhiteByteRenderingSurface bwRenderingSurface = new PdfBlackWhiteByteRenderingSurface(); bwRenderingSurface.BinarizationFilter = new PdfFloydSteinbergDitheringFilter(); settings.RenderingSurface = bwRenderingSurface; documentRenderer.ConvertToMultipageImage(settings, tiffStream); // Close the destination stream tiffStream.Flush(); tiffStream.Close();
' Load the PDF file Dim document As New PdfFixedDocument("xfinium.pdf") ' Create a document renderer. Dim documentRenderer As New PdfDocumentRenderer(document) ' Open the destination stream that will store the TIFF image. Dim tiffStream As FileStream = File.OpenWrite("xfinium.tif") ' Setup the rendering settings and convert the PDF to multi-page TIFF Dim settings As New PdfRendererSettings(96, 96) ' Specify a Black and White rendering surface with an explicit binarization filter to generate a 1bpp B/W TIFF. Dim bwRenderingSurface As New PdfBlackWhiteByteRenderingSurface() bwRenderingSurface.BinarizationFilter = New PdfFloydSteinbergDitheringFilter() settings.RenderingSurface = bwRenderingSurface documentRenderer.ConvertToMultipageImage(settings, tiffStream) ' Close the destination stream tiffStream.Flush() tiffStream.Close()
Using the same source PDF page the result of converting it to B/W TIFF looks like this when using the Floyd-Steinberg filter:


We support 10 binarization filters: 1 simple filter (threshold filter) and 9 dithering based filters (Bayer which uses ordered dithering and
Atkinson, Burkes, Floyd-Steinberg, Jarvis Judice Ninke, Sierra, Sierra Lite, Sierra 2 Row and Stucki that use error diffusion dithering).
The 1bpp B/W images are compressed using CCITT G4 compression.
Hello,
Is there way to turn off compression while converting from PDF to TIFF (or jpeg) file? I am trying to convert PDF to jpeg with certain DPI ratio but due to compression and bit rate reduction it becomes impossible to read the contents of image.
Please help.
Thanks,
Mayank Sheth.
When doing PDF to color TIFF conversion, the output TIFF image is uncompressed. Can you send us (support@xfiniumpdf.com) a sample project that we can run and reproduce the problem you reported?
Is there any way to render to an image of a specific size other than first checking what size the image would be for a specific DPI and using the result to calculate the required dpi for the desired size?
Like either the dpi of the page which would result in the page’s width and height or potentially a width and a height property for the renderersettings that can be used instead of the dpi.
At this moment you have to compute the dpi in order to get the desired size. We plan to add support for rendering to a specific image size.