csharp: Cyotek.GhostScript.Pdf Conversion pdf convert image x64

NativeMethods.cs  x64

using System;
using System.Runtime.InteropServices;

namespace Cyotek.GhostScript
{
     /// <summary>
    /// 64位
    ///  https://github.com/kelter-antunes/Cyotek.GhostScript.x64 64位
    /// </summary>
  internal class NativeMethods
  {
  #region  Public Class Methods  

    // void gsapi_delete_instance (void *instance);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_delete_instance")]
    public static extern void gsapi_delete_instance(IntPtr instance);

    // int gsapi_exit (void *instance);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_exit")]
    public static extern int gsapi_exit(IntPtr instance);

    // int gsapi_set_poll (void *instance, int(*poll_fn)(void *caller_handle));
    // int gsapi_set_display_callback (void *instance, display_callback *callback);
    // int gsapi_init_with_args (void *instance, int argc, char **argv);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_init_with_args")]
    public static extern int gsapi_init_with_args(IntPtr instance, int argc, IntPtr argv);

    //int gsapi_new_instance (void **pinstance, void *caller_handle);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_new_instance")]
    public static extern int gsapi_new_instance(out IntPtr pinstance, IntPtr caller_handle);

    // int gsapi_revision (gsapi_revision_t *pr, int len);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_revision")]
    public static extern int gsapi_revision(out NativeStructs.GS_Revision pr, int len);

    // int gsapi_run_string_begin (void *instance, int user_errors, int *pexit_code);
    // int gsapi_run_string_continue (void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code);
    // int gsapi_run_string_end (void *instance, int user_errors, int *pexit_code);
    // int gsapi_run_string_with_length (void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code);
    // int gsapi_run_string (void *instance, const char *str, int user_errors, int *pexit_code);
    // int gsapi_run_file (void *instance, const char *file_name, int user_errors, int *pexit_code);
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_run_file")]
    public static extern int gsapi_run_file(IntPtr instance, string file_name, int user_errors, int pexit_code);

    //int gsapi_set_stdio (void *instance, int(*stdin_fn)(void *caller_handle, char *buf, int len), int(*stdout_fn)(void *caller_handle, const char *str, int len), int(*stderr_fn)(void *caller_handle, const char *str, int len));
    [DllImport("gsdll64.dll", EntryPoint = "gsapi_set_stdio")]
    public static extern int gsapi_set_stdio(IntPtr instance, StdioCallBack stdin_fn, StdioCallBack stdout_fn, StdioCallBack stderr_fn);

  #endregion  Public Class Methods  

    // int gsapi_set_visual_tracer (gstruct vd_trace_interface_s *I);
  }
}

  

 

NativeMethods.cs  x32

using System;
using System.Runtime.InteropServices;

namespace Cyotek.GhostScript
{


    /// <summary>
    /// 32位
    ///  https://github.com/kelter-antunes/Cyotek.GhostScript.x64 64位
    /// </summary>
  internal class NativeMethods
  {
      #region  Public Class Methods  

    // void gsapi_delete_instance (void *instance);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_delete_instance")]
    public static extern void gsapi_delete_instance(IntPtr instance);

    // int gsapi_exit (void *instance);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_exit")]
    public static extern int gsapi_exit(IntPtr instance);

    // int gsapi_set_poll (void *instance, int(*poll_fn)(void *caller_handle));
    // int gsapi_set_display_callback (void *instance, display_callback *callback);
    // int gsapi_init_with_args (void *instance, int argc, char **argv);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")]
    public static extern int gsapi_init_with_args(IntPtr instance, int argc, IntPtr argv);

    //int gsapi_new_instance (void **pinstance, void *caller_handle);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_new_instance")]
    public static extern int gsapi_new_instance(out IntPtr pinstance, IntPtr caller_handle);

    // int gsapi_revision (gsapi_revision_t *pr, int len);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_revision")]
    public static extern int gsapi_revision(out NativeStructs.GS_Revision pr, int len);

    // int gsapi_run_string_begin (void *instance, int user_errors, int *pexit_code);
    // int gsapi_run_string_continue (void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code);
    // int gsapi_run_string_end (void *instance, int user_errors, int *pexit_code);
    // int gsapi_run_string_with_length (void *instance, const char *str, unsigned int length, int user_errors, int *pexit_code);
    // int gsapi_run_string (void *instance, const char *str, int user_errors, int *pexit_code);
    // int gsapi_run_file (void *instance, const char *file_name, int user_errors, int *pexit_code);
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_run_file")]
    public static extern int gsapi_run_file(IntPtr instance, string file_name, int user_errors, int pexit_code);

    //int gsapi_set_stdio (void *instance, int(*stdin_fn)(void *caller_handle, char *buf, int len), int(*stdout_fn)(void *caller_handle, const char *str, int len), int(*stderr_fn)(void *caller_handle, const char *str, int len));
    [DllImport("gsdll32.dll", EntryPoint = "gsapi_set_stdio")]
    public static extern int gsapi_set_stdio(IntPtr instance, StdioCallBack stdin_fn, StdioCallBack stdout_fn, StdioCallBack stderr_fn);

  #endregion  Public Class Methods  

    // int gsapi_set_visual_tracer (gstruct vd_trace_interface_s *I);
  }
}

  

pdf View 在线预览 Web or Win

https://www.cyotek.com/blog/convert-a-pdf-into-a-series-of-images-using-csharp-and-ghostscript

https://www.cyotek.com/source-code

https://www.codeproject.com/Articles/317700/Convert-a-PDF-into-a-series-of-images-using-Csharp

https://www.cyotek.com/blog/extending-the-imagebox-component-to-display-the-contents-of-a-pdf-file-using-csharp#files

https://github.com/ArtifexSoftware/ghostpdl-downloads/releases
https://www.ghostscript.com/releases/gsdnld.html

webform:

csharp: Cyotek.GhostScript.Pdf Conversion pdf convert image x64

winform:

 

csharp: Cyotek.GhostScript.Pdf Conversion pdf convert image x64

 

上一篇:四、configparser模块


下一篇:【Hadoop离线基础总结】Apache Hadoop的三种运行环境介绍及standAlone环境搭建