- Ghostscript Convert Png To Pdf
- Convert Png To Pdf Free
- Ghostscript Convert Png To Pdf Online Free
- Ghostscript Pdf To Image
Active8 years, 7 months ago
Image file formats. Ghostscript supports output to a variety of image file formats and is widely used for rasterizing postscript and pdf files. A collection of such formats ('output devices' in Ghostscript terminology) are described in this section. PNG to PDF - Convert file now View other image file formats Technical Details PNG images are in many ways better than.GIF as they also include an 8-bit transparency channel, which allows the colors in the image to fade from opaque to transparent; GIF images only. I am attempting, unsuccessfully, to use Ghostscript to rasterize PDF files with a transparent background to PNG files with a transparent background. I've searched high and low for questions from ot. Nov 13, 2017 Ghostscript can output multiple formats (png included) but I don't believe it is able to take png as an input. You may be able to accomplish your goal using something like imagemagick's convert utility, though: convert test.png test.pdf.
I am attempting, unsuccessfully, to use Ghostscript to rasterize PDF files with atransparent background to PNG files with a transparent background. I'vesearched high and low for questions from others attempting the same thingand none of the posted solutions, which as far as I can tell come down tospecifying -sDEVICE=pngalpha, have worked with my test files. At this pointI would really appreciate any advice or tips a more experienced hand couldprovide.
My test PDF is located here: http://www.kolossus.com/files/test.pdf
It could be that the issue is with this file, but I doubt it. As far as Ican tell, it has no specified background, and when I open the file with atransparency-aware app like Photoshop or Illustrator, sure enough itdisplays with a transparent background. However, when opened with anapplication like Adobe Reader the file is rendered with a white background.I believe that this has more to do with the application rendering the PDFthan with the PDF itself -- apps like Adobe Reader assume you want to seewhat a printed document will look like and therefore always show a whitecanvas behind the artwork -- but I can't be sure.
The gs command I'm using is:
This produces a PNG that has transparent pixels outside of the bounding boxof the artwork in the file, but all pixels that are inside the artwork'sbounding box are rasterized against a white background. This is a problemfor me, as my artwork has drop shadows and antialiased edges that need to bepreserved in the final output, and can't just be postprocessed out withImageMagick. A sample of my PNG output is at the same location as the pdf above, with .png at the end (stackoverflow won't let me include more than one url in my post).
Interestingly, I see no effects from using the -dBackgroundColor flag, evenif I set it to something non-white like -dBackgroundColor=16#ff0000. Perhapsmy understanding of the syntax of this flag is wrong.
Also interestingly, I see no effects from using the -dTextAlphaBits=4-dGraphicsAlphaBits=4 flags to try to enable subpixel antialiasing. I wouldalso appreciate any advice on how to enable subpixel antialiasing,especially on text.
Finally, I'm using GPL Ghostscript 8.64 on Mac OS 10.5.7, and the renderingworkflow I'm trying to get set up is to generate transparent PNG images fromPDFs output by PrinceXML. Silead kmdf hid minidriver windows 10 fix mbr. I'm calling Ghostscript directly for the rasterization instead of using ImageMagick because ImageMagick delegates to Ghostscript for PDF rasterization and I should be able to control the rasterization better by calling GS directly.
Thanks for your help.
-Jon Wolfe
Jonathon Wolfe
3 Answers
I share your experience with the
-dTextAlphaBits=4
and -dGraphicsAlphaBits=4
flags. They appear not to work on all texts. The 'fix' I came up with was to just render the image at 4 times the desired size, and then scale the image down. Luckily ghostscript has no problems rendering gigapixel PNG files.update
Ghostscript (up to version 9) also seems to enjoy major problems when rendering transparent PNG's with a pixel count above 2.500.000 (i.e. 10 mb of pixel buffer). The transparent background suddenly turns white.
Drilling down the source of ghostscript, I found that when the pixel buffer size exceeds 10 mb, it switches to a different memory allocation scheme. More specifically, the image is rendered using device
image32
instead of pngalpha
. Given the way the pngalpha
driver is implemented, it's whole purpose vanishes when gs decides not to use its pngalpha_fill_rectangle()
.Luckily, there is a switch called
-dMaxBitmap=N
to configure this parameter at runtime. This is mentioned in a workaround for a totally different bug dating back to 1999-01-15, see http://pages.cs.wisc.edu/~ghost/doc/AFPL/5.50/relnotes/index.htm.Adding
-dMaxBitmap=2147483647
solved a lot of problems for me. On 64 bit systems, this number can be higher.A true fix would of course be to rework the
mvdsmvdspngalpha
driver so that it sets the background color to 0x7f000000
no matter the actual code path, but most systems have enough ram on board for the above trick to work.40.1k66 gold badges8787 silver badges106106 bronze badges
Afraid I can't tell you what ghostscript can do but I do have a suggestion. Try rendering your PDF with both a black and a white background. Any pixel that comes out the same in the two images was clearly meant to be opaque (i.e., alpha 1.0). Pixels that are different have a non-zero alpha which can be computed by subtracting the black background pixel from the white background pixel. Give or take some precision, the value of any red, green or blue component will be the alpha value.
George PhillipsGeorge Phillips
Ghostscript can handle transparency only if at build time the 'transpar' option was selected. Assuming your Ghostscript is the right version, you can add a parameter on the commandline:
(You can use variants for the opacity in the range [0.1]).
Also, have you tried to convert your Ghostscript-created .png (in case that background indeed is white instead of transparent) to a transparent background using ImageMagick's
convert
or GraphicMagick's gm convert
commands? Here is an example:BTW, in case Acrobat or AcroReader show all page backgrounds as white: this is the default setting even for really transparent backgrounds. You can change it in the application's setup options: IIRC the setting was inside the 'Page Display' options and named s.th. like 'Show transparency rasters'. (If I looked it up in detail, it possibly wouldn't help too much -- Adobe keeps shifting all options around in every new release. Just poke around there yourself, you'll find it now that you know it's there.)
Ghostscript Convert Png To Pdf
Kurt PfeifleKurt Pfeifle68.4k1515 gold badges186186 silver badges285285 bronze badges
Active2 years ago
I found that Ghostscript is able to convert PDF to Image format.
I tried PDF to Image Converter but not able to understand it clearly.
I have installed
gs905w64.exe
but when I tried to add reference
to my web application I am getting this error.Convert Png To Pdf Free
A reference to gsdll32.dll could not be added. No type libraries were found in the component.
Sivaji songs free download.user1530755user1530755
5 Answers
You can use C# to run the GhostScript command line or use Platform Invoke (pInvoke) calls to call the GhostScript dll directly.
GhostScript is primarily file based, so the input is path to a file on disk and the output is the creation of files on disk. The parameters used to call either the dll or exe are basically the same, so there is not a huge benefit to calling the dll directly, but does make for nicer code.
I have C# wrapper that can be used to call the ghostscript dll, if you email me (address on profile) I will sent it to you.
HTH
UPDATE:
Ghostscript Convert Png To Pdf Online Free
code repo moved to https://bitbucket.org/brightertools/ghostscript
Mark RedmanMark Redman16.9k1717 gold badges8181 silver badges125125 bronze badges
You Do not need to add any DLL reference to your project.First download the gs910w32.exe application filethen install it to your local computer.Get the location of the installed .exe file eg:-
'C:Program Files (x86)gsgs8.64bingswin32.exe'
use it in your C# application as :
IF your input PDF file name has any spaces, you need to change the argument to
you can specify the output image's aspect ratio in the argument with the -r flag.If you use '-r300' the width of the image will be 3000 pixel and height will change accordingly, from the above argument you will get 1024 to 768 size jpg image.
S.RoshanthS.Roshanth
1,22722 gold badges2121 silver badges3232 bronze badges
The
gsdll32.dll
file is not a managed .NET library. You can't reference it in your project. You have to include it in your project as 'content' (menu: Add existing item) and let VS copy it to the output directory. Meanwhile you should read the Ghostscript API docs and this article on PInvoke.net on how to reference the Ghostscript functions.Keep in mind that Ghostscript is all unmanaged code and that you have to do the clean-up yourself after using the library.
Edit: What Robert said is important, too. Of course, you have to use the correct version of the Ghostscript library.
ferofero
Why do you try to add the library as reference to your project?
gsdll32.dll
is a native dll, not a Dot-Net library. When I build the sample project using Visual C# Express 2010 I get an exe file. If I execute it it tries to access the
gsdll32.dll
. The problem is now that on a 64bit system a 64bit executable is generated but the gsdll32.dll
is compiled for 32bit. The correct solution would be to modify the source code and replace
RobertRobertgsdll32.dll
with gsdll64.dll
everywhere it occurs. The simpler solution is to use the 64 bit version of Ghostscript, copy the gsdll64.dll
into the same directory as the ConvertPDF.exe
and rename it to gsdll32.dll
. This definitely works - just tested and converted a PDF to TIFF.26.3k1313 gold badges6565 silver badges114114 bronze badges
you need to run the below command to reference the libraryhttp://www.nuget.org/packages/GhostScriptSharp/
Ghostscript Pdf To Image
VS2012 --> Tools --> Library Package Manager --> Package Manager Console
MayankMayank