Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I export an SVG with both RGB and CMYK colors?

New Here ,
Apr 14, 2014 Apr 14, 2014

I'm trying to make a workflow for Illustrator (CMYK) to Web (SVG with CMYK colors and RGB fallbacks) to Print (CMYK PDF) using SVG. However, it looks like Illustrator only exports RGB colors in SVG files. Illustrator would only be responsible for the saving as SVG, then I'd use other tools to do the rest.

Is there a way to get Illustrator to export device-cmyk() or icc-color() values in addition to RGB colors in an SVG file? Is there a way to export spot color names as well?

Thanks!

33.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Sep 22, 2014 Sep 22, 2014

You probably don't have all the Batik dependencies in your classpath. I

think you'll need all those to run it. I'm accessing it from Java code from

some Batik examples but I'd imagine the executable might work as well. If

you're still having trouble, replying to the Batik thread might be helpful.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

thanks! the problem was, I had openjdk linked instead sun, to the java command. now it works without errors, but... the pdf generated still has its colorspace sRGB, even though the svg file has a profile linked and the colors are set in double format (i.e. #84B819 icc-color(cmyk, 0.57, 0, 1, 0) )

is there any switch to select the colorspace when rendering?

thanks in advance, kind regards
dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

How about fill="#71523A device-cmyk(0.7,0.8,1,0)"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

unfortunately doesn't work...

I noticed that device-cmyk was introduced in svg2, and my doc has 1.1 version.
I tried playing with different versions and doctypes, but still I am getting namespace sRGB.

I paste my input svg, maybe you can spot some error here?
gist:1ecfad9e2a8ef9023eb2

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

all the texts are at the bottom of the doc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

You won't need to change anything besides the colors. I'm doing something

similar to what you are doing by the looks of it. I was able to save from

Illustrator, then only add " device-cmyk(...)" after each fill color.

I found that when opening the resulting PDF in Illustrator for a doc like

the one you sent, I'd then get a warning that there was both CMYK and RGB

in the same document. Then I could inspect each item color by color and

verify that the CMYK colors came out exactly vs being converted from RGB

values.

What do you mean by namespace RGB?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

I test it with identify -verbose output.pdf | grep space

the input.pdf - returns CMYK while, output.pdf sRGB

I tried opening it in Illustrator again, but it opens it as RGB and does an automatic conversion to CMYK which is not exact.

No warrning as in your case.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

Hmm, I know it took me quite a while before I got it to work, but I don't

recall any problems once I had the right jars in place. You might need to

make sure you have an updated version of FOP as well because earlier

versions' PDF transcoding didn't support device-cmyk I think.

Are you using FOP 1.1?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2014 Sep 23, 2014

yes, it seems I have fop 1.1...

what else could I try?

would you try to convert my file or send me some sample you're using for testing?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014

Unfortunately I don't have that code running right now, so I can't convert

for you, but everything should be correct in what you have. I think there

was some page that mentioned something about using a newer FOP version with

Batik and potential issues or conflicts you might run into, but I can't

seem to find it.

If you can output the FOP version number when running that might help you

verify that you're running the latest. Whatever FOP stuff comes packaged

with Batik won't support the CMYK features you need (I think). This was

stated somewhat in the other thread we referenced, but since then I think

the new color code was merged so it should be in the latest FOP.

If you aren't getting any errors, I think the Batik code is running

correctly. If you install Squiggle for the stable Batik version and open

the modified SVG with the CMYK colors, you should get an error. This is why

I think the problem is with your FOP version.

Beyond that, I'm not sure what could be wrong. Hope you get it working!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014

Hi Jon_wu, thanks for you patience and helping out.


yep, squiggle complains about device-cmyk in my document. but only in the version 1.7
I test pdf generation with: 1.7, trunk and svgcolor12

I would say your theory about FOP version might be right, but I am not sure how to include it in batik.
I have downloaded and compiled fop 1.1, but I'm stuck here.
I tried replacing pdf-transcoder from batik with fop-transcoder or fop-transcoder-allinone (changing the name to pdf-trancoder) but it didn't work and gave some errors about missing classes

I found another thread where you speak about this, but I can't quite get the solution proposed there:
SVG image with CMYK colours - is it possible? - Stack Overflow

so, does it mean:
1) compile batik (svgcolor12) all-jar
2) move batik-all-jar to fop's lib and compile fop
3) move fop's transcoder back to batik???

4) ???
5) PROFIT

I don't work much with java and it's a bit confusing.

best
dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014

hmm, I just found this:
Re: SVG Color 1.2: proof of concept done

will check it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014

uff, I GOT IT!

basically all you need is to compile fop from trunk (I used github to get the source).
It has latest batik-trunk included (which recently got svgcolor12 merged, so it's not necessary to use/compile standalone batik at all).

svg version is 1.1 (but I am not sure if it matters)
colors are defined as follows: fill="#E5352C device-cmyk(0, 0.9, 0.86, 0)"

the command to generate pdf is:

./fop -imagein input_cmyk.svg -pdf output-cmyk.pdf

identify -verbose output-cmyk.pdf shows colorspace: sRGB, but when opened in Illustrator it detects both RGB and CMYK profiles, as you mentioned (thx!)


so the whole pdf(cmyk) -> svg (rgb/cmyk) -> pdf (cmyk) workflow is:
1) create a pdf in illustrator and export it to svg (rgb)
2) use illustrator scripting to loop over all objects and get their cmyk colors
3) inject the cmyk colors to the created svg file using format  fill="#E5352C device-cmyk(0, 0.9, 0.86, 0)"
4) now you can edit svg on the web (we use it for editing templates prepared by the design company in the web environment)
5) covert edited svg(cmyk) back to pdf using fop (./fop -imagein input_cmyk.svg -pdf output-cmyk.pdf)


now you have a pdf, edited in the cloud, that you can send directly to a professional printer and it keeps all original colors.

jon__wu - thanks a lot for your ENORMOUS help, patience and good pointers.

we'll be testing it soon and rolling out to production in the following weeks if everything works OK.
I may publish back some sample code on my github.com/danielzzz

thanks again, regards
dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014

Awesome! Glad you got it working.

It sounds like that solution may be all you need, but if you run into

anything weird, here are some potentially useful tips. If you're using the

fop command to generate your PDF, I'm not 100% sure if that's the same as

running from batik directly. It might be though because I have a pretty

loose understanding, but if you have any SVG specific stuff like filters

going on, I'm not sure if you have to run things a little differently.

It's my understanding that to process a full SVG, Batik would do some

stuff, then pass remaining stuff off to FOP. For example, I had an issue

where some shapes were getting rasterized in Batik before hitting FOP

because they were using the opacity attribute. Instead I changed to

fill-opacity and got vectors out. See

http://batik.2283329.n4.nabble.com/PDFTranscoder-Text-Opacity-amp-Transcoding-Hints-td2978603.html

towards the end for more details.

On Wed, Sep 24, 2014 at 3:26 PM, Adobe Forums <forums_noreply@adobe.com>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2014 Sep 24, 2014
LATEST

thanks! 

What I am not sure how to do is how to include fop in batik - check my previous messages to see what I mean...
When I tested it with batik trunk or svgcolor12 it generated files not recognizable by illustrator as cmyk, but I think it includes 1.0 or even lower by default.
I could not figure out how to include fop 1.1 in batik...

therefore, I hope standalone fop will be enough, I need to run more tests on actual templates we're using, to be sure.
what we process is mostly simple texts, however there are also some images (not sure if bitmaps or curves). I will have to test how it goes..

thanks again, dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines