Automattic/node-canvas

Missing async "canvas.toBuffer" for PDF canvases

Open

#821 aberto em 20 de out. de 2016

Ver no GitHub
 (2 comments) (1 reaction) (0 assignees)JavaScript (1.140 forks)batch import
BugHelp wanted

Métricas do repositório

Stars
 (9.524 stars)
Métricas de merge de PR
 (Mesclagem média 34d 18h) (2 fundiu PRs em 30d)

Description

I need a progress bar for user-feedback because the pdfs i want to produce are huge and i am missing a indication for the time it takes. 600m x 3000mm for example, which means i want to fill 1000 x 1800 = 1.800.000 rectangulars with fillRect.

The problems starts when i want to write the buffer to a file, because toBuffer takes the unpredictable time. My hope was the async usage to get a more reactive way to save the buffer to a file.

Issue

Callback function passed to toBuffer gets never called. Typos dont throw an error no console log.

Steps to Reproduce

var Canvas = require('canvas');
let canvas = new Canvas(600, 600, 'pdf');
let ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(0,0,0)';
// this runs in a for loop over 2 dim array with up to 2 milllion entries  
ctx.fillRect(0,0,50,50);
console.log('start buffer');
canvas.toBuffer((err,buf) => {
  // this never runs
  console.log('foobar');
});
console.log('end buffer');

Your Environment

  • Version of node-canvas (^ 1.5.0): 1.6.0 should be installed
  • Environment: node v6.5.0 on Mac OS X 10.11.6

Guia do colaborador