KDReports icon indicating copy to clipboard operation
KDReports copied to clipboard

How to use vector images in the report to have high quality PDF files

Open useful-friend opened this issue 4 years ago • 5 comments

Hello there. is there a way to use vector images in the report or any workaround to achieve that.

useful-friend avatar May 11 '20 09:05 useful-friend

The workaround is so obvious that you probably guessed it: rendering into a (large) pixmap and giving that to KDReports.

We are limited by what QTextDocument::ImageResource supports.

Well, I suppose one could support SVG by deriving from QTextObjectInterface (similar to what ChartTextObject does for KDReportsChartElement) to implement rendering directly from SVG there (and create a new Element for the public API).

dfaure-kdab avatar May 11 '20 10:05 dfaure-kdab

Thanks for the info. I have tried the high-resolution rendering but I have some problems with the default dpi used in the report. As a matter of fact, I want to render a QChart into an image but when I get paperSize() from the report object, I get a very poor quality image that is not desirable. I checked the dpi used in the report and found out that the dpi is 120, which I believe is very low for being printed on a paper. There is also another problem that I want to produce reports in select-able different page sizes and can not use a fixed-width image. I appreciate if you can guide me through this by showing a way or giving a hint that I might be missing.

useful-friend avatar May 13 '20 16:05 useful-friend

Hello, I have exactly same question, the possibility to put QChart into the report. QChart is using Graphics View Framework to render its contents. With using render() method of QGraphicsScene its possible to render contents into a QPainter* Is KDChart using painter also for rendering its contents? Can it be done like KDChart?

milad-gh avatar May 18 '20 17:05 milad-gh

Is KDChart using painter also for rendering its contents? Can it be done like KDChart?

From what I have seen on the code I think it can. Then there is a matter of how to build the API for it. Maybe this should be discussed in a new issue.

correa avatar Aug 07 '20 13:08 correa

@useful-friend you can make the image very large (say 5k*5k pixels), and use a 100% width so it'll adapt to the page size.

dfaure-kdab avatar Aug 16 '21 12:08 dfaure-kdab