Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add text in word Watermark in DocumentAssembler #62

Open
luizfbicalho opened this issue Apr 6, 2023 · 7 comments
Open

Add text in word Watermark in DocumentAssembler #62

luizfbicalho opened this issue Apr 6, 2023 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed Word Word related tasks

Comments

@luizfbicalho
Copy link
Contributor

Did anyone suceeded in addng a watermark to the template, with a tranformation and make it work?

Mine was like this

image

@sergey-tihon
Copy link
Owner

You may start from posting here code sample that you have used.

@sergey-tihon sergey-tihon added question Further information is requested Word Word related tasks labels Apr 8, 2023
@luizfbicalho
Copy link
Contributor Author

DocumentWaterMark.docx
DocumentWaterMark_Transformed.docx

I Uploaded the files and this is the xml

<Data>
	<Name>Abelardo Barbosa</Name>
	<Address>Rua Montes Passados, 1550</Address>
	<Phone>(11)9999-9999</Phone>
	<Email>aberlardo@tvz.com.br</Email>
	<WaterMark>TEXTO QUE PRECISO PARA COLOCAR DE FUNDO NO DOCUMENTO</WaterMark>
</Data>

This is the template image

image

image

and this is the result image

image

As you can see the Assembled document still have the <##> on the watermark.

Is that possible?

@sergey-tihon
Copy link
Owner

What code/class do you use (and how)?

@luizfbicalho
Copy link
Contributor Author

This is the code, just a simple AssembleDocument @sergey-tihon

var wmlDoc = new WmlDocument("template.docx", template);
var element = XElement.Parse(orig);
bool templateError;
var wmlAssembledDoc = DocumentAssembler.AssembleDocument(wmlDoc, element, out templateError);
return wmlAssembledDoc.DocumentByteArray;

@sergey-tihon sergey-tihon added enhancement New feature or request help wanted Extra attention is needed and removed question Further information is requested labels Apr 21, 2023
@sergey-tihon
Copy link
Owner

I believe that watermarks are not supported yet. If you decide to implement this, you need to take a look inside your template, find markup for the watermark and then extend content transformation to the property handle transformation - https://github.com/sergey-tihon/Clippit/blob/master/OpenXmlPowerTools/Word/DocumentAssembler.cs#L1152

@luizfbicalho
Copy link
Contributor Author

The watermark is inside a shape, the xml is this

<v:textpath style="font-family:&quot;Calibri&quot;;font-size:1pt" string="&lt;#&lt;Content Select=&quot;./WaterMark&quot;/&gt;#&gt;" xmlns:v="urn:schemas-microsoft-com:vml" />

I would work fine if it were a subnode but as an string it's too unsafe to change, do you have any other idea?

@sergey-tihon
Copy link
Owner

I see no other options rather than special case for string attribute of v:textpath

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request help wanted Extra attention is needed Word Word related tasks
Projects
None yet
Development

No branches or pull requests

2 participants