Convert PDF to TIFF Format

I am writting a VB.Net application. I need to be able to convert either a Word or PDF file to TIF format.

Free would be nice but I will also accept low cost.

I would like sample code if possible, VB is preferable but I also know c#

Answers


It's very simple with imagemagick (you do have to download ghostscript, too.). You just need to use VB to run it as a process.

Dim imgmgk As New Process()

    With imgmgk.StartInfo
        .FileName = v_locationOfImageMagickConvert.exe
        .UseShellExecute = False
        .CreateNoWindow = True
        .RedirectStandardOutput = True
        .RedirectStandardError = True
        .RedirectStandardInput = False
        .Arguments = " -units PixelsPerInch " & v_pdf_filename & " -depth 16 -flatten +matte –monochrome –density 288 -compress ZIP " & v_tiff_filename

    End With

    imgmgk.Start()

    Dim output As String = imgmgk.StandardOutput.ReadToEnd()
    Dim errorMsg As String = imgmgk.StandardError.ReadToEnd()
    imgmgk.WaitForExit()
    imgmgk.Close()

The arguments are varied - use imagemagick docs to see what they are. You can do something as simple as just pass the pdf file name and the tiff file name for a simple conversion.


You can do this with Atalasoft DotImage (commerial product - obligatory disclaimer: I work for Atalasoft and write a lot of the PDF code):

// this code extracts images from the PDF - there may be multiple images per page
public void PdfToTiff(Stream pdf, Stream tiff)
{
    TiffEncoder encoder = new TiffEncoder(tiff);

    PdfImageSource images = new PdfImageSource(pdf);

    encoder.Save(tiff, images, null);
}

// this code renders each page
public void PdfToTiff(string pathToPdf, Stream tiff)
{
    TiffEncoder encoder = new TiffEncoder(tiff);

    FileSystemImageSource images = new FileSystemImageSource(pathToPdf, true);

    encoder.Save(tiff, images, null);
}

The latter example is probably what you want. It works on a path because FileSystemImageSource takes advantage of code to operate on the file system with wildcards. It's overkill for the task, really. If you wanted to do it without you would have this:

public void PdfToTiff(Stream pdf, Stream tiff)
{
    TiffEncoder encoder = new TiffEncoder();
    encoder.Append = true;

    PdfDecoder decoder = new PdfDecoder();
    int pageCount = decoder.GetFrameCount(pdf);
    for (int i=0; i < pageCount; i++) {
        using (AtalaImage image = decoder.Read(pdf, i, null)) {
            encoder.Save(tiff, image, null);
        }
    }
}

There are many products I found that can do this. Some have a cost while some are free.

I used Black Ice http://www.blackice.com/Printer%20Drivers/Tiff%20Printer%20Drivers.htm. This is afordable at about $40. I didn't buy this one though.

I ended up using a free one called MyMorph.


Need Your Help

GAE - rpc and HashMap<K,V> field

google-app-engine gwt gwt-rpc

I tested my gwt app in eclipse and it worked fine; Then I tried to deploy my test app to gae... That what exception I can see in gae logs after each rpc call :

Need clarification of Type Casting operator in Swift

swift casting typecasting-operator

Why is the type cast operator (as) being used instead of its conditional form (as?) in this switch statement?