Sending HTML file with Images through email IOS - c#

This is more of a general question about whether or not its actually possible to achieve what I want.
The basis is that my app allows the user to fill out various tables of data for a preventative maintenance check sheet. They can also attach images to this sheet which saves to the temporary storage on the IOS app. Once its complete they then press a button which generates a HTML document through a StreamWriter. Through this StreamWriter I have created, the images are also appended through URL references to the images in the temporary folder.
The HTML file (Generated Form) is then presented to the user using a WebView. Once the user has checked all the information, they then press a button which presents a MailViewController.
The HTML file (Generated Form) is then automatically attached and once the email has been entered you press send and everything works as it should.
The problem I am now having is that im not sure if its possible to keep the images in the html document. Once you open the HTML file on the receiving device, the images no longer loads because they no longer exist according to the HTML file.
So basically is it possible to keep the images in the HTML file once opened on the receiving device.
Sorry for the long description but its needed so you get an understanding of what I am actually doing. All the code I have written works as it should but just wanted to know if this is possible or not.
Thanks
Jamie

Use base 64 encoded strings for the images and it should work. Since the images would be passed along with the html

Related

How do I Open a file directly(from the binary data saved in db), when I will click a link?

I am working on a file uploading functionality using ASP.NET, C# and telerik. I am using telerik:RadAsyncUpload control. I already convert the file to byte array and save in the SQLServer Database.
On update page, I need to open file directly(from the binary data saved in db), when I will click a link. I need to Open that file in separate browser tab/window. I do not want to save file Physically on any local drive while retrieving it.
Please help me out.
What I have tried?
For time been, I am saving that binary data in a blank file located at some local drive and then attaching it to that link. but I do not want to save file Physically on any local drive while retrieving it. I want .....when user will click link binary data will directly flush on separate browser tab and he can view the file.
Create a handler (arbitrary one or an aspx page, whatever you find easier) that will read the database (e.g., based on a querystring argument) and return the appropriate response (via the Response object, e.g., Response.BinaryWrite()).
Note that you should set the appropriate headers and that depending on the type of file you return the browser may prompt the user to open/save it instead of opening it inline. You have some control over that via the content-disposition HTTP header, but it is ultimately up to the browser.
Also, you may want to use a RadWindow to open that handler to keep browser popups to a minimum to reduce the risk of them getting blocked by the browser.

How to show preview of image being uploaded before actually sending it to server

I have a FileUpload control in my aspx page and I want to display the image selected before postback so that user confirms the image to upload.
You can use this AJAX Control Toolkit Control for Image Confirmation.
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx
What you're looking for would require a pure client-side solution, which I do not think is possible since they do not have access to the file system(under normal circumstances).
Note that using AJAX requires actually sending the file to the server first.
This Can be done VIA HTML5 now,
http://www.html5rocks.com/en/tutorials/file/dndfiles/
When the upload is selected you want to read the file with
readAsBinaryString
Then you would need to turn that binary to Base64 so you could display it on the page,
http://www.webtoolkit.info/javascript-base64.html
Then you will need to put it into an img tag on the in the src E.G
<img src="data:{image/mime_type};base64,{base64_binary_data}" width="100" height="100" />
Where {image/mime_type} is the mime type of the image they have uploaded E.G image/png, image/jpg
And {base64_binary_data} is the readAsBinaryString after it's gone though the base64 conversion
It's not possible through HTML. But it may be possible using flash/silverlight.
I say this because I remember coming across an issue when I wanted to know up front how big a file was before the user uploaded it. Html doesn't give you the ability to know this, the user must upload the whole file before you can say how big it is.
However, the workaround was to use flash because flash seems to have permissions to grab data about a file from the local disk before sending it to the server (after the user selects the file of course). Since it can grab the filename, size, etc then I imagine you'll be able to grab the image data too and then display it.
You're going to need to use flash or silverlight to do that.
Here's an article where it's explained how to do that with flash:
http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the-filereference-class-in-flash-player-10/

Server-side printing in C#/ASP.NET

On the server that my application is being run on, a virtual PDF printer is being installed (don't know much about this yet, except it's from Adobe), and my application needs to use this 'printer' to create PDF's from HTML pages (a GridView mostly), and then redirect the user to the URL of the where the PDF is stored.
I've been looking at the PrintDocument object in System.Drawing.Printing, however I've read that you can't simply feed this a HTML page. What are my choices? The easiest option would be to be able to 'print' a given HTML page (choosing what and what not to print using CSS), but from what I've read this is fairly difficult, so I'm thinking about somehow constructing whatever object PrintDocument needs programatically, if that makes sense.
Any ideas on how I should do this?
there are some free/cheap libs for creating pdfs on the fly. I've used itextsharp before and it worked pretty well. Takes a bit of time to get up to speed in how it works but I'd suggest checking it out.
There are also printing services like Neevia DocConverter that will monitor a folder and auto convert whatever you put in the folder to a pdf, jpg, etc. you can set it up so that if you drop a url shortcut in the folder it will render the webpage at that url to pdf. it's a bit more of a pain if you want to do realtime rendering but works excellent for generating mass reports in batches that you want to post up to a website or email later.

Creating RTF and printing as PDF

I'm trying to do the following(in this order):
Create a Rich Text Format file
Add company image to the top of page and write the data to the RTF
Print the RTF file as PDF through CutePDF or other printer that are
able to convert my RTF to a PDF and thereby save locally on the users PC - The pdf should be saved at a location without prompting the user
After this is done, the RTF file should be deleted and return a message, that confirms the action is successfully done.
Other stuff:
The website where these actions take place, are not meant to host the outcome(the PDFs) but these are supposed to be saved on the users PC. (is this possible without prompting the user to save it? i imagine the website would write directly to the users PC instead of doing the work on the website and save it and then transfer the file to the PC)
OBS: i do not wish to use any 3th party program/DLL other then the converter like cutePDF :)
My question is quite simple i hope :)
Will this work?
No. You can send the PDF back to the user but the user will either be prompted to download the file or it will open automatically (depending on the user's configuration and the response headers you're sending). Without using some sort of plugin you can't save any files directly to the user's computer.
If it was possible to write a file directly to the user's the world as we know it would have ceased to exist. Cities would lie in ruin as idle youtube commentators roamed the streets in violent gangs yelling "FIRST" and engaging in brutal and pointless gang wars. A generation of youth superbly trained by video games would manage to destroy civilization in a matter of days. Fortunately civilization would eventually be rebuilt by Minecraft players but it would take time.
If that functionality is really vital I would suggest looking at a plugin.

Quick & Easy PDF Viewer Ideas

This question has been asked several times but my situation is a little different.
I have a web application written in C# where I get a string value passed to this page I'm working on. This string value represents a filename of a PDF file I need to display on this page. I'm supposed to have a left panel where I have some information displayed, and a right panel showing the contents of a PDF file. I'm using a simple table here to separate the panels. All PCs should already have Acrobat Reader installed.
My question is simple. How can I display the contents of the PDF file within this table? I don't need anything fancy. It has to be free and simple enough for a newbie like me to set up. It could even be written in jQuery/AJAX, if there even is a way.
I've looked at a Webbrowser control within an ASP.NET page, but it looks way too complicated for a simple viewer. I looked at Webparts, but I'm not sure if that's doable in a non-Sharepoint environment. Suggestions?
Have you tried the object tag? More ideas are here Make PDF display inline instead of separate Acrobat Reader window

Categories