利用Ghostscript提供的gsapi_vb实现转postscript为PDF,进一步成功把VB.NET代码转为C#。
所用GhostScript为AFPL Ghostscript 8.53
附上GhostScript提供的VB.NET代码:
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。' Copyright (c) 2002 Dan Mount and Ghostgum Software Pty Ltd
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 Permission is hereby granted, free of charge, to any person obtaining 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 a copy of this software and associated documentation files (the 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 "Software"), to deal in the Software without restriction, including
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 without limitation the rights to use, copy, modify, merge, publish, 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 distribute, sublicense, and/or sell copies of the Software, and to
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 permit persons to whom the Software is furnished to do so, subject to 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 the following conditions:
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 The above copyright notice and this permission notice shall be
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 included in all copies or substantial portions of the Software.
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 SOFTWARE.
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。

实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
' This is an example of how to call the Ghostscript DLL from
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 Visual Basic.NET.  There are two examples, one converts
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 colorcir.ps to PDF, the other is like command line Ghostscript.
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 The display device is not supported.
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 This code is not compatible with VB6.  There is another
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 example which does work with VB6.  Differences include:
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 1. VB.NET uses GCHandle to get pointer
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
    VB6 uses StrPtr/VarPtr
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 2. VB.NET Integer is 32bits, Long is 64bits
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
    VB6 Integer is 16bits, Long is 32bits
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 3. VB.NET uses IntPtr for pointers
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
    VB6 uses Long for pointers
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 4. VB.NET strings are always Unicode
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
    VB6 can create an ANSI string
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
 See the following URL for some VB6 / VB.NET details
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。'
  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvb600/html/vb6tovbdotnet.asp
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。

实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
Option Explicit On 
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。
Imports System.Runtime.InteropServices
实现用C#和VB.NET调用Ghostscript的API,把Postscript文件转为PDF文件。

相关文章: