Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMYK support in PDF export #32754

Open
Andreasox opened this issue Nov 9, 2019 · 38 comments
Open

CMYK support in PDF export #32754

Andreasox opened this issue Nov 9, 2019 · 38 comments
Labels
Feature Request Map and Legend Related to map or legend rendering Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks

Comments

@Andreasox
Copy link

CMYK support in PDF export would enhance the value of QGIS for high-quality printing.
My understanding is:
Qt5 do support CMYK on screen
Qt5 does not support CMYK support in PDF export
Mapper, https://github.com/OpenOrienteering/mapper, also built on Qt, has implemented CMYK support for PDF export by forking some Qt classes.
Mapper's main developer can give guidance from the work he did for Mapper.
My company do have developers that may assist.

@nyalldawson
Copy link
Collaborator

There's no support (yet) in qt even for on-screen cmyk

@Andreasox
Copy link
Author

Andreasox commented Nov 9, 2019

On-screen CMYK is not really needed.
Although QColor do support CMYK according to https://doc.qt.io/qt-5/qcolor.html
It should be enough with a config file holding the RGB-CMYK conversion used for PDF export.
In Mapper specified colours are defined as RGB and optionally in CMYK as well.
image

@nyalldawson
Copy link
Collaborator

It is necessary to handle this correctly on screen too - CMYK changes the blending model entirely, so a CMYK based map will look different on screen vs those same colors converted to RGB and using an RGB blending model.

@Andreasox
Copy link
Author

Andreasox commented Nov 9, 2019

I am working with high-quality cartography and there CMYK values are defined by the printing capabilities and/or in standardised specifications (eg. orienteering maps). The screen can only be used as reference if using advanced colour management profiling against selected paper qualities. The users must be aware of screen contra print differences.
As a side note we have realized that Windows 10 RIP is vastly enhanced over W7, and is much better than Adobe standard RIP. Especially for thin lines due too much higher LPI.
I.e. the print workflow can be more important than screen calibration.
I assume Qcolor conversions can be used for colors not defined in a config file.

@SilvioGrosso
Copy link

Hello,

Perhaps, you can take a look at Krita [1], an open source software, which relies on the QT toolkit (5.12.X to be more precise...).
With Krita you can take advantage of the CMYK mode. However, I don't know whether they implemented it thanks to the Qt librairies or by way of some internal code...

[1] https://docs.krita.org/fr/general_concepts/colors/color_models.html

@nyalldawson
Copy link
Collaborator

@SilvioGrosso Krita uses it's own painting engine -- it doesn't use any of the QPainter API

@nyalldawson
Copy link
Collaborator

I am working with high-quality cartography and there CMYK values are defined by the printing capabilities and/or in standardised specifications (eg. orienteering maps). The screen can only be used as reference if using advanced colour management profiling against selected paper qualities. The users must be aware of screen contra print differences.

I realise this. And that's why to do this properly we need to correctly handle CMYK blending for screen as well as outputs, and ensure that a project set to a CMYK color mode never generates or displays colors outside of the CMYK gamut. Otherwise QGIS would be giving a false preview of the results, and you may as well just stick to RGB editing in QGIS and conversion to CMYK as a separate post-processing step outside of QGIS. The value in adding native support for CMYK would be that users could edit and design maps inside QGIS with confidence that the result will color match the output exactly.

@SilvioGrosso
Copy link

SilvioGrosso commented Nov 10, 2019

Hello @nyalldawson

Krita uses it's own painting engine -- it doesn't use any of the QPainter API

Yep. That's what I have thought too but I was not 100% sure...

What I know for certain is that the Krita developers have not used the QT librairies to import and export the SVG vector images because QT is not powerful enough for their needs.
An interesting library for this task might be resvg [1]:
https://github.com/RazrFalcon/resvg

At present, one workaround with QGIS missing printing capabilities might be to take advantage of Scribus [2], another QT open source application. Needless to say, a native support of CMYK would be much better :-)

[1] http://libregraphicsworld.org/blog/entry/introducing-libresvg
[2] https://wiki.scribus.net/canvas/Color_Management_setup

@Andreasox
Copy link
Author

Andreasox commented Nov 10, 2019

I am working with high-quality cartography and there CMYK values are defined by the printing capabilities and/or in standardised specifications (eg. orienteering maps). The screen can only be used as reference if using advanced colour management profiling against selected paper qualities. The users must be aware of screen contra print differences.

I realise this. And that's why to do this properly we need to correctly handle CMYK blending for screen as well as outputs, and ensure that a project set to a CMYK color mode never generates or displays colors outside of the CMYK gamut. Otherwise QGIS would be giving a false preview of the results, and you may as well just stick to RGB editing in QGIS and conversion to CMYK as a separate post-processing step outside of QGIS. The value in adding native support for CMYK would be that users could edit and design maps inside QGIS with confidence that the result will color match the output exactly.

I agree that your description is the ideal but resources ...
We currently uses a Ghostscript-based post-process but see a value in adding the same kind of "pseudo-CMYK" support as Mapper has done.

@mbernasocchi
Copy link
Member

@nyalldawson did you ever have a tought about how much work this would require?

@haubourg
Copy link
Member

@mbernasocchi that's fun you ask now, I was about to ask the same. At least our customers are interested in.

@mbernasocchi
Copy link
Member

same here, we might have something as well

@nyalldawson
Copy link
Collaborator

@haubourg @mbernasocchi can we follow up via email? (nyall@north-road.com). I've got a bunch of previous email exchanges relating to this which I'll cc your way and fill you in on the situation...

@mbernasocchi
Copy link
Member

great thanks

@llwj0303
Copy link

im also facing this problem, I had used GhostScript to change RGB pdf to CMYK color mode, but it is not suitable for me, as something like RGB(0,0,0)->CMYK(0.72, 0.67, 0.67, 0.88), that may waste a lot ink for printing it.
does the https://github.com/OpenOrienteering/mapper, can solve my problem?
you guys if find answer pls info me 479379320@qq.com
thanks a lot~

@AndyFollis
Copy link

My problem is perhaps a subset of this - when sending to print on a commercial printing press rather than a laser printer, I need the black to be C0 M0 Y0 K100, otherwise I risk colour fringing and bleed in thin black lines.
I'm happy enough with the screen showing RGB but I need to at least be able to set black as CMYK 'pure black' not this 'rich black' which has other colours (and thus ink!) in it.
At the moment I'm having to export then do a printing prefight in Adobe Acrobat Pro to correct the 4c blacks - and I then need to set the correction for each different 4c black individually.
If anyone can help on this I'd be really grateful.

@vpicavet
Copy link
Member

A note on what ArcGIS does with this matter. This item in the FAQ dating back to 2016 adds a note concerning RGB / CMYK :

CMYK output is supported with the following limitations:

· ArcMap raster layers always render internally as RGB colors. This means that even when a raster is defined with the color selector in CMYK mode, it does not internally get marked as CMYK color, and the raster layers stores only the RGB equivalent. On export to a CMYK graphics file, the stored RGB information is converted from RGB back to CMYK, but the CMYK values do not match the user defined CMYK values selected during set up of the raster layer properties.

· Vector layers with transparency render as raster. Thus, any transparent vector layer using CMYK colors are not preserved CMYK numbers during output to a CMYK export file.

· Picture Marker symbols sourced from a vector EMF file always use the colors defined in the EMF. Since the EMF file format does not support CMYK colors, it is not possible to define EMF Picture Marker symbols as CMYK. Instead, use a Simple Marker Symbol or a Character Marker Symbol, and follow the procedure documented above to define the symbol colors in CMYK.

From what I understand, it means that ArcGIS internally handles colors as RGB, but they keep a correspondence table when you input a CMYK value, allowing for CMYK colors exported correctly with the above limitations.

A full CMYK support would be great and better than ArcGIS, but it would need improvements in Qt as it seems.

@senorhesles
Copy link

Can we get a feature bounty or something going on the Qt and QGIS end so that this can be implemented? I am very, very willing to contribute as I do not want to have to migrate to ArcGIS or Mapublisher.

@eurojam
Copy link

eurojam commented Jul 29, 2021

Would it be possible to restrict CMYK support in a first phase on the Layout modules in QGIS to keep the expenses in a limit? Also the blendig mode stuff can stay as it is in the map canvas environment (without CMYK support)...
We are also willing to contribute to this feature with a funding.

@jayaddison
Copy link

If anyone waiting on a fix here has Ubuntu focal available to them -- does the resolution of QTBUG-73171 improve the results here?

That bugfix is for an issue where QColor RGB black -- as represented by red=0 green=0 blue=0 -- was converted to cyan=1 magenta=1 yellow=1 black=1, instead of cyan=0 magenta=0 yellow=0 black=1.

It's not clear to me whether the fix corrects on-screen rendering and/or printing pipelines. The fix was added in 5.12.2 of QT, and focal currently distributes 5.12.8.

@nyalldawson
Copy link
Collaborator

@jayaddison

No, that doesn't give us the missing functionality yet.

@jayaddison
Copy link

Ok, thanks @nyalldawson. I've done a bit more of my homework, and now (think that I) understand that the limitation is in Qt's QPdfEngine, which renders colour-related PDF content in RGB (and using colourspace DeviceRGB). Is that getting closer to it?

@AndyFollis
Copy link

AndyFollis commented Jul 24, 2022 via email

@Andreasox
Copy link
Author

Andreasox commented Jul 25, 2022 via email

@arx-e
Copy link

arx-e commented Oct 4, 2022

I have confronted this issue when given a large amount of distribution maps destined for offset printing. the maps were in RGB of course and most of the black lines and texts were being converted as rich blacks. So I created an Illustrator script that looks inside an illustrator file for rich black colors and replaces them with 100%K and also sets their overprint setting to "true".

The script can be used to batch process pdf files and of course can be modified in order to do more clean up. For example I have used conditions to locate and replace reds, yellows, the maps' background etc

The script can be found here: https://github.com/arx-e/pdf-to-cmyk-and-replace-rich-black

@janvda
Copy link

janvda commented Dec 22, 2022

I am interested in this feature.

It would also be nice in the absence of this feature if there is a free postprocessing step that does this and which is properly documented.

I think that the "Adobe" post processing solutions are not free (apart from the 7 days free trial period).
The best free approach seems ghostscript. This is a nice link but I haven't tried it:

@frspp
Copy link

frspp commented May 12, 2023

@senorhesles Arcgis does not support CMYK. You can use CMYK sliders to choose RGB color. So when exported the "CMYK" colors are actually RGB and won't match chosen CMYK values at all anymore. What a mess 😕 (have tried it). See full explanation in #32754 (comment)

@frspp
Copy link

frspp commented May 12, 2023

Just throwing out a wild idea: As LAB/RGB gamut is much wider than CMYK gamut what if QGIS would continue to use RGB like it does now and feature/option "Limit to CMYK gamut" would be added to the color selector. This feature would limit the color values to those which are available in some widest CMYK profile, for example in Coated Fogra39. By doing this the on screen view would be much more accurate as it would not include most vivid RGB's, those which cannot be printed in CMYK.

Of course the rich black would still be an issue (=in CMYK graphics black/grey should contain only K and no other colors). If a printing press have a modern workflow they can/will handle converting CMYK rich black to CMYK K only. Imo seeing too vivid colors while designing map is bigger issue than having rich black.

Would this make any sense?

@alexbruy alexbruy added the Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks label Dec 7, 2023
@alexbruy alexbruy added the Map and Legend Related to map or legend rendering label Dec 7, 2023
@Ricmokodo
Copy link

Just my two cents, having a "convert RGB black to 100K black" checkbox on PDF export would get us 80% there as far as utility. From my experience and in other comments, PDF is the most common export format going to print. I agree with other comments about doing it the right way long term. Maybe this narrow solution is a way to plant the seed for future development.

@andreasneumann
Copy link
Member

The good news that upstream we are working with Qt developers to improve Qt to support CMYK in their color models and conversion, focusing on PDF and TIFF formats ... Also, QGIS needs to be changed then to take advantage of the new classes and methods.

It probably will take a while until this ends up at the users desktop (because first this needs to end up in our libraries), but it will come ...

@dg0yt
Copy link

dg0yt commented Jan 11, 2024

The good news that upstream we are working with Qt developers to improve Qt to support CMYK in their color models and conversion, focusing on PDF and TIFF formats ... Also, QGIS needs to be changed then to take advantage of the new classes and methods.

Are the changes visible?
And AFAIU a key desire is to preserve original CMYK while QColor is passed through painting on a PDF.
Instead of "conversions".

@andreasneumann
Copy link
Member

Are the changes visible?

Not sure yet. Probably there won't be an exact color match that shows the colors exactly as they would be printed (that would also require a calibrated monitor - most people don't have that).

The developer proposes to integrate https://www.littlecms.com/

And AFAIU a key desire is to preserve original CMYK while QColor is passed through painting on a PDF.
Instead of "conversions".

Yes, the original CMYK values would be preserved when rendering to PDF and TIFF files. That's the goal of the whole exercise. Cartographers will be able to choose between CMYK and RGB color models in the color choice. If they go with CMYK, then the original CMYK values will be preserved in the QGIS project file and also be used during the export.

As stated previously - it will take some time until CMYK will be available for QGIS users. Probably 2025. Some early experiments may show up earlier.

Early versions also may not support opacity and blend modes. They probably will be added later on (hopefully).

@AndyFollis
Copy link

AndyFollis commented Jan 11, 2024 via email

@dg0yt
Copy link

dg0yt commented Jan 11, 2024

Are the changes visible?

Not sure yet. Probably there won't be an exact color match that shows the colors exactly as they would be printed (that would also require a calibrated monitor - most people don't have that).

I actually meant the source code and API changes.
QGIS is not the only consumer.

@SilvioGrosso
Copy link

SilvioGrosso commented Jan 11, 2024

I actually meant the source code and API changes.
QGIS is not the only consumer.

Yep. It would be interesting to get this final development useful for other softwares, QT based, as well (Krita, FreeCAD, LibreCAD, QCAD, Scribus etc).

I suppose this is already taken into account right now (hopefully...) by the QT developers.
Probably, it also goes without saying since it is in the future interest of everyone.

@troopa81
Copy link
Contributor

I proposed a QEP regarding the support of CMYK into QGIS. Please let me know if you are interested in testing or even funding part of the developments.

@eurojam
Copy link

eurojam commented Feb 27, 2024 via email

@AndyFollis
Copy link

AndyFollis commented Feb 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Map and Legend Related to map or legend rendering Print Layouts Related to QGIS Print Layouts, Atlas or Reporting frameworks
Projects
None yet
Development

No branches or pull requests