How to display rich text image (saved in Notes document) in XPages - image

Everyone keeps talking about opening the attachment. IT'S NOT AN ATTACHMENT! The image was pasted in a rich text field in Notes cocument. When I view the properties of one these Notes documents with the image, (unfortunately I'm not able to paste images to this), there are internal fields created for this rich text field namely MIME_Version, and the name of the rich text field listed four (4) times as shown below:
Field Name: myImage
Data Type: MIME Part
Data Length: 141 bytes
Seq Num: 3
Dup Item ID: 1
Field Flags: SIGN SEAL
"Content-Type: multipart/related; boundary="=_related 006391B688257C0D_="
This is a multipart message in MIME format.
"
___________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 150 bytes
Seq Num: 3
Dup Item ID: 2
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=
Content-Type: text/html; charset="US-ASCII"
<img src=cid:_2_0BCE1D8C0BCE1ACC006391B688257C0D>
"
____________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 14064 bytes
Seq Num: 3
Dup Item ID: 3
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=
Content-Type: image/jpeg
Content-ID: <_2_0BCE1D8C0BCE1ACC006391B688257C0D>
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsK
CwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQU
FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCACtALUDASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmq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qF
r4w8A+Gx5tyJSB5iFFDdB/tfhX3h8BLC38IeHEWeePdMAkUBfLk+pFTGojRxZ8L69qN5ZfF3xMtt
eT2y/wBq3IPkyMmfnPoa6n9pLU5bz9muKKa5muGGq2pXzZC3c9M1VTwS/ir4sa5KNQtrGefWbkLD
O3JBkOD+Ndd+1t4OGjfs8aZGtzDeM2qwljbHdjrSvFu4JSPEfh3ezQarAI7qaFRgARyFR+hr1b49
X9wNM8GTx3U5mUODL5h3jjpnrXJ/CP4Zt4ivLdYdUgicIhcPG52Eg8Eqp9K9W+PngBjfeFfD41K2
aeOKT94iMQHUnIIxnPHpRzxW4+STPO ..."
_________________________________________________
Field Name: myImage
Data Type: MIME Part
Data Length: 54 bytes
Seq Num: 3
Dup Item ID: 4
Field Flags: SIGN SEAL
"--=_related 006391B688257C0D_=--
"
Can someone please let me know how to display this image saved in a Notes document, in Xpages. What type of XPages control should be used? Thanks in advance.

You can use simple data binding to bind to a Rich Text field in the current document.
In my case binding to document1 a field called OverviewPicsChildparts which contains a pasted image works fine.
However I am trying to display a pasted image into a repeat control whose source is a DocumentCollection of response documents to document1 which is not as straight forward it seems.
However I solved this by adding this code...
<xp:this.data>
<xp:dominoDocument var="doc"
action="openDocument"
documentId="#{javascript:AllResponseDocs.getNoteID()}" ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
Into a panel inside the repeat control and then was able to use Simple Data Binding binding to doc the field I wanted like this...
<xp:inputRichText
id="inputRichText1"
value="#{doc.ProPicture}"
readonly="true"
style="width:198.0px;height:141.0px">
</xp:inputRichText>
it worked for me.

As Steve said, to display RichText data, you need the RichText control. Quite simple.
If the RichText data contains an image AND other data, like text or tables, things are different and much more complicated. In that case you need the NotesMIME classes to get the HTML representation of the RichText data, parse it, extract references to the image you want, then run through all MIME items to find the one holding the image data.
So in a nutshell: when the RichText contains the image alone, it's easy and Steve gave a good example. Otherwise it's complicated.

Related

Vector dev how to use hypenated key names?

Sometimes, when processing log events in vector, a log source might have hyphens as key names - for example json structured logs. Assuming it is from a third party and changing them there is not an option, how can we handle these keys?
A sample log message (contrived for demonstration) is:
{
"labels":{"no_hypens":"normal field","this-has-hypens":"this is a test"},
"message":"a message",
"timestamp":"2022-11-01T12:03:00.941866394Z"
}
Note the field labels.this-has-hyphens there.
I managed to put together a test case, and find out the syntax, both in providing test data like this and in extracting the data in VRL:
The test case
---
tests:
- name: hypens
inputs:
- insert_at: hypens
type: log
log_fields:
labels."this-has-hypens": "this is a test"
labels.no_hypens: "normal field"
outputs:
- extract_from: hypens
conditions:
- type: vrl
source: |
assert_eq!("normal field", .no_hypens)
assert_eq!("this is a test", .output_without_hypens)
This will insert and check for two fields from the input data. Note the hyphenated key segment needs to be quoted.
Next the VRL in the transform:
---
transforms:
hypens:
type: remap
inputs:
- route
source: |
log(., "error")
. = {
"no_hypens": .labels.no_hypens,
"output_without_hypens": .labels."this-has-hypens",
}
The log message is there as while debugging this, I had to figure out that the test hyphenated field didn't even get to the transform until I had quotes around it.
Then the field reference itself needs to have quotes too, after the dot (not square brackets).
This will pass the tests, and output the right data.

How to add json array and multipartFile as form data payload in postman?

I'm trying to pass a json array* and a multipart file as form data. Image below.
postman screen
As you can see i changed the content type for the "metadata" key and i passed a little array just of one element for the only scope to try the call. But it doesn't work.
The Headers tab is in the image below:
header
(*) each element of the json array is formed by 3 elements: below an example
{"key" : "metadataKey", "value":"metadataValue", "redefinedKey":"aNewKey"}
How i can solve this problem?
Thanks to all!

Change codemirror render function in show-hint.js

I would like to modify rendering hints in code mirror using
render: fn(Element, self, data) in show-hint.js with some id and replace those IDs in hint text inserted while reading value from codemirror using getValue()
Sample hint:
displayText : test
text: %%test%%
And the text should be mapped with some id in the background, it should be retrieved while getting value from the codemirror when the text in the codemirror contains special character '%%'
Could anyone please, help me to achieve this.

Get form field format itext7

I am getting form fields from the PDF document but I did not see any method for getting form field format ForExample there are multiple text form fields in my document including Number field, Date field, Percentage field.
Is there any way to get field format type in itext7
#Uladzimir Asipchuk
/TU dictionary contains ToolTip value. Format value is contained in /AA >> /K dictionary in PDF structure. However I have extracted the JS Method after some tries and exploring the PDF structure through Pre-Flight. The following code snippet give the associated JSMethod if any:
PdfDictionary additionalActions = formField.GetAdditionalAction();
if (additionalActions != null)
{
PdfDictionary formatDictionary = additionalActions.GetAsDictionary(PdfName.K);
PdfString jsMethod = formatDictionary.GetAsString(PdfName.JS);
string fieldJsMethod = jsMethod.GetValue();
}
I created a pdf via Adobe (as you suggested) and I indeed was able to set the "format" of a text field as Date, Number, Percentage, Email,..
Then I opened the resultant pdf in RUPS (an utility program used to open the pdf's tree) and investigated it.
It turned out that Adobe sets the "format" which you want to get as a /TU value of the field's dictionary. For example, for Percentage it's percentfield and for Email - emailfield.
Now the only thing you need to find the "format" of your fieeld is to get the value of /TU entry of your field:
field.getValue().getPdfObject().get(PdfName.TU)

Rebol shift-tab side effects

Given this:
view layout [ field [print "1" ] field [print "2"] ]
When I shift+tab from field #2 to field #1, no actions are fired.
How do I get them to fire just like a normal tab?
It is a bug in the key handler for field style in the Rebol/View engine. Here is a quick patch you can include in your code to fix it and make SHIFT+Tab work:
use [body f pos][
;-- patch `ctx-text/back-field` function to fix the bug
body: copy/deep second f: get in ctx-text 'back-field
insert body/2/while [if head? item [item: tail item]]
ctx-text/back-field: func first :f :body
;-- remove test that disables face/action for back-tabs
body: second get in ctx-text 'edit-text
body: find body 'word?
pos: at body/3/7/tab-char/5/6 11
change/part pos pos/4 4
]
This code will walk through View engine functions at run-time (code is data in Rebol) and hot-patch the functions bodies, by injecting or removing code where required.
If you happen to be a Rebol/SDK user, I can give you the instructions for patching the source files directly, so you can encap a fixed View executable.
Enjoy.

Resources