7 respuestas
pdf-lib is what most people use for this. Upload it as a static resource, load it in an LWC with loadScript, pull the files' base64 VersionData from Apex, merge in the browser, then save the result back as a new ContentVersion.
Main reason to do it client-side rather than Apex: you skip the 6MB/12MB heap limit, so large files still work.
const merged = await PDFLib.PDFDocument.create();for (const b64 of base64Files) { const doc = await PDFLib.PDFDocument.load(b64); const pages = await merged.copyPages(doc, doc.getPageIndices()); pages.forEach(p => merged.addPage(p));}const out = await merged.saveAsBase64();If the library misbehaves under Lightning Web Security, the usual workaround is running pdf-lib in a Visualforce page inside an iframe and passing data with postMessage.
If you'd rather not host the library, Api2Pdf and Adobe PDF Services both do merge via callout — but the files leave your org, which rules them out for most healthcare/finance work.
https://hicglobalsolutions.com/blog/how-to-merge-and-brand-pdf-files-in-salesforce-using-lwc-visualforce-pdf-lib/