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

addPage not defined #1520

Closed
ikit opened this issue Jan 29, 2020 · 3 comments
Closed

addPage not defined #1520

ikit opened this issue Jan 29, 2020 · 3 comments

Comments

@ikit
Copy link

ikit commented Jan 29, 2020

Hi, I'm stuck with a weird error...
I don't understand, because the addPage() seems to be a well documented method...

Issue or Feature

Do not compile due to the following error:

Property 'addPage' does not exists on type 'NodeCanvasRenderingContext2D'.

Note that I try to put the addPage() on the canvas object, then the project compile, but at the runtime, I got the following error:

canvas.addPage is not a function

Steps to Reproduce

import { createCanvas } from "canvas";

const canvas = createCanvas(200, 200, "pdf");
const ctx = canvas.getContext('2d');

for (let i=0; i<4; i++) {
    ctx.fillText("test " + i, 5, 40*i);
    ctx.addPage();
}

Your Environment

  • canvas 2.6.1 installed from npm
  • node 12 on Windows 10
  • typscript project
@zbjornson
Copy link
Collaborator

Hrm, I can't reproduce that.

> const {createCanvas} = require("canvas")
> const canvas = createCanvas(200, 200, "pdf");
> const ctx = canvas.getContext("2d")
> ctx.addPage()
> ctx.addPage
[Function: addPage]

Since you're using Typescript, note that #1509 corrected an error in the typings: addPage was declared on the canvas instance instead of the context.

Can you inspect the properties of your ctx instance?

@ikit
Copy link
Author

ikit commented Jan 31, 2020

ok thanks, it's the same problem that the #1509

@ikit ikit closed this as completed Jan 31, 2020
@clayplumridge
Copy link

Just ran into this myself; is there another anticipated release coming any time soon?

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

No branches or pull requests

3 participants