shairontoledo / rghost

RGhost is a document creation and conversion API. It uses the Ghostscript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents. Support(PDF,PS,GIF,TIF,PNG,JPG,etc)
http://rghost.rubyforge.org
MIT License
187 stars 46 forks source link

Gradient issue while converting eps to pdf #57

Closed leenasn closed 10 years ago

leenasn commented 10 years ago

Hi,

While converting the EPS files to PDF, I am seeing some PDF files not having the gradient correctly as its displayed in the EPS files. Can someone help me to fix the same?

Following are the links to both the EPS and PDF for reference.

https://www.dropbox.com/s/08ae2aidu1p0kbu/fop%20wingbowl2013.eps

https://www.dropbox.com/s/paeez7robezfz4c/fop%20wingbowl2013-crop.pdf

Thanks, Leena

shairontoledo commented 10 years ago

@leenasn try to render the pdf with option quality: :printer, ref: https://github.com/shairontoledo/rghost/wiki/PDF-Quality

leenasn commented 10 years ago

Thanks a log @shairontoledo. It definitely did solve the problem.

I see a difference between the command line output and using RGhost library. I've the following method:

def import_file_to_pdf doc = RGhost::Document.new doc.set RGhost::Eps.new "/home/vagrant/designtool_poc/eps/fop wingbowl2013.eps" doc.render :pdf, :filename => "/home/vagrant/designtool_poc/pdf/fop wingbowl2013.pdf",:quality => :printer end

When I call the above method, the pdf output file it creates truncates some part.

But when I run the the following command

gs -sDEVICE=pdfwrite -o output.pdf -dEPSCrop -dEPSFitPage -dPDFSETTINGS=/printer fop\ wingbowl2013.eps

I get the proper output which does not truncate the content. Is there any setting I should add so that the output file I get is in consistent with the gs command I run in the command line?

Thanks, Leena

shairontoledo commented 10 years ago

@leenasn You can reproduce same ghostscript input parameters by passing :d or :raw parameter in rghost document render method http://www.ruby-doc.org/gems/docs/l/lunks_rghost-0.8.7.6/RGhost/Document.html#method-i-render

leenasn commented 10 years ago

@shairontoledo thanks once again.

leenasn commented 10 years ago

@shairontoledo I also saw that for some files Adobe Illustrator throws the error "An unknown shading type was encountered". Any clue on that? Am I missing some settings again?

shairontoledo commented 10 years ago

@leenasn try to export the eps to a previous version also disable the thumbnail preview.

leenasn commented 10 years ago

@shairontoledo Is there anything that can be done to avoid this problem while converting? The point is that the above error message I got for the file that got converted by RGhost, so am asking is there anything that needs to be done for RGhost so that I don't get the above error?

Thanks, Leena

shairontoledo commented 10 years ago

@leenasn try to convert that EPS directly via ghostscript and let me know the result.

leenasn commented 10 years ago

@shairontoledo This is what I tried. I ran the following code to generate the PDF:

def import_file_to_pdf
  doc = RGhost::Document.new 
  doc.set RGhost::Eps.new "/home/vagrant/designtool_poc/eps/fop wingbowl2013.eps"
  doc.render :pdf, :filename => "/home/vagrant/designtool_poc/pdf/fop wingbowl2013.pdf",:quality => :printer 
end

I tried the following command with ghostscript:

gs -sDEVICE=pdfwrite -o output.pdf -dEPSCrop -dEPSFitPage -dPDFSETTINGS=/printer fop\ wingbowl2013.eps

But am getting different output files. The differences are:

Please find the link to the EPS file: https://www.dropbox.com/s/vjv50x4dvc2qw02/hero%20%28FRONT06%29.EPS?dl=0

The following is the output file created by gs command: https://www.dropbox.com/s/zjbc4u555f4jm2q/hero.pdf?dl=0

The following is the output file created by RGhost: https://www.dropbox.com/s/ggb5dozeu71jq99/hero%20%28FRONT06%29.EPS.pdf?dl=0

For another file I tried with the same code, it removed the grouping while converting to PDF. It also showed the error "An unknown shading type was encountered" while opening the generated PDF file in Illustrator. The following are the link to the EPS and PDF.

https://www.dropbox.com/s/biclx2h54pmo470/survivor%20book.eps?dl=0 https://www.dropbox.com/s/q86vysfpwd0i6vb/survivor%20book.eps.pdf?dl=0

Let me know if you need further help.

Thanks, Leena

shairontoledo commented 10 years ago

It seems the problem is the way that Illustrator is creating the EPS, https://bugs.launchpad.net/inkscape/+bug/905629

leenasn commented 10 years ago

@shairontoledo ok. As mentioned in the bug, opening the PDF and saving it seem to fix the problem about the error.

Any clue on why there are changes in the grouping? Do you think thats also related to the compatibility issue? I don't think so because like I mentioned above, it happens with other files too where Illustrator does not throw the error for shading.

So I've 2 questions:

The tool am building allows the user to upload EPS files which gets converted to PDF which can be used for custom printing. It impacts the quality of the printing when anything gets changed or is not retained in the generated PDF. Right now the only way to know that is by visual inspection i.e. open both EPS and PDF in Illustrator and see where the differences are. Is there anyway we can automate the same and notify when there is a difference between the two?

Thanks, Leena

leenasn commented 10 years ago

Looks like the "group" "ungroup" is Adobe specific feature and not part of normal PS or PDF specification. So It won't be possible to retain the same using Ghostscript. Got the following response from Ghostscript and Adobe:

http://bugs.ghostscript.com/show_bug.cgi?id=695451 https://forums.adobe.com/thread/1562128?sr=inbox&ru=1653248