Click here to Skip to main content
15,886,693 members
Articles / Programming Languages / C#

How To Convert PDF to Image Using Ghostscript API

Rate me:
Please Sign up or sign in to vote.
4.89/5 (76 votes)
28 Mar 2010CPOL4 min read 2.1M   45.3K   229  
How to use Ghostscript library to create an image (or images) from a PDF file
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <metadata name="fileSystemWatcher.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        AAABAAIAEBAAAAAACABoBQAAJgAAACAgAAAAAAgAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAAAB
        AAAAAAAAAAAAAAABAAAAAQAAAAAAAP///wBmi4oA2cCpAHhJOACr390AspB+AD5eXgCYsasA7ODUAIBo
        XgDK+PUAvqWaAEZGRgD18OsA4NDCAIVZSQCEqqgAuJuMAFyAgAC65uMA1sS5ALDV0wDg1dAA7+fiAMOt
        pAD6+PUAg2BUAMHt6wB7UUEAyK6bAOfWyQB/VUYA6dvOANvHtQCYrKYA/fv6AOLa0gB4TTwA5NPDAINj
        WADt4tgA7ObgAOHSxQB6SzoAg1tLAHdLOgDJ9vMA6NnMAOXVxQDVwrcAeU4+APv59wCAV0cAg1hIAPTv
        7QC9pJgA/fz8AOXWxwB5SjkAelBAAH5URQCGWkoAeEw7APr39ADt5eAA2sa1ANnBqgCxkX4AmK2nALic
        jQB5SjgAd0o6AHp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AAAHFC8WBwAAAAAAAAAAAAAA
        BxMRAgcAAAAAAAAAAAAAAAccCwUHAAAAAAAAAAAAACgtIyMICgAAAAAAAAAAACASJyEnQkQtAAAAAAAA
        ACAyJwA5AABDHi0AAAAAAAAMCQA5AAAAAENEGwAAAAA9QQAAOQAAAAAAQi0AAAAALEAAADkOQSUAAB8s
        AAAAACw5AAA5OTk5AAAhLAAAAAA9NwAAAAAAAAAAJz0AAAAAABk0AAAAAAAAJxIAAAAAAAAsFzQAAAAA
        QRU9AAAAAAAAACwZNzk0QQwsAAAAAAAAAAAAAC4sLC4AAAAAAAD/fwAA/B8AAPwfAAD8HwAA+B8AAPAP
        AADixwAA5eMAAM3zAADMMwAAzDMAAM/zAADn5wAA48cAAPAPAAD8PwAAKAAAACAAAABAAAAAAQAIAAAA
        AAAABAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICAAADAwMAAwNzAAPDK
        pgAEBAQACAgIAAwMDAAREREAFhYWABwcHAAiIiIAKSkpAFVVVQBNTU0AQkJCADk5OQCAfP8AUFD/AJMA
        1gD/7MwAxtbvANbn5wCQqa0AAAAzAAAAZgAAAJkAAADMAAAzAAAAMzMAADNmAAAzmQAAM8wAADP/AABm
        AAAAZjMAAGZmAABmmQAAZswAAGb/AACZAAAAmTMAAJlmAACZmQAAmcwAAJn/AADMAAAAzDMAAMxmAADM
        mQAAzMwAAMz/AAD/ZgAA/5kAAP/MADMAAAAzADMAMwBmADMAmQAzAMwAMwD/ADMzAAAzMzMAMzNmADMz
        mQAzM8wAMzP/ADNmAAAzZjMAM2ZmADNmmQAzZswAM2b/ADOZAAAzmTMAM5lmADOZmQAzmcwAM5n/ADPM
        AAAzzDMAM8xmADPMmQAzzMwAM8z/ADP/MwAz/2YAM/+ZADP/zAAz//8AZgAAAGYAMwBmAGYAZgCZAGYA
        zABmAP8AZjMAAGYzMwBmM2YAZjOZAGYzzABmM/8AZmYAAGZmMwBmZmYAZmaZAGZmzABmmQAAZpkzAGaZ
        ZgBmmZkAZpnMAGaZ/wBmzAAAZswzAGbMmQBmzMwAZsz/AGb/AABm/zMAZv+ZAGb/zADMAP8A/wDMAJmZ
        AACZM5kAmQCZAJkAzACZAAAAmTMzAJkAZgCZM8wAmQD/AJlmAACZZjMAmTNmAJlmmQCZZswAmTP/AJmZ
        MwCZmWYAmZmZAJmZzACZmf8AmcwAAJnMMwBmzGYAmcyZAJnMzACZzP8Amf8AAJn/MwCZzGYAmf+ZAJn/
        zACZ//8AzAAAAJkAMwDMAGYAzACZAMwAzACZMwAAzDMzAMwzZgDMM5kAzDPMAMwz/wDMZgAAzGYzAJlm
        ZgDMZpkAzGbMAJlm/wDMmQAAzJkzAMyZZgDMmZkAzJnMAMyZ/wDMzAAAzMwzAMzMZgDMzJkAzMzMAMzM
        /wDM/wAAzP8zAJn/ZgDM/5kAzP/MAMz//wDMADMA/wBmAP8AmQDMMwAA/zMzAP8zZgD/M5kA/zPMAP8z
        /wD/ZgAA/2YzAMxmZgD/ZpkA/2bMAMxm/wD/mQAA/5kzAP+ZZgD/mZkA/5nMAP+Z/wD/zAAA/8wzAP/M
        ZgD/zJkA/8zMAP/M/wD//zMAzP9mAP//mQD//8wAZmb/AGb/ZgBm//8A/2ZmAP9m/wD//2YAIQClAF9f
        XwB3d3cAhoaGAJaWlgDLy8sAsrKyANfX1wDd3d0A4+PjAOrq6gDx8fEA+Pj4APD7/wCkoKAAgICAAAAA
        /wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAKCgoKAAoKCgoKCgoKCgoKCgoKCgoKCgoKCgAKCgoKCgoK
        CgoACgoKCgoKCgoKCg8PCgoKCgoKCgoKAAoKCgoKCgoKCgAKCgoKCgoKCgwT6uoTCgoKCgoKCgoACgoK
        CgoKCgoKAAoKCgoKCgoKFOoHB20VCgoKCgoKCgAKCgoKCgoKCgoACgoKCgoKQxQUFEoUFBQUDgoKCgoK
        AAoKCgoKCgoKCgAKCgoKCgpKShyZGpmZc0oUIgoKCgoACgoKCgoKCgoKAAoKCgoKCkpz9sPDGhwcc0oK
        CgoKCgAKCgoKCgoKCgoACgoKCgoKSkocG8MametKSgoKCgoKAAoKCgoKCgoKCgAKCgoKCgpKURoaGpkc
        HHNKCgoKCgoACgoKCgoKCgoKAAoKCgoKCkp57+zrbevr6hQKCgoKCgAKCgoKCgoKCgoACgoKCgoKEuvv
        8PLz8/Dt6hIKCgoKAAoKCgoKCgoKCgAKCgoKCm3r8Lzt75kc8PP3bQoKCgoACgoKCgoKCgoKAAoKCgoK
        67zx7+wHB+y89P/rbQoKCgAKCgoKCgoKCgoACgoKCm3rGQkHB/P07+/09PdtCgoKAAoKCgoKCgoKCgAK
        CgoKbezxCfDx8/PzvPP0vG0KCgoACgoKCgoKCgoKAAoKCm3rvAnxGfHy8/P09PP0620KCgAKCgoKCgoK
        CgoACgptbbsJCfTx8/Pz8vHy8fPz620KAAoKCgoKCgoKCgAKCuu1Cbvz///z8fDw8PK88BnzbW0ACgoK
        CgoKCgoKAAptkQm1u//y8N3x3fHxvLwJCfPvbQAKCgoKCgoKCgoACuu1tbUJ8fHy8vPz8t0J8wkJCfLr
        AAoKCgoKCgoKCgAKbbu0u/Dx8fHy8/Pz890JCQm79G0ACgoKCgoKCgoKAAptCbQJ3fHx8fLy8/Pz8gkJ
        u7v0bQAKCgoKCgoKCgoACm27tAnw3fHx8fLy8vLx8bu7u/RtAAoKCgoKCgoKCgAK67W0Cd0Z8fHx8fHx
        8fHxu7UJ3esACgoKCgoKCgoKAAptkbUJ3d3x8fHx8fHx8fG7td33bQAKCgoKCgoKCgoACm3rtbQJ3fHx
        8fHx8fHxCbW78ettAAoKCgoKCgoKCgAKCm2uCbQJ3fHx8fHx8d27tRmRbQoACgoKCgoKCgoKAAoKCm2R
        CbW0uwnw3QkJu7UZ920KCgAKCgoKCgoKCgoACgoKrm3suwm1tLS0tLUJvOxtrgoKAAoKCgoKCgoKCgAK
        CgoKCm1t7LUJCQkJu+1tbQoKCgoACgoKCgoKCgoKAAoKCgoKCm1t6+ttbevrbW0KCgoKCgAKCgoKCgoK
        CgoACgoKCgoKCgoKCgoKCgoKCgoKCgoKAAoKCgoK///////+f///+D////gf///gB///4AP//+AH///g
        B///4Af//+AH///gA///wAP//8AB//+AAf//gAH//wAA//4AAH/+AAA//AAAP/wAAD/8AAA//AAAP/wA
        AD/8AAA//AAAP/wAAD/+AAB//wAA//8AAP//wAP//+AH//////8=
</value>
  </data>
</root>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions