-
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.
Merge pull request #10 from OnedocLabs/ffo-80-update-legacy-node-sdk-…
…with-new-api Updates js client to use fileforge api for generation
- Loading branch information
Showing
6 changed files
with
134 additions
and
175 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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)); | ||
})(); |
Oops, something went wrong.