nextjs-pdf
v0.2.0
Published
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
Downloads
85
Readme
This is a Next.js project bootstrapped with create-next-app
.
Getting Started
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.js
. The page auto-updates as you edit the file.
This project uses next/font
to automatically optimize and load Inter, a custom Google Font.
Learn More
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
Deploy on Vercel
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
nextjs-pdf
Create Nextjs PDF with ease
SAMPLE
"use client"
import React from 'react'; import jsPDF from 'jspdf'; import 'jspdf-autotable'; import Image from 'next/image'; import styles from './page.module.css';
export default function Home() { function demo() { var obj = new jsPDF('landscape');
// Add title heading
obj.setFontSize(18);
obj.text('Sample Table Report', 20, 20);
// Create the table
obj.setFontSize(12);
obj.autoTable({
startX: 30,
startY: 40, // Adjust startY to make space for the title
head: [['Name', 'City', 'Phone No.']],
body: [
['Bambo', 'World', '07066279211'],
['Rachel', 'Los Angeles', '7845521'],
['Harvey', 'Chicago', '9865371'],
],
});
obj.save('example.pdf');
}
return (
<div>
<div className={styles.buttonContainer}>
<button className={styles.customButton} onClick={demo}>
Download PDF
</button>
</div>
</div>
);
}
YOU CAN STYLE YOUR PDF AS SEEN BELOW
obj.autoTable({ startX: 20, startY: 30, head: [['Name', 'City', 'Phone No.']],
body: [ ['Donna', 'New York', '8456210'], ['Rachel', 'Los Angeles', '7845521'], ['Harvey', 'Chicago', '9865371'], ], theme: 'striped', // Apply a striped theme headStyles: { fillColor: [100, 100, 255], // Set header cell background color textColor: 255, // Set header text color }, bodyStyles: { textColor: [0, 0, 0], // Set body text color }, columnStyles: { 0: { fontStyle: 'bold' }, // Apply bold style to the first column }, margin: { top: 60 }, didDrawPage: function (data) { obj.text('Generated by jsPDF AutoTable', data.settings.margin.left, 10); }, });