简体   繁体   中英

Pdf to image converter without ghostscript

I am looking for a dotnet / nodejs library to convert pdf to image (to be used as a thumbnail). I know there are loads of disucssion already been done on this topic but most of them use ghost script which I can not use as because it's license terms (GNU GPL).

there are some online services as well but the pdfs are confidencial, so I have no liberty to use them.

I am looking for MIT or Apache license Or do not mind paid version of API. does any one used or know such library/API ?

Have a look at this:

http://code.msdn.microsoft.com/WindowsAPICodePack

You can call ShellObject.FromParsingName("C:\\somefolder\\somefile.pdf").

Take a look at Docotic.Pdf library . It is not free but good. And doesn't require you to install any command line tools with viral licenses.

Here is a sample code for a thumbnail generator.

using (Stream output = new MemoryStream())
{
    using (PdfDocument pdf = new PdfDocument(@"input.pdf"))
    {
        PdfDrawOptions options = PdfDrawOptions.CreateFitSize(new PdfSize(200, 200), false);
        options.BackgroundColor = new PdfGrayColor(100);
        pdf.Pages[0].Save(output, options);
    }
}

More samples for drawing and printing of PDFs are available on our site.

Disclaimer: I am one of the developers of the library.

Gnostice PDFOne .NET has a saveAsImage method with which you can save PDF page content to a raster image format such as JPEG, BMP, TIFF or PNG.

If you want a vector output, use the getPageMetafile method with which you get a Metafile object. However, the .NET Metafile class does not save to EMF/WMF. You will need to use some unmanaged calls as explained at: http://www.gnostice.com/nl_article.asp?id=201&t=How_To_Convert_PDF_To_Image_Formats_In_NET

DISCLAIMER: I work for Gnostice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM