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

Created Release: Ghostscript.NET v.1.1.4. (Feb 14, 2014)

$
0
0
v.1.1.4.
  • fixed problem with applying GraphicsAlphaBits and TextAlphaBits which improved antialiasing in GhostscriptViewer and GhostscriptRasterizer.
  • fixed problem with output through main stderr callback handler.
  • added support for MemoryStream in the GhostscriptPdfInfo.GetInkCoverage method.
  • added GraphicsAlphaBits and TextAlphaBits properties in GhostscriptViewer and GhostscriptRasterizer so antialiasing can now be changed from the outside...

v.1.1.3.
  • added GhostscriptPdfInfo.GetInkCoverage function which has ability to return ink coverage for the CMYK inks, separately for each single page (for RGB colors, it does a silent conversion to CMYK color space internally). This function can be used to check if the pdf is grayscale or color.
  • fixed problem with opening MemoryStream EPS files which contains "EPS Preview Header" (reported by "Chanan Eli")
  • fixed problem with empty %%BoundingBox value when handling PostScript files (thanks to by "Shane_S")
  • fixed problem with rasterizing EPS files created with Adobe Illustrator (reported by "Chanan Eli")
  • fixed problem with retrieving exported function handle in DynamicNativeLibrary noticed on the Server 2012 R2 with large amount of memory (thanks to "antonyoni")
  • assembly is now signed with a strong name key (requested by "netmajor")

v.1.1.2.
  • fixed GhostscriptPipedOutput.Data property get accesor in order to prevent a race condition. (thanks to "Marc Klenotic").
  • added GhostscriptPipedOutput class as part of the Ghostscript.NET library.
  • fixed GhostscriptException error code text message resolving.
  • implemented better methods parameters checking and exception handling.
  • changed ImageMemoryHelper class from public to internal.
  • implemented opening files represented as MemoryStream from GhostscriptRasterizer and GhostscriptViewer. (that was some users request although there is no point of passing PDF as MemoryStream (or byte array) as it will anyway end up on the disk before it will be interpreted as PDF language, unlike the PostScript language, inherently requires random access to the file).

v.1.1.1.
  • fixed problem in GhostscriptRasterizer and GhostscriptViewer when MediaBox contains negative llx or lly values. (problem reported by "Prasenjit Das").
  • added GhostscriptPngDevice, a friendly output device class with all png devices related switches. (GhostscriptPngDevice supports: png16m, pngalpha, pnggray, png256, png16, pngmono, pngmonod).
  • added GhostscriptJpegDevice, a friendly output device class with all jpeg devices related switches. (GhostscriptJpegDevice supports: jpeg, jpeggray).
  • extended GhostscriptProcessor.StartProcessing method to support GhostscriptDevice base class as StartProcessing parameter.
  • for each constructor / method that requires GhostscriptVersionInfo parameter, now there is one more constructor / method available with a same functionality but without a need to pass GhostscriptVersionInfo parameter. This new constructors and methods automatically retrieves and use last installed Ghostscript version.
  • added new samples to the Ghostscript.NET.Samples project (AddWatermarkSample, ProcessorSample, DeviceUsageSample).

v.1.1.0.
  • added GhostscriptViewer state handling (SaveState, RestoreState)
  • GhostscriptRasterizer constructor is extended in order to support usage of the existing GhostscriptViewer instance.
  • fixed problem while using a 32-bit assembly with 32-bit version of Ghostscript on 64-bit Windows: It couldn't find a registry key of installed Ghostscript. Reported and fixed by "r0land".

v.1.0.9.
  • implemented EPS (Encapsulated PostScript) support for the GhostscriptViewer.
  • added GhostscriptRasterizer class which provides ability to easily export PDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the memory. For each page different x and y dpi settings can be set.
  • fixed gsapi_stdin callback and it's value passing to the ghostscript library.
  • added ProgressiveUpdate property to the GhostscriptViewer class so progressive update can be controlled outside the library.

v.1.0.8.
  • implemented StopProcessing method in the GhostscriptProcessor class which allows us to terminate gsapiinitwith_args call in the multithread environment.
  • fixed GhostscriptViewer ZoomIn and ZoomOut problem on the systems where windows region and language settings has number decimal symbol set to comma.
  • added page navigation and zoom checker properties to the GhostscriptViewer class.
  • fixed problem in GhostscriptViewer class when trying to view PostScript files without DSC header.
  • GhostscriptProcessor.Process method name changed to StartProcessing.
Also check out Ghostscript Studio (http://ghostscriptstudio.codeplex.com/)

v.1.0.7.
  • implemented multi-page PostScript support for the GhostscriptViewer
  • included Microsoft.WinAny.Helper code files in order to have a single dll for the deployment
  • added Processing event to the GhostscriptProcessor class (with CurrentPage and TotalPages info)
  • added zoom-in and zoom-out functionality
  • fixed ImageMemoryHelper.Set24bppRgbImageColor function when stride size is not multiple of 3 bytes
  • fixed displayed page size
v.1.0.6.
  • implemented progressive display update while ghostscript is drawing / rasterizing, now a custom update interval can be set in GhostscriptViewer class.
  • fixed problem when using 64-bit ghostscript library where raster (stride) line size is not equal to 32-bit ghostscript library raster line size.
  • changed GhostscriptViewer class event logic.
  • changed Ghostscript.NET.Viewer application in order to show progressive update.
  • modified Ghostscript.NET.DisplayTest, now it uses GhostscriptViewer class with ability to interpret postscript and display standard input output messages.

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

Created Unassigned: SystemFormatException if PDF Filename contains diacritics [2129]

$
0
0
If the PDF file name contains diacritics e.g."Verträge.pdf" a format exception "Input string was not in a correct format." is thrown:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.StdOutput(String message)
at Ghostscript.NET.Viewer.GhostscriptViewerStdIOHandler.StdOut(String output)
at Ghostscript.NET.GhostscriptStdIO.gs_std_out(IntPtr handle, IntPtr pointer, Int32 count)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter.Run(String str)
at Ghostscript.NET.Viewer.GhostscriptViewerFormatHandler.Execute(String str)
at Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.Open(String filePath)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open()
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

I checked various diacritics like ćšäö and the exception is always thrown.
As a workaround the Open(MemoryStream stream, GhostscriptVersionInfo versionInfo, bool dllFromMemory) overload works like a charm

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

$
0
0
I had the same issue in a winform app.
The cause was I was reusing a single GhostscriptViewer instance to open multiple documents. Even creating a new instance for each pdf was throwing the exception when the garbage collector didn't had enough time to dispose the unmanaged resources. I ended up by creating a private member variable to hold the GhostscriptViewer and before opening a new pdf I disposed the viewer if it was not null:
private GhostscriptViewer gsViewer;
// ...

 if(this.gsViewer != null)
    this.gsViewer.Dispose();
this.gsViewer = new GhostscriptViewer();
poz

Commented Unassigned: SystemFormatException if PDF Filename contains diacritics [2129]

$
0
0
If the PDF file name contains diacritics e.g."Verträge.pdf" a format exception "Input string was not in a correct format." is thrown:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.StdOutput(String message)
at Ghostscript.NET.Viewer.GhostscriptViewerStdIOHandler.StdOut(String output)
at Ghostscript.NET.GhostscriptStdIO.gs_std_out(IntPtr handle, IntPtr pointer, Int32 count)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter.Run(String str)
at Ghostscript.NET.Viewer.GhostscriptViewerFormatHandler.Execute(String str)
at Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.Open(String filePath)
at Ghostscript.NET.Viewer.GhostscriptViewer.Open()
at Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path, GhostscriptVersionInfo versionInfo, Boolean dllFromMemory)

I checked various diacritics like ćšäö and the exception is always thrown.
As a workaround the Open(MemoryStream stream, GhostscriptVersionInfo versionInfo, bool dllFromMemory) overload works like a charm
Comments: ** Comment from web user: josip **

Quick workaround is to encode your path as UTF8:

string filePath = @"e:\äbc.pdf";

filePath = System.Text.Encoding.Default.GetString(System.Text.Encoding.UTF8.GetBytes(filePath));

Can you please try this and let me know if this works?

Cheers,
Josip

Created Unassigned: EPSCrop [2130]

$
0
0
I'm not able to activate -dEPSCrop with the rasterizer.
It works with a custom switch in GhostscriptPngDevice but temporary saving to a file is a little bit slow.
Any idea?
Cropping to the BoundingBox is the normal case if you are using .eps files.

New Post: Stream instead of MemoryStream

$
0
0
I had to replace Open(MemoryStream) with the more general Stream type.

There was only one additional change needed in WriteToTemporaryFile()

Old:
        File.WriteAllBytes(path, stream.ToArray());
New:
        byte[] buffer = new byte[stream.Length];
        stream.Read(buffer, 0, (int)stream.Length);
        File.WriteAllBytes(path, buffer);

New Post: .NET 3.5

$
0
0
I had to change the code to work in .NET 3.5. Not a lot of work luckily.
Any special reason why a higher version is requested?

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

Donations

Donations are greatly appreciated. If you find Ghostscript.NET useful, or are otherwise just of the generous nature, and would like to make a donation to this project, the donation's are accepted via PayPal :)

 

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

Donations

Donations are greatly appreciated. If you find Ghostscript.NET useful, or are otherwise just of the generous nature, and would like to make a donation to this project, the donation's are accepted via PayPal :)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="_xclick"><input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="habjan@gmail.com" /> <input name="item_name" type="hidden" value="Donation" /> <input name="currency_code" type="hidden" value="USD" /> <input name="amount" type="hidden" value="" /> <input alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" type="image" /></form>

 

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

Donations

Donations are greatly appreciated. If you find Ghostscript.NET useful, or are otherwise just of the generous nature, and would like to make a donation to this project, the donation's are accepted via PayPal :)

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="_xclick"><input name="cmd" type="hidden" value="_xclick" /> <input name="business" type="hidden" value="habjan@gmail.com" /> <input name="item_name" type="hidden" value="Donation" /> <input name="currency_code" type="hidden" value="USD" /> <input name="amount" type="hidden" value="" /> <input alt="Make payments with PayPal - it's fast, free and secure!" name="submit" src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" type="image" /></form>

 

 

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

Donations

Donations are greatly appreciated. If you find Ghostscript.NET useful, or are otherwise just of the generous nature, and would like to make a donation to this project, the donation's are accepted via PayPal :)

 

 

 

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

Updated Wiki: Home

$
0
0

Ghostscript.NET (written in C#) is the most completedmanaged wrapper library around the Ghostscript library (32-bit & 64-bit), an interpreter for the PostScript language, PDF, related software and documentation.

All other .NET Ghostscript wrappers that you can find on the internet this days does not allow you to render PDF page directly to the screen without exporting the pages to the disk first. This wrapper does not require exporting to the disk, it can render PDF pages to the screen directly from the Ghostscript interpreter.

NuGet: PM> Install-Package Ghostscript.NET

Used in Ghostscript Studio (Ghostscript IDE)

                                                       

 

Features of the Ghostscript.NET are:

  • It contains GhostscriptViewer class which allows you to easily render and navigate through PDF or PostScript files on the screen via code.  It can handle multi-page PostScript files.
  • GhostscriptViewer class contains progressive display update implementation. While Ghostscript is drawing / rasterizing you can see tiles drawing on the screen. Custom update interval can be set.
  • GhostscriptViewer class has Zoom-in and Zoom-out functionality.
  • It contains GhostscriptRasterizer class which provides ability to easily exportPDF pages, PostScript pages and EPS files to the System.Drawing.Image object in the  memory.
  • It allows you to run multiple instances of the Ghostscript library (dll) simultaneously within a single process (Ghostscript API does not support this out-of-the-box). This is achieved by using Microsoft.WinAny.Helper library and it's DynamicNativeLibrary class which allows you to load a native library from the memory instead from a disk. By doing this (loading from the memory), all Ghostscript instances are running in their own context.
  • It contains GhostscriptProcessor class which allows you to call Ghostscript library (dll) with a custom specified arguments / switches.
  • All Ghostscript functions which provides ability to rasterize / render postscript or pdf directly to the screen without a need to save it to the disk first are implemented.
  • It's completely compatible and tested with 32-bit and 64-bit Ghostscript library.

Plans:

  • Extending this library to be more "developer" friendly.

Sample applications screenshots below (built on the top of the Ghostscript.NET library):

Ghostscript.NET.Viewer: (supports viewing of PDF and multi-page PS files)

  Ghostscript.NET.Viewer 

Example of direct postscript rasterizing via Ghostscript.NET.

Cheers,
Josip Habjan
http://habjan.blogspot.com

 

Website counter

New Post: Stream instead of MemoryStream

$
0
0
Hi,

Thanks, I will implement this for the v.1.1.5 release.

Cheers,
Josip

Commented Unassigned: EPSCrop [2130]

$
0
0
I'm not able to activate -dEPSCrop with the rasterizer.
It works with a custom switch in GhostscriptPngDevice but temporary saving to a file is a little bit slow.
Any idea?
Cropping to the BoundingBox is the normal case if you are using .eps files.
Comments: ** Comment from web user: josip **

The fix for this will be included in Ghostscript v.1.1.5 release which will be published in couple of day.


New Post: Invert Image colors

$
0
0
Hi,

I want to implement a function to can invert colors for readability on a small screen. I came across some code that works for me, but i don't know where to implement this the right way, so i can stil use page/zoom etc.

public Bitmap Transform(Bitmap source)
{
//create a blank bitmap the same size as original
Bitmap newBitmap = new Bitmap(source.Width, source.Height);

//get a graphics object from the new image
Graphics g = Graphics.FromImage(newBitmap);

// create the negative color matrix
ColorMatrix colorMatrix = new ColorMatrix(new float[][]
{
    new float[] {-1, 0, 0, 0, 0},
    new float[] {0, -1, 0, 0, 0},
    new float[] {0, 0, -1, 0, 0},
    new float[] {0, 0, 0, 1, 0},
    new float[] {1, 1, 1, 0, 1}
}); 

// create some image attributes
ImageAttributes attributes = new ImageAttributes();

attributes.SetColorMatrix(colorMatrix);

g.DrawImage(source, new Rectangle(0, 0, source.Width, source.Height),
            0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);

//dispose the Graphics object
g.Dispose();

return newBitmap;
}

New Post: Invert Image colors

$
0
0
Hi,

I would implement this in the 'DisplayPage' event handler.

So, the complete source would look like this:
namespace Ghostscript.NET.Viewer
{
    public partial class FMain : Form
    {
        private GhostscriptViewer _viewer;
        private GhostscriptVersionInfo _gsVersion = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL);

        public FMain()
        {
            InitializeComponent();

            this.Text = Program.NAME;

            pbPage.Width = 100;
            pbPage.Height = 100;

            _viewer = new GhostscriptViewer();

            _viewer.DisplaySize += new GhostscriptViewerViewEventHandler(_viewer_DisplaySize);
            _viewer.DisplayPage += new GhostscriptViewerViewEventHandler(_viewer_DisplayPage);
        }

        void _viewer_DisplaySize(object sender, GhostscriptViewerViewEventArgs e)
        {
            pbPage.Image = e.Image;
        }

        void _viewer_DisplayPage(object sender, GhostscriptViewerViewEventArgs e)
        {
            pbPage.Image = this.Transform(pbPage.Image as Bitmap);

            tbPageNumber.Text = _viewer.CurrentPageNumber.ToString();
            tbTotalPages.Text = " / " + _viewer.LastPageNumber.ToString();
        }

        private void FMain_Load(object sender, EventArgs e)
        {
            lblSystemInformation.Text = "Operating system: " + (Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit") + "   " +
                "Process: " + (Environment.Is64BitProcess ? "64-bit" : "32-bit");

            lblGsVersion.Text = "Rasterizer: " + _gsVersion.LicenseType.ToString() + " Ghostscript " + 
                _gsVersion.Version.ToString() + " (" + Path.GetFileName(_gsVersion.DllPath) + ")";
        }

        private void mnuFileOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Open PDF file";
            ofd.Filter = "PDF, PS, EPS files|*.pdf;*.ps;*.eps";

            if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                mnuFileClose_Click(this, null);

                _viewer.Open(ofd.FileName, _gsVersion, true);
                this.Text = System.IO.Path.GetFileName(ofd.FileName) + " - " + Program.NAME;
            }
        }

        private void mnuFileClose_Click(object sender, EventArgs e)
        {
            _viewer.Close();
            pbPage.Image = null;
            this.Text = Program.NAME;
            tbPageNumber.Text = string.Empty;
            tbTotalPages.Text = string.Empty;
        }

        private void mnuFileExit_Click(object sender, EventArgs e)
        {
            this.Close();
            Application.Exit();
        }

        private void tbPageFirst_Click(object sender, EventArgs e)
        {
            _viewer.ShowFirstPage();
        }

        private void tbPagePrevious_Click(object sender, EventArgs e)
        {
            _viewer.ShowPreviousPage();
        }

        private void tbPageNext_Click(object sender, EventArgs e)
        {
            _viewer.ShowNextPage();
        }

        private void tbPageLast_Click(object sender, EventArgs e)
        {
            _viewer.ShowLastPage();
        }

        private void tbPageNumber_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (tbPageNumber.Text.Length > 0)
                {
                    _viewer.ShowPage(int.Parse(tbPageNumber.Text));
                }
            }
            catch { }
        }

        private void mnuAbout_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this, "Powered by Ghostscript.NET & Josip Habjan (habjan@gmail.com)", "About " + Program.NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void mnuNext_Click(object sender, EventArgs e)
        {
            _viewer.ShowNextPage();
        }

        private void mnuPrev_Click(object sender, EventArgs e)
        {
            _viewer.ShowPreviousPage();
        }

        private void mnuFirst_Click(object sender, EventArgs e)
        {
            _viewer.ShowFirstPage();
        }

        private void mnuLast_Click(object sender, EventArgs e)
        {
            _viewer.ShowLastPage();
        }

        private void tpZoomIn_Click(object sender, EventArgs e)
        {
            _viewer.ZoomIn();
        }

        private void tpZoomOut_Click(object sender, EventArgs e)
        {
            _viewer.ZoomOut();
        }

        public Bitmap Transform(Bitmap source)
        {
            //create a blank bitmap the same size as original
            Bitmap newBitmap = new Bitmap(source.Width, source.Height);

            //get a graphics object from the new image
            Graphics g = Graphics.FromImage(newBitmap);

            // create the negative color matrix
            ColorMatrix colorMatrix = new ColorMatrix(new float[][]
            {
                new float[] {-1, 0, 0, 0, 0},
                new float[] {0, -1, 0, 0, 0},
                new float[] {0, 0, -1, 0, 0},
                new float[] {0, 0, 0, 1, 0},
                new float[] {1, 1, 1, 0, 1}
            });

            // create some image attributes
            ImageAttributes attributes = new ImageAttributes();

            attributes.SetColorMatrix(colorMatrix);

            g.DrawImage(source, new Rectangle(0, 0, source.Width, source.Height),
                        0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);

            //dispose the Graphics object
            g.Dispose();

            return newBitmap;
        }
    }
}
Cheers,
Josip

New Post: Invert Image colors

$
0
0
Hi Josip,

Thanks for helping me out. I was a little confused, but its working now. I noticed the DisplaySize event is called twice when loading a document, and DisplayUpdate can be called more than once, and in the source code you call pbPage.Invalidate(); and pbPage.Update() in both DisplayUpdate and DisplayPage handler. I only call pbPage.Invalidate(); in DisplayUpdate. (less flashing now)

I changed this:
pbPage.Image = this.Transform(pbPage.Image as Bitmap);
to this
pbPage.Image = this.Transform(e.Image as Bitmap);
because the image was converted back to original when going to the next page, and the page was not going to the next one.

and i keep track if image is converted or not.
this the result:
    void _viewer_DisplaySize(object sender, GhostscriptViewerViewEventArgs e)
    {
        pbPage.Image = e.Image;
        System.Diagnostics.Debug.Write("displaySize...." + "\n");
    }

    void _viewer_DisplayUpdate(object sender, GhostscriptViewerViewEventArgs e)
    {
        pbPage.Invalidate();
        System.Diagnostics.Debug.Write("displayUpdate...." + "\n");
    }

    void _viewer_DisplayPage(object sender, GhostscriptViewerViewEventArgs e)
    {
        if (_isInverted == true)
        {
            pbPage.Image = this.InvertBitmap(e.Image);
        }

        System.Diagnostics.Debug.Write("displayPage...." + "\n");
        tbPageNumber.Text = _viewer.CurrentPageNumber.ToString();
        tbTotalPages.Text = " / " + _viewer.LastPageNumber.ToString();
    }

    public Bitmap InvertBitmap(Image img)
    {
        Bitmap bm = new Bitmap(img.Width, img.Height);
        Graphics g = Graphics.FromImage(bm);
        ColorMatrix cm = new ColorMatrix(new float[][]
        {
            new float[] {-1, 0, 0, 0, 0},
            new float[] {0, -1, 0, 0, 0},
            new float[] {0, 0, -1, 0, 0},
            new float[] {0, 0, 0, 1, 0},
            new float[] {1, 1, 1, 0, 1}
        });
        ImageAttributes ia = new ImageAttributes();
        ia.SetColorMatrix(cm);
        g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia);
        g.Dispose();

        return bm;
    }
Thanks again,
regards, Sil

New Post: Error when trying to run a processor

$
0
0
My intention is to convert a PDF to PNG, GhostscriptReasterizer first tried using the class and it worked correctly, but I can not set the output parameters all I wanted.

Then I took on the example of GhostscriptProcessor, but when I run it shows me an error "An error occured When call to 'gsapi_init_with_args' is made​​: -100".

This is the code:
        GhostscriptVersionInfo version = null;
        version = GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL, GhostscriptLicense.GPL);

        GhostscriptProcessor processor = new GhostscriptProcessor(version, false);

        processor.Processing += ShowStatus;
        processor.StartProcessing(GetArgs().ToArray(), null);
Arguments are defined in this function:
    IList<string> GetArgs()
    {
        IList<string> args = new List<string>();

        //args.Add("-dDOINTERPOLATE");
        //args.Add("-dGraphicsAlphaBits=4");
        //args.Add("-dDownScaleFactor=3");
        //args.Add("-dSAFER");
        //args.Add("-dBATCH");
        //args.Add("-dNOPAUSE");
        args.Add("-sDEVICE=pnggray");
        //args.Add("-r600");
        args.Add(string.Format("-otest.png");
        //args.Add("-q");
        args.Add("-f");
        args.Add(string.Format("test.pdf");
        return args;
    }
I tried different combinations, and I tried with Ghostscript command line app, with the same parameters:

gswin64c -sDEVICE=pnggray -otest.png -f test.pdf

And work fine.

Best Regards
Alejandro

New Post: Error when trying to run a processor

$
0
0
Hi Alejandro,

Try with this:
        private List<string> GetArgs()
        {
            List<string> args = new List<string>();
            args.Add("-empty"); // this one will not be used but it must be here
            args.Add("-sDEVICE=pnggray");
            args.Add(@"-oE:\gss_test\test.png");
            args.Add("-f");
            args.Add(@"E:\gss_test\test.pdf");
            return args;
        }
Make sure the full path is specified for both input and output file and the first switch is a dummy switch.

Cheers,
Josip
Viewing all 393 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>