Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

No commit message

  • Loading branch information...
commit 3d080deda6e103d563d966bf2ac7598f491448ea 1 parent c857d4a
Dash Dash authored
Showing with 99 additions and 11 deletions.
  1. +99 −11 GhostScriptSharp/GhostscriptSharp.cs
110 GhostScriptSharp/GhostscriptSharp.cs
View
@@ -82,25 +82,35 @@ private static void CallAPI(string[] args)
{
// Get a pointer to an instance of the Ghostscript API and run the API with the current arguments
IntPtr gsInstancePtr;
- CreateAPIInstance(out gsInstancePtr, IntPtr.Zero);
- try
+ lock (resourceLock)
{
+ CreateAPIInstance(out gsInstancePtr, IntPtr.Zero);
+ try
+ {
+
+
- int result = InitAPI(gsInstancePtr, args.Length, args);
+ int result = InitAPI(gsInstancePtr, args.Length, args);
- if (result < 0)
+ if (result < 0)
+ {
+ throw new ExternalException("Ghostscript conversion error", result);
+ }
+
+ }
+ finally
{
- throw new ExternalException("Ghostscript conversion error", result);
+ Cleanup(gsInstancePtr);
}
-
- }
- finally
- {
- Cleanup(gsInstancePtr);
}
}
/// <summary>
+ /// GS can only support a single instance, so we need to bottleneck any multi-threaded systems.
+ /// </summary>
+ private static object resourceLock = new object();
+
+ /// <summary>
/// Frees up the memory used for the API arguments and clears the Ghostscript API instance
/// </summary>
private static void Cleanup(IntPtr gsInstancePtr)
@@ -382,4 +392,82 @@ public System.Drawing.Size Manual
/// <summary>
/// Standard paper size
- %
+ /// </summary>
+ public GhostscriptPageSizes Native
+ {
+ set
+ {
+ this._fixed = value;
+ this._manual = new System.Drawing.Size(0, 0);
+ }
+ get
+ {
+ return this._fixed;
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Native page sizes
+ /// </summary>
+ /// <remarks>
+ /// Missing 11x17 as enums can't start with a number, and I can't be bothered
+ /// to add in logic to handle it - if you need it, do it yourself.
+ /// </remarks>
+ public enum GhostscriptPageSizes
+ {
+ UNDEFINED,
+ ledger,
+ legal,
+ letter,
+ lettersmall,
+ archE,
+ archD,
+ archC,
+ archB,
+ archA,
+ a0,
+ a1,
+ a2,
+ a3,
+ a4,
+ a4small,
+ a5,
+ a6,
+ a7,
+ a8,
+ a9,
+ a10,
+ isob0,
+ isob1,
+ isob2,
+ isob3,
+ isob4,
+ isob5,
+ isob6,
+ c0,
+ c1,
+ c2,
+ c3,
+ c4,
+ c5,
+ c6,
+ jisb0,
+ jisb1,
+ jisb2,
+ jisb3,
+ jisb4,
+ jisb5,
+ jisb6,
+ b0,
+ b1,
+ b2,
+ b3,
+ b4,
+ b5,
+ flsa,
+ flse,
+ halfletter
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.