Hi,
we have a profile property which is an image. Can I access this picture and paste it in the report? (E.g. HEs situation diagram, Item definition picture,..)
thanks,
Sven
Hi Sven,
Thanks for sharing the example. When looking at the RTF code it becomes clear that your "problematic" image has the type "jpegblip" instead of "pngblip" (that's what we only saw in our tests, and it's used for screenshots). So far we only support png and wmf.
So current workaround would be to convert images to PNG.
Regards,
Nils
what exactly do you mean with "is an image"? Is it an RTF profile property with an image inserted (I wouldn't know a direct way to insert that one, we could only try to find a way), or which type does the property have?
Hi Nils,
yes, it is a RTF profile property:
were you able to find out, if this will work?
The only thing I could think of is to pick the PNG information (at least in my case the inserted screenshot was stored as PNG) out of the RTF code and convert it into binary PNG again, which could then hopefully be consumed by .asImage().
Would be a bit tweaky and only work with a PNG file, and only return the first PNG. Everything else in the RTF would be ignored.
Would that fit to your use case? Do you have also PNGs in your RTF properties (containing "pngblip", if you just access the property in the M2Doc template)?
this should fit my Usecase. How can I find out, if it is a PNG? I did the same as you, using a screenshot.
Hi Nills,
how can I convert a PNG to "image"?
is there an update on the conversion of the image?
I didn't have time for this in the last weeks. Some trials today failed, but will have another look hopefully next week. I'll share another update here afterwards.
Hi again,
I failed with scripting, but Jan succeeded in Java - earliest (and most likely) for 2024R1 onwards, though. First picture in RTF property is displayed by M2Doc, then.
Yes, we managed to have the first image extracted from an RTF text, supporting embedded PNG and EMF/WMF. The template will look like this:
We intentionally will introduce a more special service method to make clear that this is parsing (e.g. RTF) strings and can only handle the first image.
Happy Reporting
Jan
Hi Jan,
this is abailable only from 2024R1 or already possible?
Hi Sven, this was just freshly implemented for 24.1, I'm sorry.
Anyway, having the code ready, we may port it back to a JS based service, I think that should be feasible.
That way you can use it in any version supporting m2doc. The code is not too complicated.
Hi Jan, is there any documentation how to use the new service in 2024? I tried:
m:a.user_picture.firstPictureAsImage()
but is doesn't work
The documentation is as below, taken from 2024 R2 documentation (didn't get into 2024 R1 in time).
Your usage should normally work in 2024 R1 - any error output or just nothing?
Happy reporting,
I get the following message:
Hi Sven, that can only happen if there is no text set in the property, it is basically null aka undefined (not "").
We could improve the code here but might be that a.user_picture is empty?
the profile property is not empty.
We cannot reproduce the issue, for us it's working.
Can you please send the project or a simpler sample (I'll send a SecureTransfer message) with the same issue and open a ticket for that?
Thanks
it seems to be an issue with the image (but I do not know why). With an random picture from a screenshot, it works.
This will be fixed in next upcoming 2024 R2, As Nils said, changing to JPEG is one option, the other is to open the JPEG in paint and use copy/paste from there, not from the windows navigator. That way the image is internally pasted as EMF/WMF which was working before.
Hi all,
Just to confirm, we improved the firstPictureAsImage() service to also accept a JPEG image in 2024 R2 (was released in July 2024).