Advertisement
nrzmalik

Storyline Notepad PDF Download

Aug 30th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.70 KB | Source Code | 0 0
  1. var player = GetPlayer();
  2.  
  3. // Get the value of the "Title" variable
  4. var title = player.GetVar("Title");
  5.  
  6. // Get the value of the "Editor" variable
  7. var editor = player.GetVar("Editor");
  8.  
  9. // Create a new jsPDF object
  10. var pdf = new jsPDF();
  11.  
  12. // Set the document name to the value of the "Title" variable
  13. pdf.setProperties({
  14.   title: title,
  15. });
  16.  
  17. // Calculate the width and height of the page
  18. var pageWidth = pdf.internal.pageSize.getWidth();
  19. var pageHeight = pdf.internal.pageSize.getHeight();
  20.  
  21. // Set title font properties
  22. pdf.setFont('Roboto', 'bold');
  23. pdf.setFontSize(30);
  24.  
  25. // Calculate the height of the title text
  26. var titleHeight = pdf.getTextDimensions(title).h;
  27.  
  28. // Set the initial y position for the title
  29. var titleY = 20;
  30.  
  31. // Write the title
  32. pdf.text(title, pageWidth / 2, titleY, 'center');
  33.  
  34. // Set description font properties
  35. pdf.setFont('Roboto', 'normal');
  36. pdf.setFontSize(16);
  37.  
  38. // Calculate the available space for description
  39. var availableSpace = pageHeight - titleY - titleHeight - 20; // Adjust for margins
  40.  
  41. // Split the editor text into lines based on the available space
  42. var lines = pdf.splitTextToSize(editor, pageWidth - 20);
  43.  
  44. // Set the initial y position for the description
  45. var descriptionY = titleY + titleHeight + 10;
  46.  
  47. // Loop through the lines
  48. for (var i = 0; i < lines.length; i++) {
  49.   // If the line would exceed the height of the page, add a new page
  50.   if (descriptionY + 10 > pageHeight) {
  51.     pdf.addPage();
  52.     descriptionY = 10;
  53.   }
  54.  
  55.   // Insert the line into the document
  56.   pdf.text(lines[i], 10, descriptionY);
  57.  
  58.   // Update the y position
  59.   descriptionY += 10; // Adjust for line spacing
  60. }
  61.  
  62. // Save the PDF document
  63. pdf.save(title + ".pdf");
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement