Comments (3)
There are several ways to add a watermark to a PDF document, depending on the tools and libraries you are using for PDF generation. Here are a few options:
- Use a library that provides built-in support for watermarks. For example, the iText library for Java allows you to add a watermark to a PDF by creating a "template" PDF with the watermark, and then overlaying that template on top of the content pages.
- Use a PDF editor tool that supports watermarking. Adobe Acrobat, for example, allows you to add a watermark to a PDF by using the "Watermark" feature in the "Edit PDF" section.
- Create the watermark as an image and add it to each page of the PDF using a PDF generation library. For example, using the PyPDF2 library in Python, you can use the "PdfFileWriter" class to add an image of the watermark to each page of the PDF.
- Use a pre-processing step to add the watermark to each page of the document before generating the PDF. For example, you can use a document processing library like OpenCV to add the watermark to each page of the document as an image then convert it to pdf.
It's important to note that watermarking a pdf is not an easy task and it depends on what libraries or tools you are using. It's good idea to check the documentation of the libraries or tools you are using to see if they have built-in support for watermarking and how to implement it.
But want to implement a watermark this library (html-pdf)
from node-html-pdf.
What came to my mind is setting an element in the header/footer and styling it so that it fills the whole page, that would be possible by rotating the element. I think you are going to need absolute positioning of the element and setting the z-index of the element smaller than all the other elements on the page.
But I have no idea whether that would work.
from node-html-pdf.
I don't know if this can to help you, but I had a similar require few months ago; I fixed it adding to the body a background-image, the rest is just design and css -try and error-, of course the image have an alpha and I tried a lot of css combination to achive a good result:
<body style="background-image: url('WATERMARK_IMG'); background-repeat: no-repeat;">
Another way is to repeat the same idea but adding the image with absolute position to the header div with id="pageHeader" (it will be repeat in all new page on the document), This works for me too, but the only inconvinent is this: the image is cutted at the end of the document.
This is not the most elegant solution but it works :) good luck!
from node-html-pdf.
Related Issues (20)
- Text not being displayed on Mac. Working fine on Windows HOT 1
- Custom font not working HOT 1
- How can I make sure table header section should have at least one row.
- Background color not applying those area where no html
- Image not showing when uploaded on vps server
- QR code not visible over generated pdf post ami upgrade HOT 2
- Fonts don't work properly on server HOT 4
- stream (.toStream) not generated after deploying to k8s HOT 2
- The download pdf always have an empty page at last HOT 1
- html-pdf: Unknown Error throw new ERR_INVALID_ARG_TYPE(name, 'string', value); Docker HOT 1
- Pdf saved in TMP directory HOT 1
- Not able to resize the chebox size while generating the pdf
- Syntax for forcing a page break HOT 2
- Potential injection vulnerability in node-html-pdf
- Page overflow with white line
- PDF Creation Error: spawn /root/pando-app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT HOT 1
- The answer to how to resolve Windows error of phantomjs ENOENT issue
- Error: spawn E2BIG
- error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-html-pdf.