is there a way to print the contents of a screen, that contain images rendered, to a printer in React Native? I looked into react-native-print but it only accepts HTML text whilst react-native-xprinter only supports Android. Thanks.
Managed to make it work. See codes below.
import RNPrint from 'react-native-print';
var htmlString = `<div style="(your CSS style here)"> (HTML contents here) </div>`;
RNPrint.print({html: htmlString});
If you want to embed an image in the HTML, see below:
var htmlString = `<div style="(your CSS style here)">
<img src="data:image/png;base64, ${imgData}" style="width: $imgWidth; height: $imgHeight"/>
</div>`;
You can replace "image/png" with other image type. Hope this helps.
Related
I am trying to render a html string into a div using v-html but it's not able to resolve the image path.
The image is stored as follows /src/assets/logo.png .
My project has already setup the copy-webpack-plugin.
The html string is as follows:
<img src="../assets/logo.png" /><br/><p>Hello World</p>
I'm using angular2 and bootstrap4. Popover correctly renders raw html as bold text asdf
<img src="assets/images/1.jpg"
data-container="body" data-toggle="popover" data-html="true" data-placement="top"
[attr.data-content]="getM()"/>
However, tooltip renders as plain <b>asdf</b> text including tags
<img src="assets/images/2.jpg"
data-container="body" data-toggle="tooltip" data-html="true" data-placement="top"
[attr.title]="getM()"/>
Component method getM:
public getM(): string {
return '<b>asdf</b>';
}
Both tooltip and popover are initialized the same way
$(function () {
$('[data-toggle="tooltip"]').tooltip({container: 'body'});
$('[data-toggle="popover"]').popover({container: 'body'});
})
Could someone explain why is that and how to solve? It seems this is connected with initialization order, but I just don't know where to look further.
Well, the issue was that my element (which tooltip was attached to) was created dynamically.
In exact, I had a 1 sec delayed service. When new data arrived, the <img> element in my component was recreated, but $('[data-toggle="tooltip"]') selector doesn't work with dynamic elements.
Instead, I had to use this selector
$("body").tooltip({selector: '[data-toggle="tooltip"]'});
Now it works as intended.
PS I'm not a front-end developer, so anyone who can explain it in better terms is welcome.
I have an editable div-tag where i dynamically create paragraphs. I want to save that div-tags content on button click. Is that possible?
<div id="RiskScoreTextArea" class="RiskScoreTextArea" contenteditable="true">
<p id="textAreaP"></p>
</div>
I would use jquery for that
$('.btnClick').on('click', function(){
var content = $('#RiskScoreTextArea').html();
});
If you wanted the text of the div you can use .text() but html will return the full contents of the div. Hopefully this will work for you.
I'm using the vLine JavaScript API with the uiVideoPanel widget to make WebRTC video calls.
My code looks like this:
window.vlineClient = client_ =
vline.Client.create({"serviceId": serviceId, "ui": true,
'uiVideoPanel':'showvideo'
});
and HTML:
<div class='span5'
style="width:300px;height:300px;background-color: #eeeeee;"
id='showvideo'>
</div>
However when one person calls another, the video takes up the full screen instead of only 300px by 300px.
How can I control the size of the video?
Make sure you set the CSS position to relative or absolute.
For example, with the HTML you provided it would be:
<div class='span5'
style="width:300px;height:300px;background-color: #eeeeee; position: absolute;"
id='showvideo'>
</div>
I want to display an image located in the app-storage directory of my AIR application. This image has to be displayed in an html text area where the html text is coming in from a local embedded sqlite database.
When I put in the following code:
imageTest.htmlText = '<img src="app-storage:/demo.jpg" border="0" />';
nothing is displayed.
But when instead of the app-storage path, I put in the absolute url of an image on the web, like below:
imageTest.htmlText = '<img src="http://www.example.com/demo.jpg" border="0" />';
the image is displayed correctly.
Also, I checked that the app-storage method is able to locate the image, but it just does not display in an htmlText container. For example, the following code displays the image:
imageTest.location = 'app-storage:/demo.jpg';
Any suggestions what I should do to get the image to display? I am using Adobe Flex Builder 3 as the IDE.
Thanks
Vinayak
Since your loading the html as a string it isn't in the application sandbox by default. Have you tried setting:
placeLoadStringContentInApplicationSandbox = true;
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/html/HTMLLoader.html#placeLoadStringContentInApplicationSandbox
Have you tried this?
imageTest.htmlText = '<img src="'+ File.applicationStorageDirectory.nativePath +'/demo.jpg" border="0" />';
This is very strange! The following code works for displaying images when I use the open source Flex Builder SDK on the Eclipse IDE, but does not work when I use the Adobe FlexBuilder IDE:
imageTest.htmlText = '<img src="app-storage:/folder/demo.jpg" />';
Maybe it is a bug.
Have posted as a bug:
https://bugs.adobe.com/jira/browse/FB-25986