AnyChart/AnyChart-NodeJS

pdf size parameters

deurloo opened this issue · 4 comments

I am trying to figure out how I can provide parameters for exportTo to pdf to set the page size (e.g. A4) and/or how to create multiple pages. Any suggestions?

@deurloo
Thank you for this question! We need to look into it and soon we will provide you with an answer.

Any update on this. I am generating pdf but just because few charts are going out of the context of single page and they are hidden now. How can I generate multi page pdf.
`exports.createPDFReport = function (completeData) {
var JSDOM = require('jsdom').JSDOM;
var jsdom = new JSDOM('

', {runScripts: 'dangerously'});
var window = jsdom.window;

var anychart = require('anychart')(window);
var anychartExport = require('anychart-nodejs')(anychart);
var stage = anychart.graphics.create("container");

// Table Layout sample
var layoutTable = anychart.standalones.table(3, 3);
layoutTable.cellBorder(null);
layoutTable.getCol(0).width('15%');
layoutTable.getCol(1).width('85%');
layoutTable.getCell(0, 0).content("101").vAlign('center').fontFamily('Tahoma').fontSize(22).fontStyle('bold').fontColor('#EE7001');
layoutTable.getCell(0, 1).content("Employee Name").hAlign('left').vAlign('center').fontFamily('Tahoma').fontSize(22).fontStyle('bold').fontColor('#3498DB');

/* ---------------Sample Document------------------------*/

// Funnel Chart Sample
var chartFunnel = anychart.funnel();
chartFunnel.title('Funnel Chart');
chartFunnel.data(completeData.funnelChart);

// Heat Map Chart Sample
var chartHeatMap = anychart.heatMap(completeData.heatMap);
chartHeatMap.title('Heat Map Chart');

// Line Chart Sample
var chartLine = anychart.line();
var seriesLine = chartLine.line(completeData.lineChart);
chartLine.title('Line Chart');

// Line Histogram Chart Sample
var chartLineHistogram = anychart.column();
var series = chartLineHistogram.column(completeData.lineHistogram);
chartLineHistogram.title('Line Histogram Chart');

// Tag Cloud Chart Sample
var chartTagCloud = anychart.tagCloud();
chartTagCloud.title('Tag Cloud Chart');
chartTagCloud.data(completeData.tagCloudChart);

// Table Chart Sample
var chartTable = anychart.standalones.table();
chartTable.contents(completeData.tableChart);
chartTable.getRow(0).height(40).fontWeight(900);
chartTable.getCol(0).width(70).fontWeight(900);
chartTable.cellFill("#E1E1E1");
chartTable.cellBorder("#B8B8B8").vAlign("middle").hAlign("center");


/* ---------------End of Sample Document------------------------*/

// Set position and size of all charts		
//layoutTable.bounds(20, 20, 400, 60);
chartFunnel.bounds(20, 100, 450, 300);
chartHeatMap.bounds(540, 100, 450, 300);
chartLine.bounds(20, 450, 450, 320);
chartLineHistogram.bounds(540, 450, 450, 320);
//chartTagCloud.bounds(20, 800, 450, 300);
//chartTable.bounds(540, 800, 450, 300);


// Set container to all charts
//layoutTable.container(stage);
chartFunnel.container(stage);
chartHeatMap.container(stage);
chartLine.container(stage);
chartLineHistogram.container(stage);
//chartTagCloud.container(stage);
//chartTable.container(stage);


// Draw all chart
//layoutTable.draw();
chartFunnel.draw();
chartHeatMap.draw();
chartLine.draw();
chartLineHistogram.draw();
//chartTagCloud.draw();
//chartTable.draw();

anychartExport.exportTo(stage, 'pdf').then(function(image) {
    saveToFolder('finalReport.pdf', image);
}, function(generationError) {
    console.log(generationError);
});

}

function saveToFolder(folder, image) {
var fs = require('fs');
fs.writeFile(folder, image, function(fsWriteError) {
if (fsWriteError) {
console.log(fsWriteError);
} else {
console.log('Complete');
}
});
}

function saveToS3(bucket, key, image) {
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var params = {
Bucket : bucket,
Key : key,
Body : image,
ACL: 'public-read'
}
s3.putObject(params, function(err, image) {
if (err) console.log(err, err.stack);
else console.log(image);
});
}
`

Finally when I am creating the PDF only few charts which are fit in first page are coming in single page. How can I control it and can make it of multi page.

@chdharm
Unfortunately, the current version of the module doesn't support multipage printing of charts. We will take it into account, but we can't provide any ETA at this moment.