I am not able to add image that is saved at a URL something like "http://host/img.png" using below code snippet:
section.AddImage(url);
However if I use url as a relative url of image that is present on my disk then this is working fine.
Is this limitation of MigraDoc?
Can someone provide workaround, code samples to over come this?
MigraDoc works with local files (relative or absolute paths), not with files that are somewhere on the Internet.
AddImage() needs a path, not a URL.
You can download the image from the URL and either store it in a local file or store it in a string using BASE64 encoding and pass that string to MigraDoc.
You will have control over accessing the image from the web and can properly deal with problems.
See this article on BASE64 encoding for MigraDoc images:
http://pdfsharp.net/wiki/MigraDoc_FilelessImages.ashx
Related
I wanted to ask how can we read a post request of a form that has file upload and then convert the file in base64 encoded form.
Looked at the examples shown in the play framework site, but it only explains about uploading a file and storing it in some location. But what if I need to convert the uploaded image into a base64 encoded form??
I looked through various resources, could not find what I was looking for. I just have a simple form that uploads image and need convert the upload image to base64 encoding. And yes I am using play framework.
Any help, please.
Update:
What I was actually searching for was:
val imageRaw:Option[play.api.mvc.MultipartFormData.FilePart[play.api.libs.Files.TemporaryFile]] = request.body.file("picture").map { picture =>
picture
}
Now how do I convert the imageRaw to base64 encoded string, I don't need to store the image in the disk.
Update2:
What I really had to achieve was load an image using drag and drop functionality and then load the image in a HTML5 canvas, had no problems with other browsers but since IE9 doesn't support FileReader Api, I couldn't retrieve its imageData after its loaded using the DnD functionality.
So, now I am trying to use polyfills to be able to use FileReader API in IE9, does anyone have any idea or samples of how to use them. I have been trying to use FileReader API for now, but can't get to know how to use it.
Is there a possible way of getting Excel to import a picture into a worksheet from a web location where the web location is not a simple url to a file but a dynamic page that generates the picture from the information supplied in the url?
I'm using the shapes.addpicture method at the moment and I get error 1004 - file not found. It works with: http://www.andyross.net/images/heide_hut.jpg
But it doesn't work with:
http://charts.moneyam.com/Chart.aspx?Provider=EODIntra&Code=RBS&Size=900&Skin=GreenRed&Type=3&Scale=0&Cycle=DAY1&Span=MONTH3&OVER=EMA%2812%29;EMA%2826%29;SR;AreaBB%2826,2%29&IND=MACD%2826,12,9%29;SlowSTO%2812,3,3%29;ADX%2812%29;VOLMA%2812%29&Layout=2Line;Default;Price;HisDate&XCycle=&XFormat=
The above URL would work if I put it in the browser address bar, and would produce a gif image of the stock chart for RBS.
At first I thought it was the long file name, so I used Tinyurl to produce a url short enough to be acceptable to Excel. However, it still doesn't work (and using tinyurl for the simple url does work in excel) so I think it must be the dynamic content.
Does anyone have any thoughts on how to get this to work?
You'd probably be better off using an embedded webbrowser control. This video can step you through setting it up and using it http://www.youtube.com/watch?v=GBAHJSfm8Xg
I have a page in JSP, which has a tag like:
<img src="images/1.bmp"></img>
The 1.bmp is like:
But the image which looks in my page, visited by firefox, is like:
what should i do to fix this problem?
I've converted the images which you uploaded into your question back to BMP and investigated their source. Everywhere where a non-ISO-8859-1 character appears in the original source, a ? appears in the malformed source.
This means that you've a servlet on /images/* which uses response.getWriter() to write the image using the platform default charset. You shouldn't do that. BMP files are not text files. BMP files are binary files. You should be using response.getOutputStream() to write binary data. You can find a basic and proper example of an image servlet in this article.
I am trying to extract images from flash on the following web-site: http://meijer.shoplocal.com/meijer/default.aspx?action=entryflash&storeref=120
I noticed that every time I click on "Next image", an images is requested from sever. Sample URL is http://akimages.shoplocal.com/dyn_rppi/740.0.75.0/meijer/large/110206os_o_003_T1C1_2pw26.jpg
So, this URL is exactly what I need, but I don't know how to extract all these URLs from the .swf file I have. I don't have any experience with flash, but I think that URLs should be in the .swf file. I tried "grep '110206os_o_003_T1C1_2pw26' adspage_slider-2.swf", but didn't get any result :(((
Ivan,
Did you try a Flash decoder? It should allow you to access the code and respective resources. Another possible and easier way would be to use Fiddler2 to extract the URLs that you have clicked from the swf file. Still, before you move further, make sure that you're not breaking any of the site's Terms and Conditions.
I am a complete novice to Flash (never created anything in flash). I am quite familiar with web applications (J2EE based) and have a reasonable expertise in Javascript.
Here is my requirement.
I want the user to select (via an html form) an image. Normally in the post, this image would be sent to server and may be stored there to be served later. I do not want that. I want to store this image locally and then serve it via HTTP to the user.
So, the flow is:
1. Go to the "select image url":mywebsite.com/selectImage
Browse the image and select the image
This would transfer control locally to some code running on the client (Javascript or flash), which would then store the image locally at some place on the client machine.
Go to the "show image url": mywebsite.com/showImage
This would eventually result in some client code running on the browser that retrieves the image and renders it (without any server round trips.)
I considered the following options:
Use HTML5 local storage. Since I am a complete novice to flash, I looked into this. I found that it is fairly straightforward to store and retrieve images in javascript (only strings are allowed but I am hoping storing base64 encoded strings would work at least for small images). However, how do I serve the image via http url that points to my server without a server round trip? I saw the interesting article at http://hacks.mozilla.org/category/fileapi/ but that would work only in firefox and I need to work on all latest browsers (at least the ones supporting HTML5 local storage)
Use flash SharedObjects. OK, this would have been good - the only thing is I am not sure where to start. Snippets of actionscripts to do this are scattered everywhere but I do not know how to use those scripts in an actual html page:) I do not need to create any movies or anything - just need to store an image and serve it locally. If I go this route, I would also use it to store other "strings" locally. If you suggest this, please give me the exact steps (could be pointers to other web sites) on how to do this. I would like to avoid paying for any flash development environment software ideally:)
Thank you!
You could use a data URI to display the file. Essentially you use the image data (plus a prefix) as the src attribute of an image element. If you already figured out how to read the file into memory as a base64 encoded string, using a data URI would probably be the easiest way to display the image.
OK
I was able to implement the following solution (just in case anyone has any comments or would like to know the answer)
wrote server side code that takes an image and returns its base 64 encoded version.
used the hidden iframe trick to get the base 64 encoded data into an iframe and stored it into the image by dynamically changing the image source to the data uri
For the "hidden iframe trick" - in case you are interested, there is a good article at (see www.openjs.com/articles/ajax/ajax_file_upload/response_data.php)
The only limitation is that IE does not work with images whose base 64 encoded string exceeds 32K - see http://msdn.microsoft.com/en-us/ie/dd578309.aspx. Note that only IE 8 works - IE 7 does not support data uri I believe.