Is it possible to convert PDF page to Image using itextSharp?

Max

Hi I have been using itextSharp for all pdf related projects in dot.net. I came across a requirement where I need to convert PDF pages to images. I could not find any sample of such a thing. I found that another tool ghostscript is able to do it the problem with that is I am on a shared hosting & I don't think ghostscript will run on server as in my local machine I had to manually copy ghost script dlls to system32 folder which is not possible in a shared hosting.

Max

Ok I searched all over and found out that there is a nuget package for Ghost Script, so problem for me was solved by going to package manager console and adding ghost script to fresh project (I created a fresh project since the old one had all kinds of reference to win32 ghostscript dlls) by "PM> Install-Package Ghostscript.NET". So the answer to my question is: 1.> itextSharp cannot directly convert PDF pages to image. 2.> The "Ghostscript.NET 1.2.0" does it quite easily. Following is a code example.

    public void LoadImage(string InputPDFFile,int PageNumber)
    {

        string outImageName = Path.GetFileNameWithoutExtension(InputPDFFile);
        outImageName = outImageName+"_"+PageNumber.ToString() + "_.png";


        GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png256);
        dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
        dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
        dev.ResolutionXY = new GhostscriptImageDeviceResolution(290, 290);
        dev.InputFiles.Add(InputPDFFile);
        dev.Pdf.FirstPage = PageNumber;
        dev.Pdf.LastPage = PageNumber;
        dev.CustomSwitches.Add("-dDOINTERPOLATE");
        dev.OutputPath = Server.MapPath(@"~/tempImages/" + outImageName);
        dev.Process();

    }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Convert HTML to PDF using itextsharp

From Dev

center image in pdf using itextsharp

From Dev

Is it possible to load XMP file in PDF using iTextSharp?

From Dev

Is it possible to load XMP file in PDF using iTextSharp?

From Java

How to convert HTML to PDF using iTextSharp

From Dev

Convert html with Persian characters to pdf using iTextSharp

From Dev

Convert MVC 4 View To Pdf using Itextsharp

From Dev

how to get pdf image orientation using itextsharp

From Dev

Image going to second page of PDF VB.Net iTextSharp

From Dev

Html to PDF ITextSharp Image

From Dev

Using itextsharp xmlworker to convert html to pdf and write text vertically

From Dev

Find location last object on PDF page using iTextSharp

From Dev

how to add pagenumbers to every pdf page using itextsharp

From Dev

Add signature image on PDF without digitally signing it using iTextSharp

From Dev

How can I get the resolution of an embeded image in a PDF using ITextSharp

From Dev

How to use iTextSharp to convert to PDF

From Dev

iTextSharp - PDF Bookmark not pointing to a page

From Dev

itextsharp adding image to existing pdf

From Dev

Is it possible to create an image library in iTextsharp?

From Dev

Is it possible to draw a pdf vector image inside a larger pdf page?

From Dev

How to break pdf page in itextsharp pdf

From Dev

itextsharp - convert page to PDF and auto save to a temp folder without opening a download dialog

From Dev

Convert html page into pdf using php

From Dev

Rotate a PDF using Powershell and iTextSharp

From Dev

Cannot convert PDF to image using PHP and ImageMagick

From Dev

Cannot convert PDF to image using PHP and ImageMagick

From Dev

Add Page bookmarks to an existing PDF using iTextSharp using C# code

From Dev

Add Page bookmarks to an existing PDF using iTextSharp using C# code

From Dev

Saving Each PDF Page to an Image Using Imagick

Related Related

  1. 1

    Convert HTML to PDF using itextsharp

  2. 2

    center image in pdf using itextsharp

  3. 3

    Is it possible to load XMP file in PDF using iTextSharp?

  4. 4

    Is it possible to load XMP file in PDF using iTextSharp?

  5. 5

    How to convert HTML to PDF using iTextSharp

  6. 6

    Convert html with Persian characters to pdf using iTextSharp

  7. 7

    Convert MVC 4 View To Pdf using Itextsharp

  8. 8

    how to get pdf image orientation using itextsharp

  9. 9

    Image going to second page of PDF VB.Net iTextSharp

  10. 10

    Html to PDF ITextSharp Image

  11. 11

    Using itextsharp xmlworker to convert html to pdf and write text vertically

  12. 12

    Find location last object on PDF page using iTextSharp

  13. 13

    how to add pagenumbers to every pdf page using itextsharp

  14. 14

    Add signature image on PDF without digitally signing it using iTextSharp

  15. 15

    How can I get the resolution of an embeded image in a PDF using ITextSharp

  16. 16

    How to use iTextSharp to convert to PDF

  17. 17

    iTextSharp - PDF Bookmark not pointing to a page

  18. 18

    itextsharp adding image to existing pdf

  19. 19

    Is it possible to create an image library in iTextsharp?

  20. 20

    Is it possible to draw a pdf vector image inside a larger pdf page?

  21. 21

    How to break pdf page in itextsharp pdf

  22. 22

    itextsharp - convert page to PDF and auto save to a temp folder without opening a download dialog

  23. 23

    Convert html page into pdf using php

  24. 24

    Rotate a PDF using Powershell and iTextSharp

  25. 25

    Cannot convert PDF to image using PHP and ImageMagick

  26. 26

    Cannot convert PDF to image using PHP and ImageMagick

  27. 27

    Add Page bookmarks to an existing PDF using iTextSharp using C# code

  28. 28

    Add Page bookmarks to an existing PDF using iTextSharp using C# code

  29. 29

    Saving Each PDF Page to an Image Using Imagick

HotTag

Archive