Skip to content

Commit 0055256

Browse files
author
Andrey
committed
Added a new generate endpoint
1 parent ad293ac commit 0055256

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

files/document.docx.pdf

65 Bytes
Binary file not shown.

files/new.pdf

1.63 KB
Binary file not shown.

index.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,28 @@ app.get('/convert/:filename', (req, res) => {
113113
await pdfdoc.initSecurityHandler();
114114
await PDFNet.Convert.toPdf(pdfdoc, inputPath);
115115
pdfdoc.save(
116-
`${pathname}${filename}.pdf`,
116+
outputPath,
117+
PDFNet.SDFDoc.SaveOptions.e_linearized,
118+
);
119+
};
120+
121+
PDFNetEndpoint(main, outputPath, res);
122+
});
123+
124+
app.get('/generate/:filename', (req, res) => {
125+
const filename = req.params.filename;
126+
console.log(filename);
127+
const outputPath = path.resolve(__dirname, filesPath, `${filename}.pdf`);
128+
console.log(outputPath);
129+
const main = async () => {
130+
const pdfdoc = await PDFNet.PDFDoc.create();
131+
await pdfdoc.initSecurityHandler();
132+
const page1 = await pdfdoc.pageCreate();
133+
pdfdoc.pagePushBack(page1);
134+
pdfdoc.save(
135+
outputPath,
117136
PDFNet.SDFDoc.SaveOptions.e_linearized,
118137
);
119-
ext = '.pdf';
120138
};
121139

122140
PDFNetEndpoint(main, outputPath, res);

0 commit comments

Comments
 (0)