jason-fox / fox.jason.watermark

DITA-OT Plug-in to add a watermark to generated PDF files
https://jason-fox.github.io/dita-ot-plugins/watermark
Apache License 2.0
1 stars 0 forks source link

Enable general usage as watermark plugin #2

Open hcw70 opened 1 year ago

hcw70 commented 1 year ago

Would it be possible to extend this plugin to:

So i would like to call it like dita -i my.ditamap -o doc/ -f pdf --pdf.watermark=CONFIDENTIAL --pdf.watermark.color="#e0e0e0" --pdf.watermark.size="48"

and get a "CONFIDENTIAL" as a backdrop.

jason-fox commented 1 year ago

I think the thing to do is to remove the existing (incomplete) language text generation, and to just create hard-coded "draft", "review" and "final" SVG images. A parameter could then override the default images, so you would be free to use the SVG of your choice.

jason-fox commented 1 year ago

I've got the same idea for HTML - here - just amend the CSS file to use your preferred image.

hcw70 commented 1 year ago

You create the images by XSLT anyway, why not have the text, color, size (and rotation) as parameters all together?

Then you dont need to distinguish between draft / review / final in you implementation at all?

The different XSLTs for these modes look similar anyway....

hcw70 commented 1 year ago

Hard-coded images does not sound like the right idea IMHO, since some (including me) may have different states / text to put as background ("confidential"). Your plugin btw is not called "review states plugin" but "watermark plugin"... 8->

jason-fox commented 1 year ago

In which case there will be a need to split the existing SVG generation in two.

1 - retrieve the appropriate default texts for the state (if not already supplied by the command line) 2 - better parameterise the SVG generation to allow for custom texts, colors and sizes.

hcw70 commented 1 year ago

Why not simply forward the command line parameters into

https://github.com/jason-fox/fox.jason.watermark/blob/63035a80d71f935beb209684c4480bf3b80f1f99/process_watermark_template.xml#L36

and have only one template to render the SVG?

hcw70 commented 1 year ago

IMHO you can also remove further code if you dont provide (language dependant) default texts. Simply grab the text to render from the command line.... The one who calls dita to render the doc already knows the language of the docs anyway....

jason-fox commented 1 year ago

Try pulling the latest change. The default is still DRAFT DOCUMENT

Change color

 ./dita -f pdf -i ../document.ditamap --pdf.watermark.color=blue

Change color and text

 ./dita -f pdf -i ../document.ditamap --pdf.watermark.color=blue  --pdf.watermark.text1=confidential

Change watermark style to FINAL

 ./dita -f pdf -i ..//document.ditamap --pdf.watermark.color=blue  --pdf.watermark.text1=CONFIDENTIAL --pdf.watermark.text2="" --pdf.watermark=final

Increase font size

 ./dita -f pdf -i ..//document.ditamap --pdf.watermark.color=blue  --pdf.watermark.text1=CONFIDENTIAL --pdf.watermark.text2="" --pdf.watermark=final --pdf.watermark.fontsize=14
hcw70 commented 1 year ago

Great! Looks good.

Two things: