This creates a text based pdf.
Include in your header
<script type="text/javascript" src="/wp-content/themes/hello-theme-child-master/odac-libaries/canvasjs/canvasjs.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script> <!--Include for export to pdf-->
Export button
<button id="exportButton" type="button">Export as PDF</button>
Javascript code to do the export when the button is clicked
<script type="text/javascript">
jQuery("#exportButton").click(function()
{
//Create new PDF object
var doc = new jsPDF("p", "mm", "a4"); //"p"=Portrait orientation, "mm"=Units in mm, "a4"=A4 format
var CoordY;
var PageIndex;
var RowIndex;
for (PageIndex = 0; PageIndex < 3; PageIndex++)
{
//----- NEXT PAGE -----
if (PageIndex > 0)
doc.addPage("a4", "p"); //"a4"=A4 format, "p"=Portrait orientation
//Do Header
doc.setFontSize(14); //Set in points
doc.text('My Page Heading', 100, 10, 'center'); //<<<Alignment can be added as 'center' or 'right'
//Do page content
doc.setFontSize(8); //Set in points
CoordY = 20; //This is in mm, not points
for (RowIndex = 0; RowIndex < 30; RowIndex++)
{
doc.text('Item ' + RowIndex, 15, CoordY);
doc.text('Item B', 80, CoordY);
doc.text('Item C', 160, CoordY);
CoordY += 7; //This is in mm, not points
}
}
doc.save("Exported Document.pdf");
});
</script>
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.