Skip to content

scale issue to generate pdf #694

Open
@manish-tech-dev

Description

@manish-tech-dev

Hello Team,

Hope you all are doing well
i am facing an issue regarding scale in the pdf generation actually i am generation 27-28 pages pdf from (html+css+js) but when i used scale:2 then the pdf is not generate else if i am using scale:1.9 then pdf is generate but with weird styling means it not take my orignal styling

this is my configration

function exportToPDF(callback) {
$('#spinner_loader_main').fadeIn();
var company_name = '';
var element = document.getElementById('sections_container_for_pdf_generate');
var opt = {
margin: [0.3125, 0.3125, 0.875, 0.3125],
mode: ['legacy'],
filename: 'Audit-Report.pdf',
pagebreak: {
mode: 'css',
after: '.section_wise_div'
},
image: {
type: 'jpeg',
quality: 0.98
},
html2canvas: {
scale: 2,
dpi: 96
},
jsPDF: {
unit: 'in',
format: [7.5, 12], //'a4',
orientation: 'landscape'
}
};
html2pdf().from(element).set(opt).toPdf().get('pdf').then(function(pdf) {
var totalPages = pdf.internal.getNumberOfPages();
for (var i = 1; i <= totalPages; i++) {
pdf.setPage(i);
pdf.setFontSize(14);
pdf.setTextColor(237, 243, 249);
pdf.addImage("http://localhost/glocoach_dev/new_glocoach/images/analytical_report_images/analytical_report_footer_bar.png", "PNG", 0, pdf.internal.pageSize.getHeight() - 0.49, 12.2, 0);
pdf.text(pdf.internal.pageSize.getWidth() - 11.2, pdf.internal.pageSize.getHeight() - 0.15, "Prepared for " + company_name + ". Copyright 2024 GloCoach. All rights reserved.");
pdf.text(pdf.internal.pageSize.getWidth() - 2.5, pdf.internal.pageSize.getHeight() - 0.15, "www.glocoach.com");
}
// if (callback && typeof callback === 'function') {
// callback(); // Call the callback function to indicate completion
// }
}).save().then(function() {
console.log("Successfully Downloaded!");
$('#spinner_loader_main').fadeOut();
if (callback && typeof callback === 'function') {
callback(); // Call the callback function to indicate completion
}
}).catch(function(error) {
alert("Something went wrong. Please try again!");
$('#spinner_loader_main').fadeOut();
if (callback && typeof callback === 'function') {
callback(); // Call the callback function to indicate completion
}
});
}

        Do you all have any idea regarding this like how we can fix it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions