Canvas position using printjs

290 views Asked by At

I'm using printjs to convert my html page to pdf, all works fine except my canvas, which you can see here:

enter image description here

and here is the code:

printJS({
    printable: 'page1',
    type: 'html',
    scanStyles: false,
    ignoreElements: ['btnPrint'],
    css: [
        'vendor/fontawesome-free/css/all.min.css',
        'css/sb-admin-2.min.css',
        'css/custom.css'
    ]
});

canvas height: 320px and width: 562px

How can I fix this?

2

There are 2 answers

0
skchawala On

try to increase canvas height. and Also adjust the center of this shape properly. looks like coordinates (x,y) are going out of bound.

0
Kenyuki On

I tried to increase the canvas height with canvas {height: 320;} (i have only 1 canvas so it should be ok) with 320, 200, 300, even 1000 nothing changes this is my code

printJS(
{printable:'page1', 
type:'html', 
scanStyles: false, 
ignoreElements:['btnPrint'], 
css: ['vendor/fontawesome-free/css/all.min.css', 'css/sb-admin-2.min.css', 'css/nowa.css'], 
style: ['@page { size: A4; margin: 0mm;} body {margin: 0;} canvas {height: 1000;}'], targetStyles: ['*']});

the @page and body works fine but even if i try to set background-color to red nothing changes.

I can center it by changing left: but cant use smt like text-align: center it doesn't work also. I'am not really good at css so maybe it is not how to center a canvas i don't know.