Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get the value of the "Title" variable
- var title = GetPlayer().GetVar("Title");
- // Get the value of the "Editor" variable
- var editor = GetPlayer().GetVar("Editor");
- // Create a new jsPDF object
- var pdf = new jsPDF();
- // Set the document name to the value of the "Title" variable
- pdf.setProperties({
- title: title
- });
- // Calculate the width and height of the page
- var pageWidth = pdf.internal.pageSize.getWidth();
- var pageHeight = pdf.internal.pageSize.getHeight();
- // Split the editor text into lines based on the width of the page
- var lines = pdf.splitTextToSize(editor, pageWidth - 20);
- // Calculate the height of the lines
- var lineHeight = pdf.getTextDimensions(lines[0]).h;
- // Set the initial y position to 10
- var y = 10;
- // Loop through the lines
- for (var i = 0; i < lines.length; i++) {
- // If the line would exceed the height of the page, add a new page
- if (y + lineHeight > pageHeight - 10) {
- pdf.addPage();
- y = 10;
- }
- // Insert the line into the document
- pdf.text(lines[i], 10, y);
- // Update the y position
- y += lineHeight;
- }
- // Save the PDF document
- pdf.save(title + ".pdf");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement