Cheers,
Josip
rasterizer.Open(ms, GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL | GhostscriptLicense.AFPL,GhostscriptLicense.GPL), true);
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
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
got error while converting large pdf to series of images using ghostscript
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.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.
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:gs9.14\\bin\\gswin32c -Igs9.14\\lib;fonts -dSAFER -dNumRenderingThreads=2 -dBATCH -dUseCropBox -dNOPAUSE -sPDFPassword=\"\" -sDEVICE=tiffg4 -r300 -sOutputFile=\"output\"