-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer input #25
Comments
is this resolve ? i want also an input buffer. @Sparticuz |
what i want is, i will generate an HTML template to PDF using pdf-creator-node, then thaat result buffer i will transfer to node-qpdf2 library to set a password. is that possible ? |
This is what I use in my app, outside of this package. I will probably add it next time I allocate some time to this package. import { randomUUID } from "node:crypto";
import { writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Readable } from "node:stream";
/** Writes a Readable to a File in tmpdir() */
export const writeTemporaryFile = async (file: Readable): Promise<string> => {
const filePath = join(tmpdir(), `${randomUUID().replaceAll("-", "")}.pdf`);
await writeFile(filePath, file);
return filePath;
}; So I'll take my buffer or stream or whatever, and put it in this function which outputs a file path that I can use in |
is the tmpdir automatically deletes after execution ? @Sparticuz |
aint working for me. this is my code: generatePDF.js:
}; secure.js:
` temp.js: `
` When i open the file on s3 bucket, it contains nothing |
I've never used pdf-creator-node before. Does the file display properly before attempting to encrypt it? |
@Sparticuz yes it works when creating an output like this: const pdf = { await encrypt(pdf); when i open the pdf on tmp/secure.pdf, inputs a password then open the pdf then boom, i see my html template, it works fine when passing like code above. but what if i dont want to create "./tmp/secure.pdf", pass the pdfbuffer to s3 bucket, it aint working like the previous code above our conversations i mentioned:
|
I don't think qpdf supports that. I guess you could then read the file into a buffer then pass it to s3, but that seems redundant. Again, this Feature Request will probably just 'fake it' by just taking the buffer and throwing it into a file, then taking the file and throwing it in a buffer. EDIT: Actually, This is in my tests, it should work: test.serial("Should encrypt File -> Buffer", async (t) => {
const BufferFromFile = await encrypt({
input,
password: "1234",
});
t.true(Buffer.isBuffer(BufferFromFile));
}); |
Not work for me when i open the PDF file the content is missing. |
Hi! Thanks for your work! |
Found one interesting thing, if I save data to a file and then read it all works fine. But if I operate with the buffer that returns from |
According to qpdf/qpdf#54, we can't use stdin as input. Build a helper function that will take in a buffer as input and output it to /tmp before passing it to
qpdf
The text was updated successfully, but these errors were encountered: