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

Background image looks blurry #664

Open
Lollichkeit opened this issue Aug 28, 2023 · 1 comment
Open

Background image looks blurry #664

Lollichkeit opened this issue Aug 28, 2023 · 1 comment

Comments

@Lollichkeit
Copy link

Lollichkeit commented Aug 28, 2023

This is my code and I don't know why the background image looks blurry:

var element = document.getElementById('elementID');
var e = element.cloneNode(true)
e.classList.add("pdf");
var opt = {
  margin:       0.25,
  filename:     'test.pdf',
  image:        { type: 'jpg', quality: 1},
  html2canvas:  {
      dpi: 600,
      scale:4,
      letterRendering: true,
      useCORS: true,
      width: 630, height: 891
  },
  jsPDF: { unit: 'mm', format: 'A4', orientation: 'p' }
};

html2pdf().set(opt).from(e).save();

I have several items with background images:

<div style="background-image: url('...')"></div>

@insaurabh
Copy link

Same for me

function generatePDF(data) {
    const { current_user, content, name } = data;
    const opt = {
        filename: `${name.toLowerCase().split(' ').join('-')}.pdf`,
        image: { type: 'jpeg', quality: 1 },
        html2canvas: {
            scale: 2,
            useCORS: true // required for assets coming from URL
        },
        jsPDF: {
            unit: 'mm',
            // format: 'letter',
            format: [216, 279],
            // hotfixes: ['px_scaling'],
            orientation: 'p'
        }
    };

    html2pdf().from(content).set(opt).save();
}

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

2 participants