mephraim / ghostscriptsharp Goto Github PK
View Code? Open in Web Editor NEWA C# wrapper for the Ghostscript library (1.1)
License: MIT License
A C# wrapper for the Ghostscript library (1.1)
License: MIT License
Looking to sit a web service on top of this library.
Would this work safely in a multithreaded environment?
Hi mephraim,
Firstly want to thank you for the great work you have done in putting this ghostscript c# wrapper together not many of these out there. I have a slight problem with it though which I am not too sure how to go about fixing it. The project reads eps files but for some images they get cropped. I have slightly gotten around this by using the "ledger" page size (landscape). The problem is it adds unnecessary spaces both at the top of images and to the right of the images. How would I go about so that the actual dimensions of an image is obtained and then used in order to create the thumbnail image rather than using the pre-defined page sizes such as "ledger". This is the only issue I see with this, and once sorted this should be perfect. Any suggestion or ideas on how to go about achieving this...
Many Thanks
There are two symptoms of what I believe is the same issue.
I've installed GhostScriptSharp using Nuget and I'm running it locally on a 32-bit machine in the Azure Development Fabric. Everything is working wonderfully.
When I deploy to Azure, which is 64-bit, I'm getting the following error message.
Unable to load DLL 'gsdll32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
There are two issues here as I can tell
I've posted the question to stackoverflow as well.
http://stackoverflow.com/questions/24519908/ghostscriptsharp-on-azure
Thanks in advance for the assistance
I've spent an entire day trying to make this to integrate into my app, I got FileNotFoundException on the gsdll32.dll, and when I copied it to C:\Windows\System32, or put it manually alongside the GhostScriptSharp.dll, it errored out with BadImage exception, then finally I thought of creating a simple console app and try it there, and it worked as both DLLs were under the bin folder alongside each other (surprisingly), but then the performance of this library is horrible!! It's slow and it generates huge files (in MBs vs. few KBs compared to other libs).
So, I don't believe anyone complained about this before so they wouldn't waste their time and try this library like I did, it sure would've helped me if I knew this was its result.
I don't think you can license it under MIT if you're using Ghostscript library.
Is there a possibility to get the total number og pages in the PDF?
Thanks in advance
In dev it works fine, butit fails to create the image when it's live on Azure hosting, no error is thrown.
Edit: No error was thrown because of a async control used. Error output was the same
Unable to load DLL 'gsdll32.dll'
Great tool. Thanks for putting this together. I'm looking for text output of a PDF so I added txtwrite to the list of devices and it now accomplished the task. Thought I'd pass it along in case it was useful to someone else.
Hi, I'm using GhostScriptSharp v1.3.1.4 and I've run into an issue when publishing a ASP.NET project.
The post-build event script only works locally.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "ls '$(SolutionDir)\packages\GhostScriptSharp.*\Tools\gsdll32.dll' | Sort -Descending | Select -First 1 | cp -Destination '$(TargetDir)'; exit 0"
So when the project is published the gsdll32.dll is missing on the server :(
However I found a solution. Inspired from https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-extra-files
You can add the following to the publish profile.
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="..\packages\GhostScriptSharp.*\Tools\gsdll32.dll" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>bin\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
And now the gsdll32.dll file is published along the other files. 🎉
Not sure if this somehow can be improved upon so this manual edit isn't necessary.
Just leaving a note. The dll in the nuget package can be swapped out with the latest version (9.07) I used.
This fixed some crashes.
Hi ,
Could you please let me know how can i dispose the gsdll reference , I am using it in threaded env. so i need to ensure that no thread is using it before to dispose.
Hi,
I downloaded ghostscriptsharp from NuGet and whenever I call: GhostscriptWrapper.GenerateOutput(pdfPath, pagePath, settings);
It gives me a BadImageFormatException "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"
I tried building my project with AnyCPU, 32 and 64 bit architecture but always getting the same exception.
This is not working with .NET Core
Hi, I maintain the nuget package for GhostScriptSharp (by the way let me know if you want to take over that duty), and was asked to update it to version 1.1
Checking out the code...
I was able to only find an sln file in the test project and when I tried to compile I got an error from nunit not being referenced. Can you please include dependencies via nuget and enable auto package restore?
Also, its standard to have an sln at the project root so I would recommend moving it there.
Thanks for the great code!
I am trying to convert a multi page PDF into bunch of PNGs.
The same code works for all PDFs with page count <11 but InitAPI() blows up with error code -100 if page count is 11 or more. I wonder if there should be a different format for generating unique file name that GhostScript takes as part of sOutputFile argument instead of %d.jpg? Or is this related to something else?
Thanks in advance.
Got any work arounds?
This is pretty crucial, so I'll do the fix by myself if you don't have the time.
Sincerely.
Hi
I'm trying to generate the first pdf document to an image. According to the method, I need to specify the with and height, but I don't know that, how should I do?
public static void GeneratePageThumb(string inputPath, string outputPath, int page, int width, int height)
Member of GhostscriptSharp.GhostscriptWrapper
Would it be possible to set dNumRenderingThreads
to Environment.ProcessorCount
instead of hardcoding it to 4
? I guess this could provide enhanced performance, based on this
.
First, good job on this wonderful library. I tried extensively with various pdf's and found out that if i use this settings below (jpg or png) to generate a thumbnail of an ebook (16.6mb), the result is a thumbnail of over 30mb even with a meager 198 * 262 pixel output dimension. Am I doing something wrong because a 72 dpi resolution produces the smallest file size posible with reasonable image quality as a thumbnail for me.
GhostscriptWrapper.GenerateOutput(filepath, fullthumbnailfilepath, New GhostscriptSettings With {
.Device = GhostscriptDevices.pngalpha,
.Page = New GhostscriptPages With {.Start = 1, .End = 1, .AllPages = False},
.Resolution = New Size With {.Height = 72, .Width = 72},
.Size = New GhostscriptPageSize With {.Native = GhostscriptPageSizes.a4}
})
GeneratePageThumbs is throwing error and GeneratePageThumb working fine. When I dig into this GeneratePageThumb is actually calling GeneratePageThumbs internally. So GeneratePageThumbs expect outputPath which is a string and output files can be multiple. GeneratePageThumbs should get outputDirectoryPath instead of outputFilePath and output file name should be handled within the function.
how can i do a callback after GenerateOutput is done processing?
Hello,
i am using this function and Works fine in 32 bits application, but i need to run it on 64 bits.
Exception:
An unhandled exception of type 'System.BadImageFormatException' occurred in GhostscriptSharp.dll
Additional information: Se ha intentado cargar un programa con un formato incorrecto. (Excepción de HRESULT: 0x8007000B)
Could you help me?
Thanks
While converting PDF by using GeneratePageThumb & GeneratePageThumbs I'm getting an exception System.Runtime.InteropServices.ExternalException' occurred in GhostscriptSharp.dll
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.