RubyPDF Blog PDF Convert PDF to Bitmap with PDFium

Convert PDF to Bitmap with PDFium

After successfully build PDFium with Microsoft Visual C++ 2000 Express,  I begin my first attempt,  tried to convert PDF to Bitmap.

To simplify the job, I do not want use some big Image Library, such as FreeImage, ImageMagick,  GraphicsMagick, OpenImageIO and so on.

After some research, I found EasyBMP, a simple, cross-platform, open source (revised BSD) C++ library designed for easily reading, writing, and modifying Windows bitmap (BMP) image files.

Simply add EasyBMP.cpp, EasyBMP.h, EasyBMP_BMP.h, EasyBMP_DataStructures.h,  EasyBMP_VariousBMPutilities.h to project pdfium_test, and use the following code, we can easily convert PDF to Bitmap.

 

 

here is the example, pdfium_test.zip(Win32 pre-build, 3.77M), the usage is same as the original pdfium_test.exe, but convert PDF to PPM and BMP at the same time.

P.S.

From this example, we know PDFium is not only an open-source PDF rendering engine for Chrome, we can do many jobs with the help of it.

 

2 thoughts on “Convert PDF to Bitmap with PDFium”

  1. I’ve just checked out the latest source code of PDFium, it seems that pdfium_test supports writing to BMP and even scale now!

    As being able to scale up/down will be a very useful feature, would you mind to share the ready to build source repository on github or oschina so that we can simply merge from master and build to have an up-to-date pdfium_test easily?

    commit cedc562477cbca7496bd88999b773b72912c40f8
    Author: Tom Sepez
    Date: Thu Jan 29 15:48:15 2015 -0800

    Merge to Master: Add output scale factor command line parameter to pdfium_test.

    Original Review URL: https://codereview.chromium.org/861203003

    TBR=thestig@chromium.org

    Review URL: https://codereview.chromium.org/889733002

    commit 9e0177a5337117f00d2a891d17d3dd491764ce24
    Author: Vitaly Buka
    Date: Tue Jul 22 18:15:42 2014 -0700

    Added options to save pages into BMP and EMF on Windows.

    BUG=179413
    R=bo_xu@foxitsoftware.com

    Review URL: https://codereview.chromium.org/408403002

  2. Sorry Steven, I’ve installed svn and checked out the depot_tool and then used gsclient as instructed (it will then download the necessary tools) and be able to build using Ninja with Visual Studio Community 2013 installed.

    I think that Ninja is a great build system that I don’t even need to build the project from VS!

    Thus I think no need to share the projects / solution files.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.