Can anyone tell me ow to format the text/document before I send it to print. Below is little explanation of what I am trying to achieve.
I have few lines like below
To: abcd
From: xyz
Location:blah
Phone:99999999
Sub:something
Message Body:
I can have this all in a list<string>; add them to page and print them but the print will not be formatted ... printed outcome will be as above but what I am looking for is kind below:
To: abcd
From: xyz
Location: blah
Phone: 99999999
**Sub : something**
Dear abcd,
Some message.
Some other information
any idea how can I achieve this. Thanks.
You might need to use Run's inside a textblock like this:
<TextBlock>Name: <Run FontWeight="Bold">Hola que tal</Run><LineBreak />
Age: <Run FontWeight="Bold">201</Run><LineBreak /></TextBlock>
Related
I have a functioning Robot Framework test that scrapes the elements of a page and returns the link text. My problem is, some of these fields are empty and some of them have text. I do not care what the text is, however. This is an example of the output I get:
"Link Text="
"Link Text=" John Doe
"Link Text=" Jane Doe
In this case, I would only want the program to return items 2 and 3, and not Log item 1. Here is my code to achieve this right now.
TEST
${Count}= Get Element Count //a
Log To Console Total= ${Count} \n
FOR ${INDEX} IN RANGE 1 ${Count}-1
${text}= Get Text xpath=(//a)[${INDEX}]
${href}= Run Keyword And Return Status Get Element Attribute xpath=(//a)[${INDEX}] #href
Run Keyword If ${href} Log To Console ${INDEX}. "Link Text=" ${text}
... ELSE Log To Console NONE
END
So this does give me a pass, and I do get the link text I'm asking for. I just need to take out the blank entries. I know my loop is functional, but I can't figure out how to parse the blank fields. How can I do this? Any ideas? Please let me know, thanks so much!
In these situations I usualy use Get Length and test if greater than zero.
Here is your modified example:
TEST
${Count}= Get Element Count //a
Log To Console Total= ${Count} \n
FOR ${INDEX} IN RANGE 1 ${Count}-1
${text}= Get Text xpath=(//a)[${INDEX}]
${size}= Get Length ${text}
${href}= Run Keyword And Return Status Get Element Attribute xpath=(//a)[${INDEX}] #href
Run Keyword If ${href} and ${size} > 0 Log To Console ${INDEX}. "Link Text=" ${text}
... ELSE Log To Console NONE
END
I have an array of 150 buttons that link to 150 pictures, i need to show the picture once the button is pressed. The information for the buttons is stored in a JSON file. The pictures names are the ID's of the buttons, so 1.jpg, 2.jpg etc.
Now I am facing the problem that I can't write:
fish["image"] = {uri: "asset-library://" + fish.id + ".jpg"};
And the other solution with if statements does not work since I have so many options, any ideas?
Thanks so much
I had a similar problem. I built a function that contains a huge switch statement and has static requires for every case.
function getImage(id) {
switch(id) {
case 1:
return require('./img/1.jpg');
case 2:
return require('./img/2.jpg');
...
}
}
Now you can do
fish["image"] = getImage(fish.id);
I also had to use over 100 icons, so instead of writing the cases by hand, I built a script that generates the function automatically.
I had too this problem for a component I developed. I used base64 image in json file. But maybe it's not a good fit for you, I hope it can help.
<Image
style={styles.imgStyle}
source={{uri: CountryFlags[country.cca2]}}
/>
You can see it here : https://github.com/xcarpentier/react-native-country-picker-modal/blob/master/src/index.js#L137-L139
And if you have a folder with files on it, simply convert images like that :
#!/bin/sh
list=`ls ./flags | grep '[A-Z]'`
echo "{"
for item in $list
do
header="data:image/png;base64,"
img64=`ls ./flags/$item | xargs cat | base64`
echo ${item:0:2} :\'$header$img64\',
done
echo "}"
I need to print a barcode on Odoo (v8) pos receipt using posbox.
I tried like this :
<barcode encoding="CODE39"><t t-esc='receipt.coupon_code'/></barcode>
Result : Nothing is printed . But if I make a test like :
<barcode encoding="CODE39">*123456798*</barcode>
It prints the barcode.
I also tried like this without success:
<img t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s' % ('CODE39', receipt.coupon_code, 600, 100)" style="width:300px;height:50px"/>
Any advice ?
Thanks a lot.
In fact,
<barcode encoding="CODE39"><t t-esc='receipt.coupon_code'/></barcode>
works perfectly...
The problem was the length of receipt.coupon_code.
For information, this coupon_code is randomly generated .
It prints successfully the barcode with an 8 digits code, starting and ending with "*" ( *12345678*, for example)
I created one receipt and I know how to write barcode in receipt for that you have to convert your barcode in image and then split it. You have to make changes in .xml file. Steps are as follow:
Convert this code in image using <img> tag after then split that like this:
<img t-if="field_name" t-att-src="'/report/barcode/?type=%s&value=%s&width=%s&height=%s&humanreadable=%s' % ('Code128', field_name.split(' ')[1], 600, 100, 1)" style="width:300px;height:50px"/>
Here field_name is that field of py where your barcode is stored.
I have a link somewhere on my page, let say like this
my link label
How to verify, that my link title attribute has 'my title message' value?
Assertattribute command use to verify it, please check this code.
assertattribute | title = my title message#href | http://example.com
assertattribute | link=my link label#href | http://example.com
From Selenium IDE use this:
command | target | value
-------------------------------------------------------------
assertAttribute | link=my link label#title | my title message
try like this.
command: verifyTitle
target: my title message
this command will compare the actual page title with the text given in the command target if both is same no error will show other wise error will display
Thank You...
So, I'm trying to migrate a database from Textpattern CMS to something more generic. There are some textpattern-specific commands inside of articles that pull in images. I want to turn these into generic HTML image links. At the moment, they look like this in the sql file:
<txp:upm_image image_id="4" form="dose" />
I want to turn these into something more like this:
<img src="4.jpg" class="dose" />
I've had some luck with TextWrangler doing some regex stuff, but I'm stumped. Any ideas on how to find & replace all of these image paths?
EDIT:
For future reference, here's what I ended up doing in PHP to output it:
$body = $post['Body_html'];
$pattern = '/txp:upm_image image_id="([0-9]+)" form="([^"]*)"/i';
$replacement = 'img src="/images/$1.jpg" class="$2"';
$body = preg_replace($pattern, $replacement, $body);
// outputed <img src="/images/59.jpg" class="dose" />
I wouldn't use grep; it's sed you want
$ echo '<txp:upm_image image_id="4" form="dose" />' | sed -e 's/^.*image_id="\([[:digit:]]*\)".*form="\([[:alpha:]]*\)".*/<img src="\1.jpg" class="\2" \/>/'
<img src="4.jpg" class="dose" />
$
if your class has alphanumeric characters, use [[:alnum:]]
(works on macos darwin)
Not sure which tool you are using but try this regex solution: Search for this:
<txp:upm_image\s+image_id="(\d+)"\s+form="([^"]*)"\s*\/>
And replace with this:
<img src="$1.jpg" class="$2" />
Note that this only works for txp tags having the same form as your example. It will fail if there are txp tags having extra attributes, or if they are in a different order.