Closed maximuk closed 5 years ago
Hi,
I'm trying to replace some images in source PDF, but I succeeded only in replacing with JPEG images. Here is the code example:
const hummus = require('hummus'); const pdfWriter = hummus.createWriter('./output.pdf'); const copyingContext = pdfWriter.createPDFCopyingContext('./input.pdf'); const imageXObject = pdfWriter.createImageXObjectFromJPG('./jpeg.jpeg'); const xObjectIds = pdfWriter.createFormXObjectsFromPDF('./pdf.pdf', hummus.ePDFPageBoxMediaBox); copyingContext.replaceSourceObjects({ 41: xObjectIds[0] }); // -- does not work copyingContext.replaceSourceObjects({ 46: imageXObject.id }); // -- works copyingContext.appendPDFPageFromPDF(0); pdfWriter.end();
I understand that one PDF can be rendered into another, but in this case "z-index" and all transformations will be lost. So replacement is required.
The question is how to prepare PDF/PNG/TIFF images for replacement.
Thanks in advance!
Hi,
I'm trying to replace some images in source PDF, but I succeeded only in replacing with JPEG images. Here is the code example:
I understand that one PDF can be rendered into another, but in this case "z-index" and all transformations will be lost. So replacement is required.
The question is how to prepare PDF/PNG/TIFF images for replacement.
Thanks in advance!