Export polar charts of high maps to PDF using phantomjs

I am evaluating highcharts for a client project and ran into the problem of creating a polar diagram with phantomjs. Chart lines come out like a thick gray drop! I thought this was due to the animation, but it turned off. Try and post the image, but does anyone have any thoughts on what else might cause this? If I print a preview with chrome, it also looks fine.

Here is the image .

This was created as part of a report that I created using the rasterize.js script included in phantomjs. All other diagrams work fine, the polar diagram is the only one that does not come out. If I use a highcharts script export server with phantomjs, it works fine, but it only allows exporting 1 chart to PDF. I need to export the entire web page as a PDF, including some diagrams.

+5
source share
1 answer

In this case, the workaround for tracking project errors is:

https://github.com/ariya/phantomjs/issues/10364#issuecomment-14992612

All you have to do is delete all the elements of the page with low opacity before rendering to a file:

diff --git a/examples/rasterize.js b/examples/rasterize.js
index fcd74cd..dcc81d4 100644
--- a/examples/rasterize.js
+++ b/examples/rasterize.js
@@ -19,6 +19,16 @@ if (phantom.args.length < 2 || phantom.args.length > 3) {
             console.log('Unable to load the address!');
         } else {
             window.setTimeout(function () {
+                // Remove all low-opacity paths. see PhantomJS  issue #364 
+                page.evaluate(function () {
+                    var paths = document.getElementsByTagName("path");
+                    for (var i = paths.length - 1; i >= 0; i--) {
+                        var path = paths[i];
+                        var strokeOpacity = path.getAttribute('stroke-opacity');
+                        if (strokeOpacity != null && strokeOpacity < 0.2)
+                            path.parentNode.removeChild(path);
+                    }
+                });
                 page.render(output);
                 phantom.exit();
             }, 200);

, , .

+6

All Articles