WPF WebBrowser NavigateToString vs NavigateToStream (hebrew/non-utf8 encodings) - wpf

When I use WPF WebBrowser's NavigateToString method to display UTF8 html (with hebrew text in it) it's displayed perfectly.
However, when I try to use the NavigateToString to display html with hebrew text in it in a non-utf8 encoding (CodePage 1255 to be exact) the hebrew is messed up.
I checked the cp1255 string in Visual Studio's debugger and it looks great, and also when I save the source of the web browser's contents and open it with an external browser it looks great.
If I use the NavigateToStream method instead of the NavigateToString method it works great.
What's the problem with the NavigateToString? am I doing something wrong?

NavigateToString= NavigateToStream + UTF8NoBOM
Use NavigateToStream and make sure you have the correct encoding in the stream data.

Related

WPF XAML Encoding Error

I opened Login.XAML file in VS2012, it showing Encoding dialog box shown below
After clicking OK
I didn't see any design content of mine. I googled out but I didn't find any solution.
By clicking the encoding, or by something done previously, you've put in a character that Unicode or windows doesn't recognize. Scour your code or click on the error and you should find out how to fix it.

Internet explorer fails to display local image

I've created a bitmap image in C# and want to display this on a webpage on the local machine (so I can print it easily). The problem is, the Internet Explorer 9 does not display the image, it shows the "broken image" icon instead. Firefox has no problems with the image. I'm using Win7, 64 bit.
In order to narrow down the problem, I tried to just drag (from the file explorer) and drop the image file onto an empty browser window. Same thing: Firefox shows it, IE9 doesn't.
It gets even more weird: If I upload the file somewhere (see http://www.diebreuerei.de/Barcode.bmp), the IE9 does display it, it only doesn't if the file is stored locally.
Thanks in advance
Thanks for the answers, guys.
#Shannon: Nope, the console showed no errors.
#Michael: The Bitmap was directly created in C#, I dunno how to encode it in UTF-8.
But I got a solution: I just save my bitmap in PNG format and the IE9 is happy to display it. So I kinda lost interest in BMP :)
See ya,
Hannes

How to paste a text from textbox to some other application without using SIP?

I have made my own keypad.I know about the copy paste feature of WP7. I want to paste the copied text from textbox to some other application without using SIP.
Issues:
Copy the text by using default copy paste feature of WP7.
Get the copied text means from where i can get the copied text.
Now i don't want to use SIP to paste the text because i m hiding the SIP and using my own custom keypad.
I want to paste the copied text to some other application. So how to do this. Is it can be done with clipboard or through some other way.
Need some links to do so.
In the current version of the framework there is no API for working with the clipboard, though the Silverlight 4 Clipboard API will be coming in the next version.
However, if Matt Lacey has produced a solution that works by saving text information in JPEG images. You would be able to access this virtual clipboard from any of your own applications. http://blog.mrlacey.co.uk/2011/03/wp7clipboard-clipboard-api-for-wp7dev.html
While not possible now, one of the slides from Mix included a reference to a "Clipboard API" as part of the extras we'll get in the move to Silverlight 4 which is coming with Mango.
Hopefully that will complete the picture with regard to copy & paste / clipboard functionality.

Show pdf inside silverlight application. PDF to XAML

I need to create silverlight application where customer will see some pdf files.
PDF files have to be inside silverlight control and not rendered as images (customer wants to select text)
For this purposes i need some free libriaries or code to convert pdf file to xaml (or just open pdf so i can convert it to xaml).
Which library can read pdf and help me to convert data to xaml?
Can I read somehow pdf file and write custom convertation tool?
I saw iTextSharp. Is this library can read pdf and help me with my issue?
I will be thankfull for any ideas or links.
I make use of the Acrobat Reader plugin to do the displaying for me. It does require a different method depending on whether your application is running inside or outside the browser (I check if the application is running inside the browser and change the means of display accordingly). If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/9781430272076/.
Hope this helps...
Chris

Displaying PDFs in Silverlight

I want to make a PDF document reader, and the only thing I've found to help me is "Amyuni PDF Suite" that will turn the PDF into XAML and stream that. Are there any other controls for displaying PDFs in Silverlight? Or could I add an IFrame into Silverlight and let the client render it?
Cheers
Nik
Or could I add an IFrame into Silverlight and let the client render it?
Silverlight doesn't really have that capability. You can make your Silverlight control transparent, and have an HTML div block that sits above your Silverlight control, which you could then load a PDF in, but as for displaying a PDF within Silverlight, I think you're out of luck.
Edit:
This question has some info on how to accomplish transparent Silverlight controls, I hope it helps!
If you're ok with buying the pdf converter you can do something like this:
CanvasObject.Children.Add(XamlReader.Load("xaml string from pdf converter"));
And the pdf should be rendered inside your CanvasObject.
I really think you'll get the best result with some type of conversion to XAML. I imagine it can't be that hard to write the converter yourself, I might be wrong though.
Looks like First Floor Software has a solution but it's still in preview.
http://firstfloorsoftware.com/blog/pdf-for-silverlight-preview/
What we are actually trying to do is convert the PDF to SVG, then use something like: http://www.codeplex.com/XamlTune to then go to Xaml
you can use server side conversion of PDF say into set of bitmaps or as mentioned above SVG and return by WCF service to Silverlight client.

Resources