-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 13a2873
Showing
19 changed files
with
587 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# dependencies | ||
node_modules | ||
|
||
# logs | ||
npm-debug.log | ||
|
||
# yarn & npm | ||
yarn.lock | ||
package-lock.json | ||
|
||
# Nuxt build | ||
.nuxt | ||
|
||
# Nuxt generate | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.nuxt/ | ||
coverage/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Nuxt PDF | ||
|
||
[![npm](https://img.shields.io/npm/dt/nuxt-pdfsvg?style=flat-square)](https://npmjs.com/package/nuxt-pdf) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-pdf/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-pdf) | ||
[![License](https://img.shields.io/npm/l/nuxt-pdf?style=flat-square)](http://standardjs.com) | ||
|
||
> Generate PDF files directly from your content on your website, can be used for offline downloadable documentation pages. | ||
## Features | ||
|
||
- Create PDF from Vue template | ||
- Automatic PDF Generation | ||
- Customizable Metadata | ||
- Supports (A1, A2, A3, A4, A5) | ||
- Support dynamic routes (Nuxt Generate) | ||
- For **NUXT 2.x** and higher | ||
|
||
## Table of Contents | ||
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Configuration](#configuration) | ||
- [Development](#development) | ||
- [License](#license) | ||
|
||
## Installation | ||
|
||
```shell | ||
npm install nuxt-pdf | ||
``` | ||
|
||
or | ||
|
||
```shell | ||
yarn add nuxt-pdf | ||
``` | ||
|
||
## Usage | ||
|
||
- Add `nuxt-pdf` to the `modules` section of your `nuxt.config.js` file: | ||
|
||
```js | ||
modules: ["nuxt-pdf"]; | ||
``` | ||
|
||
- Add a custom configuration with the `pdf` property. | ||
|
||
You can see the available options in the example [configuration](#configuration) | ||
|
||
```js | ||
// nuxt.config.js | ||
|
||
{ | ||
modules: [ | ||
'nuxt-pdf' | ||
], | ||
pdf: { | ||
// custom configuration | ||
} | ||
} | ||
``` | ||
|
||
## Configuration | ||
|
||
```javascript | ||
// nuxt.config.js | ||
|
||
{ | ||
pdf: { | ||
/* | ||
* Output folder for generated pdf. | ||
*/ | ||
dir: "dist", | ||
|
||
/* | ||
* Function options for page.pdf([options]) | ||
* Read more: https://pptr.dev/#?product=Puppeteer&version=v2.0.0&show=api-pagepdfoptions | ||
*/ | ||
pdf: { | ||
// Change the format of the pdfs. | ||
format: "A4", | ||
|
||
printBackground: true // Include background in pdf. | ||
}, | ||
|
||
/* | ||
* PDF Meta configuration. (inspired by vue-meta) | ||
*/ | ||
meta: { | ||
title: "Default PDF title", | ||
titleTemplate: "Example ─ %s", | ||
|
||
author: "Christian Hansen", | ||
subject: "Example", | ||
|
||
producer: "Example Inc.", | ||
|
||
// Control the date the file is created. | ||
creationDate: new Date(), | ||
|
||
keywords: ["pdf", "nuxt"] | ||
}, | ||
|
||
/* | ||
* PDF generation routes. (expanding nuxt.generate) | ||
*/ | ||
routes: [ | ||
{ | ||
// PDF Filename | ||
filename: "super-awesome-pdf.pdf", | ||
|
||
// Output directory for pdf. | ||
// Combined with 'dir' value in options. (default 'dist') | ||
directory: "downloads/", | ||
|
||
// Route to content that should be converted into pdf. | ||
route: "/", | ||
|
||
// Override global meta with individual meta for each pdf. | ||
meta: { | ||
title: "Super Awesome PDF" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## Development | ||
|
||
```bash | ||
$ git clone https://github.com/ch99q/nuxt-pdf.git | ||
|
||
$ cd nuxt-pdf | ||
|
||
$ yarn | ||
``` | ||
|
||
## License | ||
|
||
[MIT License](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@page { | ||
format: A1; | ||
size: 594mm 841mm; | ||
margin: 0mm 0mm; | ||
} | ||
|
||
@media print { | ||
.page { | ||
width: 594mm !important; | ||
height: 840.75mm !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@page { | ||
format: A2; | ||
size: 420mm 594mm; | ||
margin: 0mm 0mm; | ||
} | ||
|
||
@media print { | ||
.page { | ||
width: 420mm !important; | ||
height: 594mm !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@page { | ||
format: A3; | ||
size: 297mm 420mm; | ||
margin: 0mm 0mm; | ||
} | ||
|
||
@media print { | ||
.page { | ||
width: 297mm !important; | ||
height: 420mm !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@page { | ||
format: A4; | ||
size: 210mm 297mm; | ||
margin: 0mm 0mm; | ||
} | ||
|
||
@media print { | ||
.page { | ||
width: 210mm !important; | ||
height: 296.75mm !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@page { | ||
format: A5; | ||
size: 148mm 210mm; | ||
margin: 0mm 0mm; | ||
} | ||
|
||
@media print { | ||
.page { | ||
width: 148mm !important; | ||
height: 209.75mm !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@media print { | ||
html, | ||
body { | ||
margin: 0 !important; | ||
padding: 0 !important; | ||
visibility: hidden; | ||
} | ||
|
||
.page { | ||
position: relative; | ||
overflow: hidden; | ||
|
||
visibility: visible; | ||
|
||
padding: 0 !important; | ||
margin: 0 !important; | ||
|
||
page-break-after: auto; | ||
page-break-inside: avoid !important; | ||
|
||
border: none !important; | ||
border-radius: 0 !important; | ||
box-shadow: none !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
dir: 'dist', | ||
pdf: { | ||
format: 'A4' | ||
}, | ||
meta: { | ||
title: '', | ||
titleTemplate: '%s', | ||
subject: '', | ||
author: '', | ||
producer: '', | ||
keywords: [] | ||
}, | ||
routes: [] | ||
} |
Oops, something went wrong.