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

Export to PDF #509

Closed
pkubat opened this issue Sep 18, 2013 · 75 comments
Closed

Export to PDF #509

pkubat opened this issue Sep 18, 2013 · 75 comments

Comments

@pkubat
Copy link

pkubat commented Sep 18, 2013

Use PhantomJS to render images of a dashboard. These images then could be email/shared. All this could be scheduled.

rashidkpc came up with this idea the other day in IRC. There is an issue with AngularJS' routing though, and it does not work.

@devilankur18
Copy link

+1

@pkubat
Copy link
Author

pkubat commented Sep 24, 2013

Comments via IRC

[kubes] Ok, what do you think the issue is. Can you point me in the write direction and I take swing @ it.

[rashidkpc] basically you need to convince phantom JS to both wait for thr route to full resolve, as well as wait for all of the data to be loaded

[kubes] rashidkpc: Is there any element to check to tell if the data is loaded? If I have phantomjs just wait for N sec it works.. thinking of waiting for something...

[rashidkpc] kubes: not really, everything is async, and the panels operate independently, there's currently no way to tell if everything is "done"

@pkubat
Copy link
Author

pkubat commented Sep 24, 2013

here is a modified version of the example https://github.com/ariya/phantomjs/wiki/Screen-Capture

rasterize.js

Increase(added) the WaitTime to 10 seconds

var page = require('webpage').create(),
    system = require('system'),
    address, output, size;
//How to to wait for kibana to load and the data from elasticseatch in milliseconds.
var waitTime = 10 * 1000;

if (system.args.length < 3 || system.args.length > 5) {
    console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
    console.log('  paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
    phantom.exit(1);
} else {
    address = system.args[1];
    output = system.args[2];
    page.viewportSize = { width: 1024, height: 1024 };
    if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
        size = system.args[3].split('*');
        page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
                                           : { format: system.args[3], orientation: 'portrait', margin: '1cm' };
    }
    if (system.args.length > 4) {
        page.zoomFactor = system.args[4];
    }
    page.open(address, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
            phantom.exit();
        } else {
            window.setTimeout(function () {
                page.render(output);
                phantom.exit();
            }, waitTime);
        }
    });
}

@pkubat
Copy link
Author

pkubat commented Sep 24, 2013

I would be nice: http://newspaint.wordpress.com/2013/04/05/waiting-for-page-to-load-in-phantomjs/

@rashidkpc rashidkpc changed the title Utilize phantomjs to render screenshots (schedule email of dashboards) Export to PDF Jan 9, 2015
@rashidkpc rashidkpc added this to the 4.2.0 milestone Jan 9, 2015
@rashidkpc rashidkpc removed this from the 4.2.0 milestone Mar 2, 2015
@rashidkpc rashidkpc added v4.3.0 and removed v4.2.0 labels Mar 14, 2015
bcicen added a commit to bcicen/phantom-snapshot that referenced this issue Mar 16, 2015
@simianhacker simianhacker removed their assignment Apr 22, 2015
@monotek
Copy link

monotek commented Apr 23, 2015

+1

@damienbod
Copy link

When will this be supported? 2015?

Greetings Damien

@ziadloo
Copy link

ziadloo commented Jul 16, 2015

For the records:

  • You don't need to use .setTimeout to make sure that a webpage has completely loaded before you'll call render. You can use onConsoleMessage event handler and pre-specific messages to communicate among Javascript inner code and outer script. And within Javascript you surely know you when are ready to render:
var page = require('webpage').create(),
    system = require('system'),
    address, output, size;
//How to to wait for kibana to load and the data from elasticseatch in milliseconds.
var waitTime = 10 * 1000;

if (system.args.length < 3 || system.args.length > 5) {
    console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
    console.log('  paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
    phantom.exit(1);
} else {
    address = system.args[1];
    output = system.args[2];
    page.viewportSize = { width: 1024, height: 1024 };
    if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
        size = system.args[3].split('*');
        page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' }
                                        : { format: system.args[3], orientation: 'portrait', margin: '1cm' };
    }
    if (system.args.length > 4) {
        page.zoomFactor = system.args[4];
    }
    page.open(address, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
            phantom.exit();
        } else {
            page.onConsoleMessage = function(msg, lineNum, sourceId) {
                if (msg == 'done') {
                    page.render(output);
                    phantom.exit();
                }
            };
        }
    });
}
  • My experience with PhantomJs (which is a little old now) is that; major problem with PhantomJs as a report generator tool is that it does not produce paper perfect content. I struggled a lot but I couldn't generate paper aligned content in my HTML. Stuff like preventing a table from being cut off in middle is unavoidable.

@rashidkpc rashidkpc added v4.5.0 and removed v4.3.0 labels Jul 23, 2015
@vg15
Copy link

vg15 commented Jul 24, 2015

Sorry Guys , can someone help me to run this JS in Phantom. Actually I am new to Phantom and I am sure I am missing some argument. Below I have mentioned my command , with this it is creating blank PDF file . Please suggest how I can modify it to show correct result .

phantomjs abc.js http://www.google.com vikas.pdf [60cm*60cm,A4,Letter]

Second question regarding this would be do I need to mention complete kibana dashboard URL in the URL argument ?

@MosesMansaray
Copy link

+1

3 similar comments
@iemem15
Copy link

iemem15 commented Jul 29, 2015

+1

@shanimsa
Copy link

+1

@tdwolf
Copy link

tdwolf commented Aug 12, 2015

+1

@absmith82
Copy link

+1

2 similar comments
@theazyfa
Copy link

+1

@yinchuan
Copy link

+1

@ranjansaga
Copy link

+5. Please take care of the page breaks too. So that the graphs are not distributed in two pages while printing.

@kc89rst
Copy link

kc89rst commented Mar 9, 2016

+1

@jmtsi
Copy link

jmtsi commented Mar 11, 2016

I have tried using this: https://github.com/fzaninotto/screenshot-as-a-service
It uses the same PhantomJS approach and adds additional configuration options to bypass http basic auth etc. It seems to work otherwise, but Kibana (v4.4.1) reports an error: Courier Fetch Error: unhandled courier request error: unknown error. Any ideas?

Nevermind. This works well after updating PhantomJS to 2.1.1 :)

@yanndb
Copy link

yanndb commented Apr 17, 2016

+1

16 similar comments
@acristu
Copy link

acristu commented May 10, 2016

+1

@Secespitus
Copy link

+1

@thethomp
Copy link

+1

@rgroten
Copy link

rgroten commented May 25, 2016

+1

@mvazquezc
Copy link

+1

@piglesiasm
Copy link

+1

@vaibhavsankaye
Copy link

+1

@dimatha
Copy link

dimatha commented Jun 20, 2016

+1

@mpok3
Copy link

mpok3 commented Jun 27, 2016

+1

@ngwmm
Copy link

ngwmm commented Jun 28, 2016

+1

@imangd
Copy link

imangd commented Jul 12, 2016

+1

@CyberSecDog
Copy link

+1

@torse
Copy link

torse commented Jul 25, 2016

+1

@henpat
Copy link

henpat commented Jul 26, 2016

+1

@eramos-ce
Copy link

+1

@SaketKum
Copy link

SaketKum commented Aug 8, 2016

+1

@biswajit86
Copy link

Elastic devs, now that reporting feature is already released , will that be utilized to bring pdf export to kibana ?

@kimchy
Copy link
Member

kimchy commented Sep 6, 2016

heya, we have released reporting as a plugin to kibana, you can find more info here: https://www.elastic.co/products/reporting.

@kimchy kimchy closed this as completed Sep 6, 2016
@biswajit86
Copy link

@kimchy , reporting seems to be a paid plugin. Will the pdf export ever come to kibana core itself .

@kimchy
Copy link
Member

kimchy commented Sep 6, 2016

@biswajit86 no, there are no plans. The reporting infrastructure we built and the generation of PDF/images are part of xpack. Note, we do provide it as part of our cloud offering in our cheapest tier (Standard): https://www.elastic.co/cloud/as-a-service/subscriptions.

@kumarProspera
Copy link

kumarProspera commented Apr 25, 2017

how to authenticate in kibana using phantomjjs and then take a screen-shot?

@theMiddleBlue
Copy link

theMiddleBlue commented Jun 6, 2017

Hi,

After some tests, I managed to export a Kibana dashboard to PDF using wkhtmltopdf.

More information here: https://github.com/theMiddleBlue/From-Kibana-to-PDF

hope this can help ✌️

@varunsharma27
Copy link
Contributor

varunsharma27 commented Jun 9, 2017

@vg15

Sorry Guys , can someone help me to run this JS in Phantom. Actually I am new to Phantom and I am sure I am missing some argument. Below I have mentioned my command , with this it is creating blank PDF file . Please suggest how I can modify it to show correct result .

phantomjs abc.js http://www.google.com vikas.pdf [60cm*60cm,A4,Letter]
Second question regarding this would be do I need to mention complete kibana dashboard URL in the URL argument ?

Try this:-
phantomjs abc.js https://www.google.com testing.pdf A4 1920px

w33ble pushed a commit to w33ble/kibana that referenced this issue Sep 13, 2018
* Checked out function_wrapper from common-tests

* Removed url arg from image and fetch_image function. Added unit testsfor image.

* Changed default val for _ to an array containing an empty string in markdown. Added unit tests for markdown

* Updated unit tests for markdown

* Changed default value of paginate in table to true. Added unit tests for table

* Unit tests for repeatImage

* Unit tests for revealimage

* Updated render to not mutate context. Added unit tests for render

* Pulled out style objects into a fixtures file. Updated imports in markdown, render and table unit tests

* Removed large objects and cleaned up tests

* Added tests for plot

* Cleaned up tests for markdown and render

* Pulled out plot helper functions into separate files. Removed step from seriesStyleToFlot

* Added seriesStyle tests for plot. Removed unused bubble options in plot function.

* Added pointseries and style fixtures

* Added tests for getFlotAxisConfig

* Added unit tests for getLegendConfig

* Added tests for getColorsFromPalette

* Added tests for getTickHash

* Added tests for seriesStyleToFlot

* Refactored plot and added unit tests

* Rearranged test pointseries

* Added tests for data in plot

* moved getColorsFromPalette to lib

* Renamed testpointseries and updated tests for plot

* Added default values to pie. Added unit tests for pie. Added test pointseries for pie.

* Removed .js

* Cleaned up tests

* Cleaned up tests

* Removed comments for url handling in image view

* Removed label color from pie function

* Changed palette colors and updated tests

* Wrapped empty string in double quotes for default values in markdown and replace. Commented out tests that require an instance of the interpreter

* Removed fallback value for css in render

* Removed null types from markdown args

* Removed pie tests for 'combine' arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests