I am building a mobile site and the footer has an background.
I want to check if the browser supports css property, background-image, if true display background with specific html, else display a different set of html.
I am using the following :
HttpBrowserCapabilities bc = new HttpBrowserCapabilities();
I can't seem to get a check for backgrounds.
The reason why I want to check for BG-image support is coz I have to switch between 2 sets of html. 1 with html text and bg image, and the other with the text on the image - sliced for each word/link...to give the same effect.
to get information by HttpBrowserCapabilities, you have to use Request.Browser property.
HttpBrowserCapabilities browerCapabilities = Request.Browser;
I think Asp.net will automatically check the type of the browser and render the page accordingly. So if the the browser don't support background images it will not come.
Another idea to solve the issue is getting the browser type by using code, then you can show or hide the background images based on the type.
Related
I have a pdf file created with itextsharp with images in the file. I would like to put a hyperlink in the file that if you pick the picture it will open that picture in a picture viewer. I can set a hyperlink to a web address but have no idea how to get it to open a file. Below is the code, yes I know that c:\test.jpg is a bad hardcoded file name but it is just a test. When you click the picture it does nothing but I have no idea how to tell it what to do.
iTextSharp.text.Image pic =TextSharp.text.Image.GetInstance(comment.examplePic);
pic.ScaleToFit(200f, 200f);
Chunk cImage = new Chunk(pic, 0, 0, false);
Anchor anchor = new Anchor(cImage);
anchor.Reference = "c:\\test.jpg";
doc.Add(pic);
doc.Add(anchor);
A PDF is self-contained. This means that all the resources needed to show the PDF are (usually) stored inside the PDF (exceptions are for instance fonts that can be retrieved from the operating system).
When you have an image that is shown on a PDF page, the bytes of that image are stored in what we call an Image XObject. An XObject is an object that is external to the page, but that is stored as a separate object inside the PDF file.
You are asking to serve the image bytes stored inside this separate object to a viewer on the operating system. This is impossible. I don't know of any viewer that can take those bytes and somehow forward them to an image viewer.
I can think of three possible workarounds. I don't know if any of these workarounds is acceptable to you.
1. Serve the image online
You could put the image on a server and use the code you have in your snippet to link to that online image. Of course: this will only work if the person viewing the document is online and clicks OK when his viewer asks him if it's OK to link to a resources on the internet.
2. Serve the image as an annotation
In this case, you create an annotation for which you create an appearance that renders that same image XObject in the annotation layer (all annotations are shown on top of the page content). You can easily change the visibility status of an annotation to make it invisible (in your case, this would be the default status) or visible (in your case, this would be triggered by a JavaScript action when clicking the link).
There's an example of such an annotation here: Advertisement. If you open advertisement.pdf, you see an image with a button that says "Close this advertisement". Once you click that, the status of the annotation will be changed to invisible. You could do something similar, but the other way round: click a link to make it visible instead of invisible.
This solution doesn't depend on an external viewer, the image is shown in the PDF viewer.
3. Add the image as optional content
Starting with PDF 1.5, PDF supports optional content. See for instance the OptionalContentExample. In this example, we have some questions and answers, but the answers are not visible by default. See layer_actions.pdf. There are links "on / off / toggle" to make the answers visible or invisible.
You could do the same with images: you could add them to a layer that is invisible by default, but that can be made visible if somebody clicks a link. However: this requires a viewer that supports OCG (optional content groups) and the actions to change the status of these OCGs. For instance: if you would try the layer_actions.pdf example in the PDF viewer in Chrome, it won't work, but if you download the PDF and open it in Adobe Reader, you'll see the behavior I described.
Summarized:
You are asking something that is impossible, but there are workarounds. Please post another question if you have chosen a workaround and you don't succeed in making that workaround word (but please take into account that not all viewers support every workaround).
no offence but too much knowledge sometimes makes you ignorant of small things.
simple solution to this problem is here
http://kuujinbo.info/iTextSharp/imageAnchor.aspx
sample code that i implemented works like charm
PdfPCell p1 = new PdfPCell();
p1 = new PdfPCell();
p1.Padding = 0;
p1.Border = 0;
PdfPTable nav = new PdfPTable(1);
nav.WidthPercentage = 100;
nav.SpacingAfter = 12;
navbarImg.Annotation= new Annotation(0, 0, 0, 0, ur);
p1.Image = navbarImg;
nav.AddCell(p1);
_doc.Add(nav);
Im using .net c# MVC3 Model. I need to show a gif called loading when I click save on the page. I used <img src="sourcepath" alt="loading" style="display:none"/> and trying to display it whenever user clicks save button using jquery. I have stored the image temporarily in views folder. Unfortunately, i could not see image on the screen. I can see its division with a small red cross cancel button.
Pls Help
If you're seeing the broken image icon, it means your src "sourcepath" is wrong. You would normally put static content in the Content folder of your site, and access it using /Content/imagename.jpg or /Content/Images/imagename.jpg or similar.
Try to use the search, here you can find an solution the show an spinner when doing ajax requests:
How to show loading spinner in jQuery?
So I was wondering, if I have a div which contains a maps of google maps rendered with some makers and I want to take a picture of that element how can I do this?.I found this solutions it's a approach of what I need but the problem it's that sending a url doesn't help me, I need the specific Div with all the markers. For the server side i'm using C# and for the cliente, asp.net with jquery. Also the google maps apiV3 to handle the maps
Take a look at the Canvas2Image library by Nihilogic Labs:
http://www.nihilogic.dk/labs/canvas2image/
Here's an example of how to take a screenshot of an element through JavaScript:
var oCanvas = document.getElementById("thecanvas");
Canvas2Image.saveAsPNG(oCanvas);
EDIT
You might also take a look at Html2Canvas and FlashCanvas too. I believe one of them has support for earlier browsers (those which don't support HTML5).
Use the method in the link you mentioned and crop the resulting image to the dimensions of your div. You can use myDiv.getBoundingClientRect() in JavaScript to get the dimensions of your div.
Using the WebBrowser control, you can manipulate the document using html or JavaScript to get the page in the state you need to take your screenshot.
Have you considered using the Google Maps Static API - this will render a map image, with markers on it, as a PNG.
I am having the following problem:
I have a web page hosting silverlight content. The silverlight content is navigation aware, so it will always be the same html page and the same silverlight control. The content however will of course change when the user is navigating from one page inside the control to another.
Different pages have different size requirements and in some cases the final height of the content is unknown because the content is coming from a web service.
I want the height of the silverlight content to be dynamically according to what it actually needs. I saw many solutions to make the silverlight control fit the browser window, but I want the silverlight content to only have the actual height it needs and overflow when necessary, so that I can use the browsers scrollbars.
The page should also have a static background image, which is giving me some problems when the object tag is not exactly the size of the silverlight content.
The effect I want to achieve is more or less like in this web page:
http://www.codegarden.de/
The background should be in the html page when possible and the silverlight control should be the content in the middle part and should scroll with the browser scrollbar.
Can anyone help me? Thanks!
You can have your silverlight application execute javascript commands on the hosting page, that will in turn set the size of the <Object> tag.
Something like that:
using System.Windows.Browser;
// set a global variable
HtmlPage.Window.Eval(String.Format("setSilverlightObjSize({0},{1});",newW,newH));
where setSilverlightObjSize is a javascript function you wrote in the hosting page.
soemthing like:
function SetObjectTagProps(w,h)
{
var obj = document.getElementById("silverlightObj");
obj.width = w;
obj.height = h;
}
I have an asp.net page, with couple of Divs, some of these div's get the image path from database and show the image in a smaller version (thumbnail). and as soon as user click on thumbnail, I use ajax Modal popup to show the full size image, what I need to have is to have a progree image(gif), on every thumbnail image while loading the asp.net page for the first time, I konw that it is possible to use UpadePanel, but I need the actual working code,or any other way to achieve this,
Thanks in advance
Well, if you are posting back, udpate panel can work; but you can programmably in JS do this yourself, or also consider using a JS plugin like lightbox: http://www.huddletogether.com/projects/lightbox2/
Which has that feature and looks very cool.