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

scale issue to generate pdf #694

Open
mansihpancha opened this issue Apr 19, 2024 · 0 comments
Open

scale issue to generate pdf #694

mansihpancha opened this issue Apr 19, 2024 · 0 comments

Comments

@mansihpancha
Copy link

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
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

1 participant