Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Can't render to stdout #481

Open
slorber opened this issue Mar 3, 2016 · 4 comments
Open

Can't render to stdout #481

slorber opened this issue Mar 3, 2016 · 4 comments

Comments

@slorber
Copy link

slorber commented Mar 3, 2016

Hello,

I have reported a bug to PhantomJS here

When running

var page = require('webpage').create();

page.open('http://blog.zenika.com/', function() {

  setTimeout(function() {
    page.render("/dev/stdout",{ format: "png" });
    phantom.exit()
  }, 1000);

});

it does not output anything

But it only happens when installing phantomjs with sudo npm install -g phantomjs, not when using apt-get
I tried many phantomjs versions.
I tried this on my ubuntu 12.04.5 laptop and on a softlayer server running ubuntu 14.04.3 and got the same results.

Do you know the problem?

Note that when using fs.write("/dev/stdout", page.renderBase64(), "w"); I get the following output:

Unable to open file '/dev/stdout'

  phantomjs://platform/fs.js:79 in open
  phantomjs://platform/fs.js:136 in write
  phantomjs://code/recorder.js:13
@somprabhsharma
Copy link

somprabhsharma commented Jun 28, 2016

I am also facing similar issue.

when running below code with PhantomJs v1.9.15 It works fine and generate a file.
But when running this with v2.1.7 it outputs nothing.

var page = require('webpage').create();
var system = require('system');

page.paperSize = { format: "A4", orientation: "portrait" };

page.onLoadFinished   = function(status) {
    if (status === 'success') {
        setTimeout(function () {
            page.render(system.args[2], function (finished, err) {
                phantom.exit()
                return callback(null, status)
            })
            phantom.exit()
        }, 0)
    } else {
        phantom.exit()
    }
};

page.open(system.args[1], function () {
});

@jbg77
Copy link

jbg77 commented Aug 3, 2016

I have a similar issue, I want to render my pdf to stdout, to take it in a var

page.render('/dev/stdout', { format: 'pdf' });

var content;
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
        content = stdout;
        })
return content;

@gabrielAnzaldo
Copy link

did not work for me also, I am using windows 7, phantomjs-prebuilt 2.1.13 and node 6.9.1

@CMCDragonkai
Copy link

Does not work for me either, the --debug=true option shows it just freezes at:

2017-01-25T17:20:26 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-01-25T17:20:26 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-01-25T17:20:26 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))

This was my small code:

"use strict";


var page = require('webpage').create();
var fs = require('fs');

page.open("https://fifthestate.com/#/articles/588766177e85bd5b44fa24a7?s=", function (status) {

    console.log(status);


    // Check for page load success
    if (status !== "success") {

        console.log("Unable to access network");

    } else {

        console.log('ACCESSING!');
        setTimeout(
            function() {
                fs.write('C:\1.html', page.content, 'w');
                phantom.exit();
            },
            5000
        );

    }

});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants