Quantcast
Channel: Ghostscript.NET
Viewing all 393 articles
Browse latest View live

New Post: change image orientation.

$
0
0
Great, thanks for letting me know it works.

Cheers,
Josip

New Post: Additional information: An error occured when call to 'gsapi_new_instance' is made: -100

$
0
0
I also tried to replace the offending statement with the more I also tried to replace the offending statement with the more explicit one, but consistently getting -15 error now.
rasterizer.Open(ms, GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL,GhostscriptLicense.GPL), true);

Created Unassigned: Arithmetic operation resulted in an overflow [2243]

$
0
0
Hello,

i get following exception while converting PDF to image...
i use ghostscript 9.14 and ghostscript.net 1.1.8

thanks..

```
An exception of type 'System.OverflowException' occurred.
---------------------------------------------------------
08/12/2014 14:52:34
Type : System.OverflowException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Arithmetic operation resulted in an overflow.
Source : Ghostscript.NET
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void FinalizeSections(MEMORY_MODULE*)
HResult : -2146233066
Stack Trace : at Microsoft.WinAny.Interop.DynamicNativeLibrary.FinalizeSections(MEMORY_MODULE* memory_module)
at Microsoft.WinAny.Interop.DynamicNativeLibrary.MemoryLoadLibrary(Byte[] data)
at Microsoft.WinAny.Interop.DynamicNativeLibrary..ctor(Byte[] buffer)
at Ghostscript.NET.GhostscriptLibrary..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(MemoryStream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

```


using that code

```
MemoryStream ms = new MemoryStream();
GhostscriptVersionInfo _lastInstalledVersion = null;
GhostscriptRasterizer _rasterizer = null;
byte[] pdfByteArray = <<<This is a method parameter>>>;
List<byte[]> exportedImageByteList = new List<byte[]>();

try
{
int desired_x_dpi = 300;
int desired_y_dpi = 300;

_lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);

_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(new MemoryStream(pdfByteArray), _lastInstalledVersion, true);

Logger.Info("This Log will not hit when exception occurs");

for (int i = 1; i < _rasterizer.PageCount+1; i++)
{
ms.Position = 0;
System.Drawing.Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, i);
img.Save(ms, ImageFormat.Gif);
ms.Position = 0;
exportedImageByteList.Add(ms.ToArray());
}

}
catch (Exception ex)
{
Logger.ErrorException("Exception !!!", ex);
}
```

Commented Unassigned: Arithmetic operation resulted in an overflow [2243]

$
0
0
Hello,

i get following exception while converting PDF to image...
i use ghostscript 9.14 and ghostscript.net 1.1.8

thanks..

```
An exception of type 'System.OverflowException' occurred.
---------------------------------------------------------
08/12/2014 14:52:34
Type : System.OverflowException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Arithmetic operation resulted in an overflow.
Source : Ghostscript.NET
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void FinalizeSections(MEMORY_MODULE*)
HResult : -2146233066
Stack Trace : at Microsoft.WinAny.Interop.DynamicNativeLibrary.FinalizeSections(MEMORY_MODULE* memory_module)
at Microsoft.WinAny.Interop.DynamicNativeLibrary.MemoryLoadLibrary(Byte[] data)
at Microsoft.WinAny.Interop.DynamicNativeLibrary..ctor(Byte[] buffer)
at Ghostscript.NET.GhostscriptLibrary..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(MemoryStream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

```


using that code

```
MemoryStream ms = new MemoryStream();
GhostscriptVersionInfo _lastInstalledVersion = null;
GhostscriptRasterizer _rasterizer = null;
byte[] pdfByteArray = <<<This is a method parameter>>>;
List<byte[]> exportedImageByteList = new List<byte[]>();

try
{
int desired_x_dpi = 300;
int desired_y_dpi = 300;

_lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);

_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(new MemoryStream(pdfByteArray), _lastInstalledVersion, true);

Logger.Info("This Log will not hit when exception occurs");

for (int i = 1; i < _rasterizer.PageCount+1; i++)
{
ms.Position = 0;
System.Drawing.Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, i);
img.Save(ms, ImageFormat.Gif);
ms.Position = 0;
exportedImageByteList.Add(ms.ToArray());
}

}
catch (Exception ex)
{
Logger.ErrorException("Exception !!!", ex);
}
```
Comments: ** Comment from web user: josip **

Can you please tell me more details about the system you are using? (exact Windows version, 32 bit or 64 bit, memory size...)

Workaround for this would be:
_rasterizer.Open(new MemoryStream(pdfByteArray), _lastInstalledVersion, false);
this will force Ghostscript.NET to use standard LoadLibrary instead of the DynamicNativeLibrary.

Cheers,
Josip

Commented Unassigned: Arithmetic operation resulted in an overflow [2243]

$
0
0
Hello,

i get following exception while converting PDF to image...
i use ghostscript 9.14 and ghostscript.net 1.1.8

thanks..

```
An exception of type 'System.OverflowException' occurred.
---------------------------------------------------------
08/12/2014 14:52:34
Type : System.OverflowException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Arithmetic operation resulted in an overflow.
Source : Ghostscript.NET
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : Void FinalizeSections(MEMORY_MODULE*)
HResult : -2146233066
Stack Trace : at Microsoft.WinAny.Interop.DynamicNativeLibrary.FinalizeSections(MEMORY_MODULE* memory_module)
at Microsoft.WinAny.Interop.DynamicNativeLibrary.MemoryLoadLibrary(Byte[] data)
at Microsoft.WinAny.Interop.DynamicNativeLibrary..ctor(Byte[] buffer)
at Ghostscript.NET.GhostscriptLibrary..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter..ctor(GhostscriptVersionInfo version, Boolean fromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(Stream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)
at Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(MemoryStream stream, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

```


using that code

```
MemoryStream ms = new MemoryStream();
GhostscriptVersionInfo _lastInstalledVersion = null;
GhostscriptRasterizer _rasterizer = null;
byte[] pdfByteArray = <<<This is a method parameter>>>;
List<byte[]> exportedImageByteList = new List<byte[]>();

try
{
int desired_x_dpi = 300;
int desired_y_dpi = 300;

_lastInstalledVersion =
GhostscriptVersionInfo.GetLastInstalledVersion(
GhostscriptLicense.GPL | GhostscriptLicense.AFPL,
GhostscriptLicense.GPL);

_rasterizer = new GhostscriptRasterizer();
_rasterizer.Open(new MemoryStream(pdfByteArray), _lastInstalledVersion, true);

Logger.Info("This Log will not hit when exception occurs");

for (int i = 1; i < _rasterizer.PageCount+1; i++)
{
ms.Position = 0;
System.Drawing.Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, i);
img.Save(ms, ImageFormat.Gif);
ms.Position = 0;
exportedImageByteList.Add(ms.ToArray());
}

}
catch (Exception ex)
{
Logger.ErrorException("Exception !!!", ex);
}
```
Comments: ** Comment from web user: idemirel **

i am using that in service layer on win2012x64 (virtual) with 8GB of RAM, to produce images from PDFs which i already have.

i will try to open rasterizer with "false" option..

thanks
ibrahim

New Post: Editing a PostScript File

$
0
0
I need to be able to edit a PostScript file, in order to change the output printer tray manually. This library looks like it might be able to assist with that. Any chance you could point me in the right direction? Thanks!

New Post: Suppress all dialogs

$
0
0
Hello,

I have been using the library with some success to send to device mswinpr2 but have not determined how to successfully suppress all the dialog boxes that appear? I have tried to use -dNODISPLAY which works but then the document does not print to the printer? There is also a setting in a setup.ps /QueryUser which I have had no success.

Does anyone have any insight on how to do this.
Thanks

Created Unassigned: out of memory issue [2247]

$
0
0
out of memory issue in getimages() while reading pdf of 800 pages.

Commented Unassigned: out of memory issue [2247]

$
0
0
out of memory issue in getimages() while reading pdf of 800 pages.
Comments: ** Comment from web user: reenumoses **

got error while converting large pdf to series of images using ghostscript

New Post: Parameter is not valid.

$
0
0
I am currently using Ghostscript.net to process pdf's into images. For multipage document the first page processes then the next throws the error: "Parameter is not valid." Here is the stack trace:

at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData)
at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
at Ghostscript.NET.Viewer.GhostscriptViewerImage.Lock()
at Ghostscript.NET.Viewer.GhostscriptViewerDisplayHandler.Page(IntPtr handle, IntPtr device, Int32 copies, Int32 flush)
at Ghostscript.NET.GhostscriptDisplayDeviceHandler.display_page(IntPtr handle, IntPtr device, Int32 copies, Int32 flush)

And here is the code:
Dim TestGWScriptRast As New Ghostscript.NET.Rasterizer.GhostscriptRasterizer
Dim GSLatestVer As Ghostscript.NET.GhostscriptVersionInfo =   Ghostscript.NET.GhostscriptVersionInfo.GetLastInstalledVersion()
        Try
            Dim OutPutDir As String = My.Computer.FileSystem.SpecialDirectories.Temp
            TestGWScriptRast.Open(PDFPath, GSLatestVer, True)
            For PageToProc As Integer = 1 To TestGWScriptRast.PageCount
                If TestGWScriptRast Is Nothing Then
                    TestGWScriptRast = New Ghostscript.NET.Rasterizer.GhostscriptRasterizer
                End If

                Dim TempPngImagePath As String = OutPutDir & "\temppng" & Identifier & PageToProc & ".png"
                Dim PDFImage As Image = TestGWScriptRast.GetPage(96, 96, PageToProc)
                Dim PDFImageClone As New Bitmap(PDFImage.Width, PDFImage.Height)
                Dim PDFGraphics As Graphics = Graphics.FromImage(PDFImageClone)

                PDFGraphics.DrawImage(PDFImage, 0, 0)
                PDFImage.Dispose()

                PDFImageClone.Save(TempPngImagePath, Imaging.ImageFormat.Png)
                PDFImageClone.Dispose()
                GC.Collect()

            Next
Is there a workaround or another possible solution to this issue? Any help is greatly appreciated.

New Post: Editing a PostScript File

$
0
0
Hi,

Maby i can give you a direction. I have done this in the past for some automatic printing, by modifying the source PostScript file. Condition is that the printer must support postscript language. And for any printer this could be different, i don't know exactly.

With .NET i modify the source Postscript file and add this line to send the postscript to a specific tray:
(printerinfo trayselect 5 = lade 3)=string FieryXJdict /ExtCmdGetExec get exec {pop} if

or:
%%BeginFeature:
%%+ *InputSlot Drawer1
<</InputAttributes <</Priority [1]>> >> setpagedevice
%%EndFeature

This is an example for an Canon printer.

This is working for an plain HP laserprinter:
tray 1:
%%BeginFeature: *InputSlot ManualFeedTray/ Tray
<</ManualFeed false /MediaPosition 3>> setpagedevice
%%EndFeature

tray 2:
%%BeginFeature: *InputSlot Tray2
<</ManualFeed false /MediaPosition 0>> setpagedevice
%%EndFeature

tray 3:
%%BeginFeature: *InputSlot Tray3_500
<</ManualFeed false /MediaPosition 1>> setpagedevice
%%EndFeature

tray 4:
%%BeginFeature: *InputSlot Tray4_500
<</ManualFeed false /MediaPosition 4>> setpagedevice
%%EndFeature

try to put this right behind this line: %!PS-Adobe-3.0

regards,
Sil

New Post: use local ghostscript dll (instead of installed version)

$
0
0
Hi,

I am in a situation that needs a small distribution. The software i made uses Ghostscript.NET and i do not want any need for installation. So i made a check for gsdll32.dll or gsdll64.dll and so i skip GhostscriptVersionInfo.GetLastInstalledVersion()

Maby a suggestion for a next release would be to skip or modify GetInstalledVersion if gsdll32.dll or gsdll64.dll is in the same directory as Ghostscript.NET.dll

regards,
Sil

New Post: Editing a PostScript File

$
0
0

Awesome! Thanks!

Joseph Reynolds

Senior Software Developer and Software Architect

Microsoft C# MVP

Notice: This e-mail message is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. If you are the intended recipient but do not wish to receive communications through this medium, please so advise the sender immediately.

New Post: how to convert pcl into pdf using ghostscript in C#.Net

$
0
0
hi,

i'm implementing the one program for converting pcl files into pdf readable format files using ghostscript open source dll in C#.Net.


could you please tell me the solution for converting pcl into pdf, if anyone knows?

thank you,
sai k

New Post: convert prn into pdf

$
0
0
An error occured when call to 'gsapi_init_with_args' is made: -100

New Post: GhostscriptProcessor with pdfwrite fails to write pdf

$
0
0
Hi

Im trying to use the GS.Net library to reduce a load of PDF files programmatically. It finds the PDF (it has the correct number of pages but no new pdf is written to the dir). What am i dooing wrong? I get no exceptions.

Code:
    internal class Program
    {
        private static void Main(string[] args)
        {
            const string InputFile = @"E:\OPD\038612_2_org.pdf";
            const string OutputFIle = @"E:\OPD\038612_2_org_ebook-code_1.pdf";

            var gsVersionInfo = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL);
            using (var gsProcessor = new GhostscriptProcessor(gsVersionInfo, true))
            {
                gsProcessor.Processing += ProcessorProcessing;
                var switches = GetGsSwitches(InputFile, OutputFIle);
                gsProcessor.StartProcessing(switches.ToArray(), null);
            }
        }

        private static List<string> GetGsSwitches(string inputFile, string outputFile)
        {
            var switches = new List<string>
                               {
                                   "-sDEVICE=pdfwrite",
                                   "-dCompatibilityLevel=1.4",
                                   "-dPDFSETTINGS=/ebook",
                                   "-dNOPAUSE",
                                   //"-dQUIET",
                                   "-dBATCH",
                                   @"-sOutputFile=" + outputFile,
                                   inputFile
                               };

            return switches;
        }

        static void ProcessorProcessing(object sender, GhostscriptProcessorProcessingEventArgs e)
        {
            Console.WriteLine(e.CurrentPage + " / " + e.CurrentPage);
        }
    }
GS console line used, which reduces the original PDF and saves the new PDF to disk:
"C:\Program Files (x86)\gs\gs9.14\bin\gswin32c" -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sOutputFile=E:\OPD\038612_2_org_ebook_code_2.pdf E:\OPD\038612_2_org.pdf

Anyone got a tip?

BR
/Per

New Post: convert prn into pdf

$
0
0
I think this means that it cant find the file. At least thats the exception i just got when I tried to change to filename to provoke an exception.

BR

New Post: GhostscriptProcessor with pdfwrite fails to write pdf

$
0
0
Great, i found the solution myself. The first switch is ignored, probably used for the gs call, so the pdfwrite was actually never invoked.

So I added a "-empty" switch to the list as first item, and it works.

BR
/Per

New Post: A generic error occurred in GDI+

$
0
0
Hi,

We attempted to use the GhostscriptRasterizer class code from the Documentation section. At the last line of code in method Start() img.Save(pageFilePath,ImageFormat.Png); we received an error "A generic error occurred in GDI+". We tried with a simple pdf that consists of only one page.

We are using 64-bit machine and 64-bit ghostscript is installed in machine. We have referenced the dll GhostScript.Net in VS 2012.

If somebody can help, it would be great.

Thanks.

New Post: save pdf as image tiff ccitg4

$
0
0
Is it possible to convert the loaded PDF file to Tiff format using CCITG4 compression? Or any alternative to run the following gswin32c command:
gs9.14\\bin\\gswin32c -Igs9.14\\lib;fonts -dSAFER -dNumRenderingThreads=2 -dBATCH -dUseCropBox -dNOPAUSE -sPDFPassword=\"\" -sDEVICE=tiffg4  -r300 -sOutputFile=\"output\" 
Viewing all 393 articles
Browse latest View live


Latest Images