dampee / imageprocessor.plugins.pdf Goto Github PK
View Code? Open in Web Editor NEWA PDF fileformat for ImageProcessor
License: MIT License
A PDF fileformat for ImageProcessor
License: MIT License
great plugin , just what i needed .
my only suggestion is to add a dpi parameter to the query string .
in my case the render of the pdf doesn't come out that well on low dpi
I kept getting messages stating that Ghostscript couldn't find the installed version, so googled around a bit, and found a workaround, for when you don't have GS installed (http://ghostscriptnet.codeplex.com/discussions/465418).
I then implemented it in PdfRasterizer like this, and now it works like a charm. Not sure if this is a good way to go though.
public PdfRasterizer(int xDpi = 96, int yDpi = 96)
{
_desiredXDpi = xDpi;
_desiredYDpi = yDpi;
_lastInstalledVersion = new GhostscriptVersionInfo(new System.Version(0, 0, 0), HttpContext.Current.Server.MapPath("~/bin/gsdll32.dll"), string.Empty, GhostscriptLicense.GPL);
_rasterizer = new GhostscriptRasterizer();
}
see question is this possible?
Hello,
First, thank you for your work, so usefull!
And sorry for my english :)
We encounter a problem with a pdf containing layers. The resulted image contains only the above layer and fill the page with black. I can send it if it helps.
Thank you for your help.
Currently, the check whether we run 32/64 bit is kind of wrong.
You could have a 64 bit machine, while IIS (or IIS Express) can be running in 32-bit. Which will cause an invalid result because we check on the machine: Environment.Is64BitProcess
I would be better if we checked on the current process whether it is 32 or 64 bit?
Looking for a solution, I came across this : https://stackoverflow.com/a/397695/97615
if (IntPtr.Size == 8)
{
// 64 bit machine
}
else if (IntPtr.Size == 4)
{
// 32 bit machine
}
See title.
Just ran into your blogpost and awesome solution. Installed the plugin using NuGet, pulled the latest Ghostscript 9.50 (gsdll64.dll) assembly into the bin folder and used the following Razor to generate the image url: @Url.GetCropUrl(item, furtherOptions: "&format=jpg&width=500")
So far, so good but when viewing the image url, the following (not so good) exception is shown:
[GhostscriptException: Page number is not in pages number range!] Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.InitPage(Int32 pageNumber) +206 Ghostscript.NET.Viewer.GhostscriptViewer.ShowPage(Int32 pageNumber, Boolean refresh) +160 Ghostscript.NET.Rasterizer.GhostscriptRasterizer.GetPage(Int32 xDpi, Int32 yDpi, Int32 pageNumber) +39 ImageProcessor.Plugins.Pdf.PdfRasterizer.Rasterize(Stream pdfStream, Int32 pageNumber) +54 ImageProcessor.ImageFactory.Load(Stream stream) +129 ImageProcessor.Web.HttpModules.<ProcessImageAsync>d__31.MoveNext() +4497 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60 System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar) +64 System.Web.AsyncEventExecutionStep.InvokeEndHandler(IAsyncResult ar) +209 System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +156
I don't have a clue as to what to do with the page number. Have I missed something?
When a generated PNG preview is generated it's content-type header is application/pdf
where it should be image/png
.
As a result of CORB, the importance of providing the correct content type has increased as images with an incorrect content type cannot be embedded into pages on external domains (i.e. if using a CDN).
I would like to render another pages, please tell me how to do that.
Thanks.
@dampee, any chance you can update the NuGet release. The "Use in memory version (#7)" commit is essential for this plugin and that's not in the current (1.2.0) NuGet package.
It's not hard to compile the source myself but it would be nice to be able to just include the NuGet package.
Otherwise, great work and thank you.
Geoff
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.