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
const axios = require('axios'); | |
async function renderPdfWithDoppio() { | |
try { | |
const sourceHtml = "<h1>Hello Doppio</h1>" | |
const htmlAsBase64 = new Buffer.from(sourceHtml, 'utf8').toString('base64') | |
const options = { | |
method: 'POST', | |
url: 'https://api.doppio.sh/v1/render/pdf/direct', |
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
const fetch = import('node-fetch'); | |
const myHeaders = { | |
"Authorization": "Bearer xxxxxxxxxxxxxxx", | |
"Content-Type": "application/json" | |
}; | |
const raw = JSON.stringify({ | |
"page": { | |
"goto": { |
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
async generatePdf(link: string, token: string): Promise<string> { | |
const doppioApiUrl = this.configService.get<string>('DOPPIO_API_URL'); | |
const doppioApiKey = this.configService.get<string>('DOPPIO_API_KEY'); | |
const data = { | |
page: { | |
pdf: { | |
printBackground: true, | |
}, | |
goto: { |
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
const { getSignedUrl } = require('@aws-sdk/s3-request-presigner'); | |
const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3'); | |
const connectedClient = new S3Client({ | |
credentials: { | |
accessKeyId: process.env.S3_ACCESS_KEY_ID, | |
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY, | |
}, | |
endpoint: `https://${process.env.S3_ENDPOINT}`, | |
region: 'eu-east-1', |