html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

Texts shift down only in Vuejs.

Open killernova opened this issue 1 year ago • 3 comments

Unlike other issues about texts shift down, it worked very well if I copy the code to the Chrome console, but if use those code in vue, the texts shifted down some distance. Using methods from others doesn't work, those methods include: setting line-height; set image as inline-block;

codes:

const element = document.getElementById("print-area");
const opt = { html2canvas: { width: 540 }, jsPDF: {format: 'a4'}};
html2pdf().set(opt).from(element).save();

html2pdf version: 0.9.3 vuejs version: 3.4.29 tailwindcss version: 3.4.10 platform: macos browser: chrome

SCR-20240822-kdyk

killernova avatar Aug 22 '24 03:08 killernova

I found the solution: The reason is that Tailwindcss set img height to auto, so just overwrite this attribute to unset;

img {
    height: unset;
}

killernova avatar Aug 22 '24 05:08 killernova

i solved it using:

img {
    display: inline-block !important;
}

patrick-psandre avatar Nov 05 '24 19:11 patrick-psandre

Thanks for your solution! it worked.

sinhkej avatar Jul 22 '25 06:07 sinhkej