jsPDF AddPage() Method Example to Add Different Page Sizes & Orientations in PDF Document Using Javascript Full Project For Beginners

 

 

addPage(format, orientation) → {jsPDF}

Source:

Adds (and transfers the focus to) new page to the PDF document.

Parameters:
Name Type Description
format String/Array The format of the new page. Can be:

  • a0 – a10
  • b0 – b10
  • c0 – c10
  • dl
  • letter
  • government-letter
  • legal
  • junior-legal
  • ledger
  • tabloid
  • credit-card

Default is “a4”. If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89] 

orientation string Orientation of the new page. Possible values are “portrait” or “landscape” (or shortcuts “p” (Default), “l”).

 

 

 

Example

 

 

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.4.1/jspdf.debug.js"></script>
<script>
	var doc = new jsPDF()

	doc.addPage("credit-card","portrait")

	doc.addPage("government-letter","landscape")

	doc.addPage("letter","landscape")

	doc.addPage("tabloid","portrait")


	doc.save("output.pdf")
</script>
</html>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

See also  Build a Electron.js Music or Audio File 3D Visualizer or Analyzer Using Three.js Library in HTML5 & Javascript GUI Desktop App Full Project For Beginners

Leave a Reply