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
I'm trying to merge multiple pdf-documents to a single pdf document and display it in the browser in pdf-viewer and send it to the S3 to store the merge result
I'm using pdf-lib to do the operations and react-pdf to display the documents in the broweser
Why were you trying to do this?
I'm building a web application that has a feature of pdf-viewer and that include merging pdf's appending images - scaling-rotating-etc
How did you attempt to do it?
Here attached the code that I use to merge documents
That didn't include bookmarks with the final document, so I tried to implement it following an issue/discussion on pdf-lib repo issue127
What actually happened?
I wasn't able to get the outlines programmatically from any method or API in pdf-lib by checking the pdf that I loaded, so tried to read the code and loop through pdf.context.enumerateIndirectObjects() and with that, I got some information but I couldn't continue because my main issue now is, how I can link bookmark/outline with its page or get bookmark associated page index? Including nested bookmarks
// both base64 have outlines
const mergedPdf = await MergeDocuments([base64....1, base64....2]);
console.log("getPages", mergedPdf.getPages());
console.log("getPageIndices", mergedPdf.getPageIndices());
console.log("getForm", mergedPdf.getForm());
console.log("getKeywords", mergedPdf.getKeywords());
console.log("getTitle", mergedPdf.getTitle());
console.log("getProducer", mergedPdf.getSubject());
// Or looping trough enumerateIndirectObjects
for (const [key, value] of mergedPdf.context.enumerateIndirectObjects().map(x => x[1].dict).filter(x => x).entries()) {
console.log(key, value);
if (typeof value === "object") {
if (value.entries) {
for (const [k, v] of value.entries()) {
if (v instanceof PDFString && k?.encodedName?.includes("Title")) {
outlines.push(v.value);
}
}
}
}
}
What did you expect to happen?
When merging multiple pdf-documents the bookmarks/outlines got merged with them, or to have a proper way to do that accurately
How can we reproduce the issue?
I have attached two pdf-files that have bookmarks, try to merge them then open the merged document with adobe-acrobat "or another reader" and check bookmarks
Thank you for the awesome library, I think merging and including outlines/bookmarks will be added sometimes in the future based on the road map links if you could please consider giving ways to merge outlines with merging documents if that isn't in the roadmap plan implementation with high-level API
What were you trying to do?
I'm trying to merge multiple pdf-documents to a single pdf document and display it in the browser in pdf-viewer and send it to the S3 to store the merge result
I'm using pdf-lib to do the operations and react-pdf to display the documents in the broweser
Why were you trying to do this?
I'm building a web application that has a feature of pdf-viewer and that include merging pdf's appending images - scaling-rotating-etc
How did you attempt to do it?
Here attached the code that I use to merge documents
That didn't include bookmarks with the final document, so I tried to implement it following an issue/discussion on pdf-lib repo issue127
What actually happened?
I wasn't able to get the outlines programmatically from any method or API in pdf-lib by checking the pdf that I loaded, so tried to read the code and loop through
pdf.context.enumerateIndirectObjects()
and with that, I got some information but I couldn't continue because my main issue now is, how I can link bookmark/outline with its page or get bookmark associated page index? Including nested bookmarksWhat did you expect to happen?
When merging multiple pdf-documents the bookmarks/outlines got merged with them, or to have a proper way to do that accurately
How can we reproduce the issue?
I have attached two pdf-files that have bookmarks, try to merge them then open the merged document with adobe-acrobat "or another reader" and check bookmarks
Result in, no outlines or any bookmarks:
Version
1.16.0
What environment are you running pdf-lib in?
Browser
Required Reading
Additional Notes
No response
The text was updated successfully, but these errors were encountered: