You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
save modified PDF to specific destination file path without copy of whole PDF buffer
How could this be implemented?
add saveOnFilePath: string variant to SaveOptions interface
and returns Promise<Uint8Array> | Promise<string>
or separate two methods (ex. PDFDocument.save(), PDFDocument.saveToDestFile(filePath:string))
What problem are you trying to solve?
Usage Environment of this Library: AWS Lambda (memorySize: 1024MB)
Problem Scenario
The input PDF is approximately 1024MB.
A modification is applied to the input PDF (e.g., adding text with drawText).
When using PDFDocument.save() to save the modified PDF (which is the input), I encounter an issue.
When I call PDFDocument.save(), an error occurs due to insufficient memory in AWS Lambda, causing the execution to fail. After investigating the issue, I discovered the cause.
PDFDocument.save() ultimately calls PDFWriter.serializeToBuffer(), which copies the entire original PDF buffer.
Whenever the input PDF size exceeds half of the AWS Lambda memory size (1024MB), a memory shortage exception occurs.
To resolve this, I had to increase the memory size to more than 1GB, which incurs additional costs.
Why does this matter to you?
with this problem, i have to pay more infrastructure cost which is critical of business
Would others find this helpful?
Most users who use serverless environment (AWS LAMBDA)
Are you interested in implementing your proposal?
Yes
Why are you submitting a proposal?
Suggestion
I propose adding a function that accepts a file path, rather than copying the modified buffer. This function would return the file path of the saved PDF file.
This solution would alleviate memory constraints in environments like AWS Lambda and help reduce infrastructure costs while maintaining the same functionality.
Additional Notes
No response
The text was updated successfully, but these errors were encountered:
Describe your idea
save modified PDF to specific destination file path without copy of whole PDF buffer
How could this be implemented?
add
saveOnFilePath: string
variant toSaveOptions
interfaceand returns
Promise<Uint8Array> | Promise<string>
or separate two methods (ex.
PDFDocument.save()
,PDFDocument.saveToDestFile(filePath:string)
)What problem are you trying to solve?
Usage Environment of this Library: AWS Lambda (memorySize: 1024MB)
Problem Scenario
drawText
).PDFDocument.save()
to save the modified PDF (which is the input), I encounter an issue.When I call
PDFDocument.save()
, an error occurs due to insufficient memory in AWS Lambda, causing the execution to fail. After investigating the issue, I discovered the cause.PDFDocument.save()
ultimately callsPDFWriter.serializeToBuffer()
, which copies the entire original PDF buffer.Whenever the input PDF size exceeds half of the AWS Lambda memory size (1024MB), a memory shortage exception occurs.
To resolve this, I had to increase the memory size to more than 1GB, which incurs additional costs.
Why does this matter to you?
with this problem, i have to pay more infrastructure cost which is critical of business
Would others find this helpful?
Most users who use serverless environment (AWS LAMBDA)
Are you interested in implementing your proposal?
Yes
Why are you submitting a proposal?
Suggestion
I propose adding a function that accepts a file path, rather than copying the modified buffer. This function would return the file path of the saved PDF file.
This solution would alleviate memory constraints in environments like AWS Lambda and help reduce infrastructure costs while maintaining the same functionality.
Additional Notes
No response
The text was updated successfully, but these errors were encountered: