Rectangle 27 10

LibPdf library converts converts PDF file to an image. Supported image formats are PNG and BMP, but you can easily add more.

using (FileStream file = File.OpenRead(@"..\path\to\pdf\file.pdf")) // in file
{
    var bytes = new byte[file.Length];
    file.Read(bytes, 0, bytes.Length);
    using (var pdf = new LibPdf(bytes))
    {
        byte[] pngBytes = pdf.GetImage(0,ImageType.PNG); // image type
        using (var outFile = File.Create(@"..\path\to\pdf\file.png")) // out file
        {
            outFile.Write(pngBytes, 0, pngBytes.Length);
        }
    }
}

ImageMagick, you should also look at this freely available and powerful tool. It's capable of doing what you want and also provides some .NET bindings (as well as bindings to several other languages).

In its simplest form, it's just like writing a command

convert file.pdf imagefile.png

Thanks a lot , I am still getting the exception "Could not load file or assembly 'libpdf.DLL' or one of its dependencies. The specified module could not be found. " ?

am also getting the same problem , my application is .net framework 4.can any one please suggest how to over come from this issue

This is old, but there's several DLLs the binary distribution of lib-pdf seem to be missing: QtXml4.dll, freetype.dll, and Zlib.dll... It's not clear to me which versions of Freetype and Zlib are needed (although Zlib doesn't change often), but you can examine the DLLs packaged with the distribution to figure out which 4.x version of QtXml4.dll is required. See qt-windows-binaries.googlecode.com/svn/site/QtWindowsBinaries .... that being said, I still haven't gotten this library to function properly.

Was LibPDF recommended based solely on a Google search? The code sample provided is just copied from their page. The problem is that, so far as I can tell, this library does not work. I messed with it for an hour or two with no success. There are quite a few people posting in the issues log that they cannot get it to work either.

c# - Convert PDF to Image without using Ghostscript DLL - Stack Overfl...

c#
Rectangle 27 7

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 7

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 7

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 10

//PdfiumAndroid (https://github.com/barteksc/PdfiumAndroid)
//https://github.com/barteksc/AndroidPdfViewer/issues/49
void generateImageFromPdf(Uri pdfUri) {
    int pageNumber = 0;
    PdfiumCore pdfiumCore = new PdfiumCore(this);
    try {
        //http://www.programcreek.com/java-api-examples/index.php?api=android.os.ParcelFileDescriptor
        ParcelFileDescriptor fd = getContentResolver().openFileDescriptor(pdfUri, "r");
        PdfDocument pdfDocument = pdfiumCore.newDocument(fd);
        pdfiumCore.openPage(pdfDocument, pageNumber);
        int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNumber);
        int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNumber);
        Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        pdfiumCore.renderPageBitmap(pdfDocument, bmp, pageNumber, 0, 0, width, height);
        saveImage(bmp);
        pdfiumCore.closeDocument(pdfDocument); // important!
    } catch(Exception e) {
        //todo with exception
    }
}

public final static String FOLDER = Environment.getExternalStorageDirectory() + "/PDF";
private void saveImage(Bitmap bmp) {
    FileOutputStream out = null;
    try {
        File folder = new File(FOLDER);
        if(!folder.exists())
            folder.mkdirs();
        File file = new File(folder, "PDF.png");
        out = new FileOutputStream(file);
        bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
    } catch (Exception e) {
        //todo with exception
    } finally {
        try {
            if (out != null)
                out.close();
        } catch (Exception e) {
            //todo with exception
        }
    }
}

Include library in build.gradle

compile 'com.github.barteksc:pdfium-android:1.4.0'

Call the method generateImageFromPdf(uri) by passing any PDF uri that is stored in your storage.

The method will generate the PDF.png in PDF folder of your storage.

You should really add some explanation as to why this code should work - you can also add comments in the code itself - in its current form, it does not provide any explanation which can help the rest of the community to understand what you did to solve/answer the question.

How can I get the "ParcelFileDescriptor fd" from Assets?

image - Generate Thumbnail of Pdf in Android - Stack Overflow

android image pdf pdfbox
Rectangle 27 3

You can use potrace to reduce the noise It vectorises the given image(bmp) and convert it to svg, pdf and some other formats

Character recognition (OCR algorithm) - Stack Overflow

ocr
Rectangle 27 25

You can easily convert 04-Request-Headers.pdf file pages into image format.

Convert all pdf pages into image format in Java using PDF Box.

or the maven dependency

<dependency>
    <groupId>org.apache.pdfbox</groupId>
    <artifactId>pdfbox</artifactId>
    <version>1.8.3</version>
</dependency>

Here is the solution:

package com.pdf.pdfbox.examples;

import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;

import javax.imageio.ImageIO;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

@SuppressWarnings("unchecked")
public class ConvertPDFPagesToImages {
    public static void main(String[] args) {
        try {
        String sourceDir = "C:/Documents/04-Request-Headers.pdf"; // Pdf files are read from this folder
        String destinationDir = "C:/Documents/Converted_PdfFiles_to_Image/"; // converted images from pdf document are saved here

        File sourceFile = new File(sourceDir);
        File destinationFile = new File(destinationDir);
        if (!destinationFile.exists()) {
            destinationFile.mkdir();
            System.out.println("Folder Created -> "+ destinationFile.getAbsolutePath());
        }
        if (sourceFile.exists()) {
            System.out.println("Images copied to Folder: "+ destinationFile.getName());             
            PDDocument document = PDDocument.load(sourceDir);
            List<PDPage> list = document.getDocumentCatalog().getAllPages();
            System.out.println("Total files to be converted -> "+ list.size());

            String fileName = sourceFile.getName().replace(".pdf", "");             
            int pageNumber = 1;
            for (PDPage page : list) {
                BufferedImage image = page.convertToImage();
                File outputfile = new File(destinationDir + fileName +"_"+ pageNumber +".png");
                System.out.println("Image Created -> "+ outputfile.getName());
                ImageIO.write(image, "png", outputfile);
                pageNumber++;
            }
            document.close();
            System.out.println("Converted Images are saved at -> "+ destinationFile.getAbsolutePath());
        } else {
            System.err.println(sourceFile.getName() +" File not exists");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}

Possible conversions of image into jpg, jpeg, png, bmp, gif format.

Note: I mentioned the mainly used image formats.

ImageIO.write(image , "jpg", new File( destinationDir +fileName+"_"+pageNumber+".jpg" ));
ImageIO.write(image , "jpeg", new File( destinationDir +fileName+"_"+pageNumber+".jpeg" ));
ImageIO.write(image , "png", new File( destinationDir +fileName+"_"+pageNumber+".png" ));
ImageIO.write(image , "bmp", new File( destinationDir +fileName+"_"+pageNumber+".bmp" ));
ImageIO.write(image , "gif", new File( destinationDir +fileName+"_"+pageNumber+".gif" ));
Images copied to Folder: Converted_PdfFiles_to_Image
Total files to be converted -> 13
Aug 06, 2014 1:35:49 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_1.png
Aug 06, 2014 1:35:50 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_2.png
Aug 06, 2014 1:35:51 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_3.png
Aug 06, 2014 1:35:51 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_4.png
Aug 06, 2014 1:35:52 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_5.png
Aug 06, 2014 1:35:52 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_6.png
Aug 06, 2014 1:35:53 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_7.png
Aug 06, 2014 1:35:53 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_8.png
Aug 06, 2014 1:35:54 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_9.png
Aug 06, 2014 1:35:54 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_10.png
Aug 06, 2014 1:35:54 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_11.png
Aug 06, 2014 1:35:55 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_12.png
Aug 06, 2014 1:35:55 PM org.apache.pdfbox.util.PDFStreamEngine processOperator
INFO: unsupported/disabled operation: i
Image Created -> 04-Request-Headers_13.png
Converted Images are saved at -> C:\Documents\Converted_PdfFiles_to_Image

It's slightly different for the latest version of PDFbox. Use the PDFRendered class.

pdf that has both text and image content has an issue. I have seen that after the final image(of the input pdf file) is generated the text data gets omitted, only image part (like background image etc) gets displayed. Any help in this regards is appreciated.

@yeppe provide pdf file as a link. I will provide input to you.

java - Convert a PDF file to image - Stack Overflow

java pdf pdf-generation pdfbox ghost4j
Rectangle 27 7

I dont think a php class will be the best for render an xHtml page with css.

What happen when a new css rule come out? (soon css 3.0...)

The best way to render an html page is, obvisiuly, a browser. Firefox 3.0 can natively 'print' in pdf format, torisugary developed an extension (command line print) to use it. Here you'll find it.

Anyway, there are still many problmes runninr firefox just as a pdf converter...

At the moment, i think that wkhtmltopdf is the best (that is the one used by the safari browser), fast, quick, awesome. Yes, opensource as well... Give it a look

PHP is useful if you want to output some type of official documentation such as a receipt for a user and you can use CSS to make it look nice.

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 7

I dont think a php class will be the best for render an xHtml page with css.

I dont think a php class will be the best for render an xHtml page with css.

What happen when a new css rule come out? (soon css 3.0...)

What happen when a new css rule come out? (soon css 3.0...)

The best way to render an html page is, obvisiuly, a browser. Firefox 3.0 can natively 'print' in pdf format, torisugary developed an extension (command line print) to use it. Here you'll find it.

The best way to render an html page is, obvisiuly, a browser. Firefox 3.0 can natively 'print' in pdf format, torisugary developed an extension (command line print) to use it. Here you'll find it.

Anyway, there are still many problmes runninr firefox just as a pdf converter...

Anyway, there are still many problmes runninr firefox just as a pdf converter...

At the moment, i think that wkhtmltopdf is the best (that is the one used by the safari browser), fast, quick, awesome. Yes, opensource as well... Give it a look

At the moment, i think that wkhtmltopdf is the best (that is the one used by the safari browser), fast, quick, awesome. Yes, opensource as well... Give it a look

PHP is useful if you want to output some type of official documentation such as a receipt for a user and you can use CSS to make it look nice.

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 7

I dont think a php class will be the best for render an xHtml page with css.

What happen when a new css rule come out? (soon css 3.0...)

The best way to render an html page is, obvisiuly, a browser. Firefox 3.0 can natively 'print' in pdf format, torisugary developed an extension (command line print) to use it. Here you'll find it.

Anyway, there are still many problmes runninr firefox just as a pdf converter...

At the moment, i think that wkhtmltopdf is the best (that is the one used by the safari browser), fast, quick, awesome. Yes, opensource as well... Give it a look

PHP is useful if you want to output some type of official documentation such as a receipt for a user and you can use CSS to make it look nice.

Convert HTML + CSS to PDF with PHP? - Stack Overflow

php html css pdf pdf-generation
Rectangle 27 0

LibPdf library converts converts PDF file to an image. Supported image formats are PNG and BMP, but you can easily add more.

using (FileStream file = File.OpenRead(@"..\path\to\pdf\file.pdf")) // in file
{
    var bytes = new byte[file.Length];
    file.Read(bytes, 0, bytes.Length);
    using (var pdf = new LibPdf(bytes))
    {
        byte[] pngBytes = pdf.GetImage(0,ImageType.PNG); // image type
        using (var outFile = File.Create(@"..\path\to\pdf\file.png")) // out file
        {
            outFile.Write(pngBytes, 0, pngBytes.Length);
        }
    }
}

ImageMagick, you should also look at this freely available and powerful tool. It's capable of doing what you want and also provides some .NET bindings (as well as bindings to several other languages).

In its simplest form, it's just like writing a command

convert file.pdf imagefile.png

Thanks a lot , I am still getting the exception "Could not load file or assembly 'libpdf.DLL' or one of its dependencies. The specified module could not be found. " ?

am also getting the same problem , my application is .net framework 4.can any one please suggest how to over come from this issue

This is old, but there's several DLLs the binary distribution of lib-pdf seem to be missing: QtXml4.dll, freetype.dll, and Zlib.dll... It's not clear to me which versions of Freetype and Zlib are needed (although Zlib doesn't change often), but you can examine the DLLs packaged with the distribution to figure out which 4.x version of QtXml4.dll is required. See qt-windows-binaries.googlecode.com/svn/site/QtWindowsBinaries .... that being said, I still haven't gotten this library to function properly.

Was LibPDF recommended based solely on a Google search? The code sample provided is just copied from their page. The problem is that, so far as I can tell, this library does not work. I messed with it for an hour or two with no success. There are quite a few people posting in the issues log that they cannot get it to work either.

c# - Convert PDF to Image without using Ghostscript DLL - Stack Overfl...

c#
Rectangle 27 0

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP.

There is no PHP-api, but you can always use it through PHP's exec functions.

Think I'd be able to run it with a hosted server?

Timthumb provides access to cutycapt, which may help with the "no PHP-api" problem.

php - Taking website screenshot, server-side, on a Linux rented server...

php linux website screenshot server-side
Rectangle 27 0

Apache PDF Box can convert PDFs to jpg,bmp,wbmp,png, and gif.

The library even comes with a command line utility called PDFToImage to do this.

If you download the source code and look at the PDFToImage class you should be able to figure out how to use PDF Box to convert PDFs to images from your own Java code.

it's somewhat inconsistent for images. If there is a "ColorPattern" (not an image but similar.. confusing) in the source PDF, it will not be copied over to the destination image. stackoverflow.com/questions/28589477/

but there may be improvements in PDFBox's 2.x release! (hoping)

PDF to image using Java - Stack Overflow

java image pdf jar
Rectangle 27 0

#! /usr/bin/env python

import os
import cgi
import cgitb 
cgitb.enable()
import sys

def check_file_extension(display_file):
    input_file = display_file
    nm,file_extension = os.path.splitext(display_file)
    return file_extension

form = cgi.FieldStorage()

type_of_file =''
file_nm = ''
nm =''
path = '/home/shantala/Documents'
not_found = 0

if form.has_key("file1"):
    file_nm = form["file1"].value

for f in next(os.walk(path))[2]:
    if str(f) == str(file_nm).strip():
        not_found = 0
        absolute_path_of_file = os.path.join(path, f)
        type_of_file = check_file_extension(absolute_path_of_file)
        if type_of_file == '.pdf':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: application/pdf\n'
            print file_read
        if type_of_file == '.txt':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: text/html\n'
            print file_read
        if type_of_file == '.png':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: image/png\n'
            print file_read
        if type_of_file == '.pdf':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: application/pdf\n'
            print file_read
        if type_of_file == '.JPG':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: image/jpg\n'
            print file_read
        if type_of_file == '.bmp':
            file_read = file(absolute_path_of_file,'rb').read()
            print  'Content-type: image/bmp\n'
            print file_read

        break
    else:
        not_found = 1

if not_found == 1:
    pass
    # print "%s" % str(file_nm) + " not found"

python - How to invoke webbrowser from cgi script? - Stack Overflow

python linux cgi webbrowser-control
Rectangle 27 0

You can use potrace to reduce the noise It vectorises the given image(bmp) and convert it to svg, pdf and some other formats

Character recognition (OCR algorithm) - Stack Overflow

ocr
Rectangle 27 0

You could use Ghostscript to convert your pdf to a png. A command like

gs -sDEVICE=png16m -r600 -o my_Map.png my_Map.pdf

would provide you a png from a pdf image.

Is there a tool or trick to store a large PDF image as a file (BMP/PNG...

pdf png converter
Rectangle 27 0

CutyCapt is a small cross-platform command-line utility to capture WebKit's rendering of a web page into a variety of vector and bitmap formats, including SVG, PDF, PS, PNG, JPEG, TIFF, GIF, and BMP.

It is already packaged in Debian (available since Squeeze) and Ubuntu.

debian - How can i make a screenshot of an HTML page (jpeg, png, etc.....

html debian screenshot jpeg
Rectangle 27 0

You'll need to use a PDF library, such as PDFSharp.

void DrawImage(XGraphics gfx, int number)
{
  BeginBox(gfx, number, "DrawImage (original)");

  XImage image = XImage.FromFile(jpegSamplePath);

  // Left position in point
  double x = (250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2;
  gfx.DrawImage(image, x, 0);

  EndBox(gfx);
}

well, event here "Don't repeat your self principle" should normally work. We need to re-factor questions and answers not duplicating them !

PdfDocument doc = new PdfDocument();             doc.Pages.Add(new PdfPage());             XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);             XImage img = XImage.FromFile(source);              xgr.DrawImage(img, 0, 0);             doc.Save(destinaton);             doc.Close();
Bitmap bitmap = new Bitmap(this.Width, this.Height);

Well, you could either draw to the PDF directly, or you could save your Bitmap to a file and use the path when calling XImage.FromFile(source).

c# - How to save bmp as pdf? - Stack Overflow

c# visual-studio
Rectangle 27 0

I use GraphViz to generate this sort of graph. My app generates the .dot file that can then is then passed into GraphViz. It supports a load of file formats, such as bmp, jpg, png, pdf, svg etc etc.

graphics - C# graph drawing library? - Stack Overflow

c# graphics graph-theory
Rectangle 27 0

BMP
JPEG/JFIF
TIFF
GIF
PNG
PDF

Apache POI can read doc, docx, xls and xlsx, but I am not aware of an easy way to convert them to an image (if that is what you would want to do). What you could probably do is make a conversion to a PDF first and then from PDF to an image.

thank you very much...

How to convert images with following extensions jpg, pdf, gif, xls, xl...

java image-conversion