Image opacity in stories #3676
-
Hi I am using PyMUPDF to convert HTML to pdf. When I initially started I used stories. Now I want to add effectively a bunch of watermarked images. I have tried adding the image in html <p class="first"> <img class="myimg" src="glass_blank_bW.png"/> with CSS .myimg {
background-image: url("glass_blank_bW.png");
opacity: 0.1;
width: 100%;
} and within code img = ("glass_blank_bW.png", "img")
members = (img)
arch = pymupdf.Archive("/blah/blah/blah/blah/")
arch.add(members, path="mypath")
CSS = csspath.read_bytes().decode()
story = pymupdf.Story(html=HTML, user_css=CSS, archive=arch) but I cannot get the opacity to change in the document, nor can I have the text sit on top of the image. I can see that I can add a watermark outside of stories and that i can use insert_HTMLbox but I have no idea how to use these with stories if i need to. Just to add that i will want to add multiple images on different pages. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yo must use separate stories or |
Beta Was this translation helpful? Give feedback.
Yo must use separate stories or
insert_html
executions to achieve this.A single story is intended to represent the output of one "flow" of text (actually the DOM content of the Story) across potentially multiple rectangles / pages. Although "text" may contain image references, there exists no explicit control to position details of the Story's content.
So use multiple rounds to achieve what you want. One round that writes text to pages (outputting to some memory), then re-open that new document and put your watermarks on the pages.
For round 2,
insert_htmlbox
is a convenient thing, but of course you can do whatever you want and e.g. useinsert_image
as well.