HTML2PDF has blurry pdf output
Asked Answered
C

3

12

I need some help, why is it that the resolution of my html2pdf is blurry? How can I adjust the resolution?.

Colo answered 9/7, 2015 at 6:2 Comment(5)
Which programming language are you using?Inevasible
@VinodKumar php sir.Colo
Oh OK. Please call me Vinod. I believe you are losing quality only on images and not text (since they are vector based already), refer this link html2pdf.solutions/en/Support/Parameters_for_html2pdf.htm You have an option to set the quality of the image. Let me know if it helpsInevasible
@VinodKumar sir Vinod, my problem is the text sir, the pdf has no image .Colo
can you show the code ??Empennage
S
3

There are some parameters like ImageQuality and DisablePdfCompression you have to pass which is defining the image quality, pdf compression and pdf size. Here is some details of it.

ImageQuality

Integer: Values from 1 to 100 resp. 101. Default is 101 (lossless compression) Can be used to decrease PDF files size. The smaller the value the smaller the PDF file size. A reasonable value is 75.

DisablePdfCompression

Integer: 0 (Standard), 1 do not use lossless compression on pdf objects

For more details : http://www.html2pdf.solutions/en/Support/Parameters_for_html2pdf.htm

Sunrise answered 25/12, 2018 at 7:5 Comment(0)
B
11

It's work for me!

var opt = {
      margin: [15, 0, 15, 0],
      filename: `CV-${name}.pdf`,
      image: { type: 'jpeg', quality: 1 },
      html2canvas: {
        dpi: 192,
        scale:4,
        letterRendering: true,
        useCORS: true
      },
      jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
    };
Banting answered 22/7, 2020 at 4:13 Comment(0)
S
10

This is an example in js if someone use this lib

https://github.com/eKoopmans/html2pdf#image-type-and-quality

You can pass an option html2pdf(content, option)

Try this, html2pdf(document.body, {html2canvas: { scale: 4 }})

I guess in php, it should be similar.

Sebiferous answered 25/12, 2018 at 6:30 Comment(0)
S
3

There are some parameters like ImageQuality and DisablePdfCompression you have to pass which is defining the image quality, pdf compression and pdf size. Here is some details of it.

ImageQuality

Integer: Values from 1 to 100 resp. 101. Default is 101 (lossless compression) Can be used to decrease PDF files size. The smaller the value the smaller the PDF file size. A reasonable value is 75.

DisablePdfCompression

Integer: 0 (Standard), 1 do not use lossless compression on pdf objects

For more details : http://www.html2pdf.solutions/en/Support/Parameters_for_html2pdf.htm

Sunrise answered 25/12, 2018 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.