29
Views
10
Comments
[OfficeUtils] Set Text end Image in word file
Question
officeutils
Service icon
Forge asset by Bruno Gonçalves
Application Type
Service

I am using the Word_Export_SetText function to replace text using a tag. Within this text, images may or may not be present. The steps I am following are: 

1) I use Word_Export_SetText to replace the #content_Nota tag with the desired text. 

2) I store the conversion in a local variable and obtain this: text before example #Content1image text after example.

 3) At this point, I use Word_Export_SetPicture to insert the image record.

 4) Finally, I use Word_EtichettaNota.NewWordFile.WordFile in WordFile and also Word_Export_SetPicture.NewWordFile.WordFile in WordFile. 

This does NOT work. Is there a way to dynamically replace text that contains images? 

Thank you, Davide 

UserImage.jpg
Bruno Gonçalves

Hi Davide,

In fact the situation you are describing (add picture in the middle of a text block) was not accounted for. However, this is a fairly small adjustment to do, so I can make it part of the release I'm planning to do towards the end of next week.

To play safe, I would like to send you the application package early next week for you to make sure it works, and only after that publish it in Forge. Does this work for you?

Out of curiosity, what is the result you are getting on the exported document?

Best,

Bruno


UserImage.jpg
davide cannarella

Hi Bruno,

I'll do the tests in the next few days.

I'll give you feedback as soon as possible.

Thanks

Best regards

Davide

UserImage.jpg
Bruno Gonçalves

Hi Davide,

Just to let you know that I have just released a new version of OfficeUtils (5.3.0) that addresses your requirement (add picture in the middle of text block).

Please let me know if it works as expected.

Best,

Bruno

UserImage.jpg
davide cannarella

Hi Bruno, 

I installed the version into personal environment (5.3.0).

comparing the old version with this new version I can't find the appropriate server action to test.


Can you give me some instructions on how to do it? in FORGE not prensent documents


Thanks

regards

Davide


UserImage.jpg
davide cannarella

Hi, after the update some tags stopped being replaced. For example, the tag #content_DataNascita is replaced like this '14/08/1984ataascita' instead of being replaced like this '14/08/1984'. I have many that no longer work, another example is the tag #content_EtichettaBanker: which is replaced with 'BankerBanker' instead of just 'Banker' . Below are the images. 

replace2.PNG
tag1.PNG
tag2.PNG
replace1.PNG
UserImage.jpg
davide cannarella

I add that in my Test environment, the old version of the component correctly replaces the tags with the same template, whereas in the DEV environment, I updated the component to the latest version, and the replacement behavior is incorrect as described in the previous post. Could you please check and correct the malfunction? Thank you 

UserImage.jpg
Bruno Gonçalves

Hi Davide,

In fact this issue was introduced in the latest release, where I've made a significant refactoring of the placeholder replacement logic.

I missed to spot it in my tests, since apparently only happens when capital letters are used in the placeholders.

I fixed the issue already, and I will be sharing a new built of OfficeUtils with you in a private message. Then if and when you confirm that everything is working properly, I will release it in Forge.

Best,

Bruno

UserImage.jpg
davide cannarella

Hi Bruno,

confirm all replace correct. 

can you upload to forge?

thanks

:)

UserImage.jpg
Bruno Gonçalves

Great Davide! :)

I have just released the new OfficeUtils version (5.3.1) in Forge, also for ODC.

Best,

Bruno

UserImage.jpg
davide cannarella

Hi Bruno, another question: Is it possible to pass character formatting for printing in Word? For example, I would like to insert a sentence in bold or underline parts of the text. I tried writing the text in HTML and then passing it through the HTML To TEXT converter on the Server Action WordExport\Word_Export_SetText, but unfortunately, it doesn't see the formatting. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.