-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
2 changed files
with
35 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,32 @@ | ||
import {Onedoc} from "../src/client"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import process from "process"; | ||
|
||
const ONEDOC_API_KEY = process.env.ONEDOC; | ||
(async () => { | ||
|
||
const onedoc = new Onedoc(ONEDOC_API_KEY); | ||
|
||
let doc = { | ||
html: "<h1>Hello World</h1>", | ||
title: "Hello", | ||
test: true, // if true, produce a PDF in test mode with a Onedoc's watermark | ||
save: false, // if true, host the document and provide a download link in the console and your Onedoc's dashboard | ||
expiresIn: 30, // the number of day you want to host your document | ||
assets: [ | ||
{ | ||
path: "./stylesheet.css", | ||
content: fs.readFileSync(path.join(process.cwd(), "/test/stylesheet.css")).toString(), | ||
}, | ||
], | ||
}; | ||
|
||
const { file, link, error, info } = await onedoc.render(doc); | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
|
||
fs.writeFileSync("./Test.pdf", Buffer.from(file)); | ||
})(); |
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 @@ | ||
body{ | ||
background-color: red; | ||
} |