I need to render complex svg files in my UWP application, but I haven't found any way to properly render a svg file from a path without using a WebView.
Is there a library which is able to do that? Moreover it would be great if it provides DataBinding.
With complex I mean every valid svg file should be able to render properly. e.g. a base64 encoded image within the svg file
Currently I use a WebView but there are a few caveats:
kinda slow. it takes approximately a second to load. I'd expect at most 500ms (I think that's possible)
I have to know the size of the file in advance
there are sometimes clipping issues
I use it inside a scroll view with the ability to zoom and sometimes something breaks and weird things happen
I have to cover the web view with another view and forward the events to the ScrollView (not very MVVM friendly)
Is there a way to render svg files in UWP
Sure, please refer SvgImageSource document, it could used to render svg image file. You can define a SvgImageSource by using a Uniform Resource Identifier (URI) that references a SVG file.
For example
<Image
Width="24"
Height="24"
Stretch="Fill">
<Image.Source>
<SvgImageSource
UriSource="/Assets/AddComment.svg" />
</Image.Source>
</Image>
And you could also use Win2D library to render SVG file, this related care reply that you could refer to.
Related
I have a large number of svg files (over 1000) that have keyframe animations included in the CSS. Ultimately I want to be able to display these in an android app.
I looked into using android vectordrawable among other solutions but that will only display the image from path data and wont be feasible to try add animations to every file.
I have have also tried converting to png using http://www.codeplex.com/svg in c#, again the png file does not include the animation.
You can use a Webview to display your svg.
here is a post that can help .svg file as object in HTML
Is there a way to display an SVG image (from a URL) in a xaml Image control in a UWP app
e.g.
<Image Source={Binding image_source}>
Where image_source is an absolute path to an image. Where the image is either png or svg format.
My solution works as expected with any common graphics format (jpg, png, gif) but displays nothing when the graphic is svg format.
I've seen loads of articles about converting the svg to something else, but the information comes from a web service that is not mine and use by others I would suspect. changing images on mass to png or something else I doubt would be an option.
In my application the Image is within a listView.
I've seen articles about converters and built in support for svg but none of them seem to work. I have yet to find any article here or anywhere with someone that has a working solution other than manually converting files (not an option)
Any help would be much appreciated.
UWP supports SVG natively and your solution should work. I guess the issue in your case is due to scaling. Make sure your graphics image has not scaled out of boundaries and you only see transparent part of it. You might try testing other SVG files to confirm that and play with size and SVG ViewBox attribute.
I am trying to convert html to pdf using wkhtmltopdf and I have done with it.But I din found any property to add page border in every page .Is there any solution to add page border on every page in Pdf file??
Thanks.
Do you mean just like a single color border around the page, touching the edges of the paper? This is very, very difficult with wkhtmltopdf, I would not use it do something like this. Maybe generate the file and "stamp" the borders with a different tool, for example iText (or iTextSharp seeing that you have a .net project) http://itextpdf.com/examples/iia.php?id=119
There's this question of SO: wkhtmltopdf with full page background which basically deals with your issue - trying to set a full page background, which is similar to what you are trying to achieve. You can evaluate the answers, but I think that it's not really an exact science or a reliable method to twist wkhtmltopdf into doing this.
I would like to know a most efficient way to load external images to my website.
For example:
My website's url is "www.mydomain.com". The external image is http://www.myimagedomain.com/image.jpg.
The most common way is to write a simple html image-tag like
<img src="http://www.myimagedomain.com/image.jpg" />.
The problem is, if the requested image is very large (8000x6000 pixel) but I want to show this picture as a thumbnail/preview like 200x200 pixel, e.g on mobile devices.
Based on this information I wrote a little ashx (c#) handler that downloads the requested image and resizes it to a given weight/height parameters, like this:
<img src="http://www.mydomain.com/img.ashx?imageUrl=http://www.myimagedomain.com/image.jpg&w=200&h=200" />
Now there is another problem, because the httphandler always downloads the requested image, on-the-fly.
My new approach is to generate a based64 string from the resized image and save this in a database once?!
Would you recommend this or is there another way to eliminated the download problem?
Maybe someone know how google-image-search prevents this problem?
I don't want to save the external images on my own server...
I would suggest to use image resizer library, it solves much of what you need in efficient way - caching included:
http://www.nuget.org/packages/ImageResizer/
I think google caches image thumbnails on its servers for search.
I have swf file's that's contains 2D images (here one of them: http://mapviewer.ru/img/tramvay/depo_d.swf )
I need draw this image (like seen in my browser), to bitmap.
Maybe i need convert this file to image (png, jpg)? No matter how, but it should be done programmatically.
Updated
Have you tried to look at this library ?
There are no embedded images inside the SWF file, only Vector shapes, which means you would need to both parse the SWF and render the data that is inside, so taking a screenshot of it is probably your best option. There are a lot of ways of doing this, but you could simply load the Flash Active-x in your application and take a screenshot. Here's how to load the SWF : Displaying Flash content in a C# WinForms application