jspdf change dpi to 300 in javascript

You can set the DPI (Dots Per Inch) in jspdf by setting the density property of the PDF object.

Here's an example code:

index.tsx
// Create PDF object
var doc = new jsPDF({
    orientation: "portrait",
    unit: "pt",
    format: "letter",
    compress: true
});

// Set Density
doc.setDensity(300);

// Add content to PDF
doc.text("Hello World!", 20, 20);

// Save the PDF
doc.save("example.pdf");
269 chars
17 lines

In the above example, doc.setDensity(300) sets the DPI to 300. You can adjust the value to any DPI you want.

Note that the PDF file size will increase with higher DPI.

related categories

gistlibby LogSnag