Convert PDF to JPG or PNG using C# or Command Line

Question: I need to convert a PDF file to images. I used for testing purposes by some software which offers a command line, but it's shareware and conversion effect is not good.Does anyone knows such a tool or maybe even a C# library?  Is there a solution on VeryPDF?

Answer: According to your needs, maybe you can have a free trial of this software: VeryPDF PDF to Image Converter COM, by which you can convert PDF documents into single page or multi-page raster images such as TIFF or JPEG. And the COM version also allows you to call it from C#, VB .NET, J# via .NET, C, C++ via native C and Borland Delphi. But this is also shareware. As to the conversion effect, please experience it yourself or check it from the following snapshot.

Step 1. Free download PDF to Image Converter COM

  • Even if this is shareware but this software allows you to use it free for evaluating more than 50 times. 
  • When downloading finishes, there will be a zip file. Please extract it to some folder then you check related parameters, usage, code template and other related elements.

Step 2.  Convert PDF to image like PDF to JPG, PDF to PNG by command line or C#.

  • When you use this software, please refer to the usage and examples.
  • If you use the COM version, there is also command line version available.
  • Here is some command line parameters for your reference:
    Usage:pdf2img [options] <-i PDF File> [-o Output]
        -i <input file>: Specify input PDF filename
        -o <output file>: Specify output filename
        -r <resolution>: Set resolution
        -f <first page>: First page to convert
        -l <last page>: Last page to convert
        -c <compress>: Set compression method in generated image
    Examples:
        pdf2img -i C:\input.pdf -o C:\output.png
        pdf2img  -i C:\input.pdf -o C:\output.jpg
        pdf2img -c lzw -i C:\input.pdf -o C:\output.tif
        pdf2img -q 80 -i C:\input.pdf -o C:\output.jpg
  • Here is one code examples of converting PDF to image from C#.
  • void main(int argc,char *argv[])
    {
      if(argc != 3)
      {
      printf("Usage: input.pdf output.tif");
      return;
      }

    PDFExtractToTIFF_SetLicenseKey("XXXXXXXXXXXXXXXXXXX");
    int iBeginTick,iEndTick;
    PDFExtractToTIFF_SetDPI(300,300);
    PDFExtractToTIFF_SetOptions("AutoInvertBWImage","1");
    PDFExtractToTIFF_SetOptions("AutoMergeStrips","1");
    PDFExtractToTIFF_SetOptions("RemoveThumbnail","1");
    iBeginTick = GetTickCount();
    int pagecount = PDFExtractToTIFF(argv[1],argv[2],0,NULL,NULL);
    iEndTick = GetTickCount();
    printf("Page Count(1): %d, time = %d ms\n", pagecount,iEndTick-iBeginTick);
    printf("Please press any key to continue ...\n");
    _getch();
    PDFExtractToTIFF_SetDPI(200,200);
    iBeginTick = GetTickCount();
    pagecount = PDFExtractToTIFF(argv[1],argv[2],1,NULL,NULL);
    iEndTick = GetTickCount();
    printf("'%s' Page Count(1): %d, time = %d ms\n",argv[2],pagecount,iEndTick
    -iBeginTick);
    }

Now let us check the conversion effect from the following snapshot.

input PDF and output PNG 
When you meet any difficulty, please refer to PDF to Image Converter COM component user manual. Or you can contact us as soon as possible, we will solve your problem at the first time.

VN:F [1.9.20_1166]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: +1 (from 1 vote)
Convert PDF to JPG or PNG using C# or Command Line, 10.0 out of 10 based on 1 rating

Related Posts

This entry was posted in PDF to Image Converter and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!