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
Related
I have adopted various approaches to embed PDF blob in html in IE in order to display it.
1) creating a object URL and passing it to the embed or iframe tag. This works fine in Chrome but not in IE.
</head>
<body>
<input type="file" onchange="previewFile()">
<iframe id="test_iframe" style="width:100%;height:500px;"></iframe>
<script>
function previewFile() {
var file = document.querySelector('input[type=file]').files[0];
var downloadUrl = URL.createObjectURL(file);
console.log(downloadUrl);
var element = document.getElementById('test_iframe');
element.setAttribute('src',downloadUrl);
}
</script>
</body>
2) I have also tried wrapping the URL Blob inside a encodeURIcomponent()
Any pointers on how I can approach to solve this?
IE doesn't support iframe with data url as src attribute. You could check it in caniuse. It shows that the support is limited to images and linked resources like CSS or JS in IE. Please also check this documentation:
Data URIs are supported only for the following elements and/or
attributes.
object (images only)
img
input type=image
link
CSS declarations that accept a URL, such as background, backgroundImage, and so on.
Besides, IE doesn't have PDF viewer embeded, so you can't display PDFs directly in IE 11. You can only use msSaveOrOpenBlob to handle blobs in IE, then choose to open or save the PDF file:
if(window.navigator.msSaveOrOpenBlob) {
//IE11
window.navigator.msSaveOrOpenBlob(blobData, fileName);
}
else{
//Other browsers
window.URL.createObjectURL(blobData);
...
}
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.
I'm using data-menu-top on this page because everything is fixed and uses Skrollr to animate the different sections into view. The reason everything is fixed is so that I could do full-page SVGs that cover the height of the page (if you think there's a better way to do this, I would love to be enlightened).
Here's a link to the project development page: http://pman.mindevo.com
The button that appears on the first section has data-menu-top="10300", and this works great on Chrome, but when I try to view it in Firefox (33.0) the link doesn't do anything at all.
I am initializing using this code:
<script type="text/javascript">
setTimeout(function() {
var s = skrollr.init({
});
skrollr.menu.init(s, {
easing: 'quadratic',
duration: function(currentTop, targetTop) {
return 1500;
}
});
}, 1000);
</script>
Am I properly using data-menu-top? Is this a bug I'm not aware of using fixed layouts that are hidden using height?
Do I need to change the layout somehow to accomplish what I want and have it work in Firefox?
So the problem with Firefox was the way that it handles <button> linking. Here's the way the button was in the HTML:
<button class="buy buypotato">
<a data-menu-top="10300" href="#potatoPurchase1" class="purchase-options first-popup-link">
<svg ....etc></svg>
</button>
In Firefox it wasn't doing anything upon clicking, and got me thinking perhaps I'm using "button" HTML element incorrectly. Anyways, changing it to a div like so:
<div class="buy buypotato">
<a data-menu-top="10300" href="#potatoPurchase1" class="purchase-options first-popup-link">
<svg ....etc></svg>
</div>
That allowed Firefox to utilize Skrollr-menu to scroll to where I needed it to.
There might be a better way to do the layout on this, I'm still experimenting.
I have the following code for a popupmenu from Extension library
<xe:popupMenu id="pop">
<xe:this.treeNodes>
<xe:basicContainerNode image="/vwicn148.gif" label="Container">
<xe:this.children>
<xe:basicLeafNode label="Child" image="/vwicn148.gif"></xe:basicLeafNode>
</xe:this.children>
</xe:basicContainerNode>
</xe:this.treeNodes></xe:popupMenu>
<xp:link escape="true" text="Open popup" id="link1">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.openMenu(thisEvent,#{javascript:getComponent('pop').getMenuCtor()})]]></xp:this.script>
</xp:eventHandler>
</xp:link>
The result looks like this
As you can see the image for the basic containerNode is not displayed but the image for the basicLeafNode is displayed.
I want to add an arrow to the container node so that users know it has sub items, how can I do that?
Using firebug I can see that the image icon for the basicContainerNode has the class "dijitNoIcon" added to it, which sets "display:none" for the icon image. Whereas the leaf node does not have that dijiNoIcon class added. (I might need to look into that further as a possible defect)
But, as a workaround you could use some custom CSS to override what dijitNoIcon is doing.
<xe:basicContainerNode image="/vwicn148.gif" label="Container" styleClass="showIcon">
And add a custom css file to your application with the following:
.showIcon .dijitNoIcon{
display: block;
}
I hope someone can help me. I have colorbox working on a new client site, but I'm having troubles figuring out how to add code that will allow for the image that pops up to be clicked and then linked to an external site in a new tab.
This is what I have so far:
$(document).ready(function(){
$("a[rel='pop']").colorbox({transition:"fade", speed: 250});
});
<span class="h2">Baby Knits Kit</span> (2007)<br>Chronicle Books<br>
In the above, when Baby Knits Kit is clicked a pop-up opens fine with the image I created (about.babyknitskit.png). On top of the pop-up there's "Get it at Chronicle Books" and when I click it will take me to that site (in the same tab which I don't want). Instead, I would like the about.babyknitskit.png image to be clickable and opening up the link in a new window.
Any thoughts much appreciated. I hope I've given you guys enough information as I'm new to all of this and stackoverflow.
Simply use the html property of colorbox. Alternatively you could use the href property with 'inline' set to true. I have defined a custom attribute for the anchor for easier extraction, alternatively you could write a regex pattern to extract it from the title attribute.
$(document).ready(function() {
$("a[rel='pop']").colorbox({transition:"fade", speed: 250, html: function(){
var html = $('<img src="' + $(this).attr('href') + '" />');
return html;
}});
});
<span class="h2">Baby Knits Kit</span> (2007)<br>Chronicle Books<br>