I have files in e pub format. I have to show their contents to the user. How do I read them in asp.net? Can it be done through javascript?
-
whatever may be the format you can use stream reader for that if you can see the contents in notepad – Pratik May 19 '12 at 11:30
-
@PratikGupta Epub is actually Zip file format. – user1509 May 19 '12 at 11:33
-
any comments on my answer before the bounty runs out? – Peter Jun 05 '12 at 16:34
3 Answers
Authoritative? What could be better then a StackOverflow answer? I started from this question ( https://stackoverflow.com/questions/4870594/is-there-a-c-sharp-epub-library ) and gleaned a few usefull links:
- Usefull information on displaying text in a web browser using javascript so it paginates nicely: HTML book-like pagination
A C# open source library for reading ePub files, the sample code on the home page includes how to get the contents as HTML: http://epubreader.codeplex.com/
There are other libraries which may come in handy if the ePub reader library on codeplex doesn't pan out: http://sourceforge.net/projects/epubsharp/, and http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx
You can't do this with just JavaScript of course, you'll have a server side like a web service or code behind on your asp.net webpage which opens the epub file, extracts the contents as HTML and returns it to the client, but I think there is enough here to get you started.
-
@explorer - I just tried it, from the copy of the link you provided, and it opened fine. – Peter Jun 29 '12 at 13:54
-
Just to add then i suggest the steps:
Step 1: unzip the file using C#,.net code having some third party library.
Refer : recommend a library/API to unzip file in C#
Step 2: Check whether in the extracted folder there is only one file or more.
Refer: How do I find out how many files are in a directory?
Step 3 :Read the file using stream reader in c#.net
Refer: http://msdn.microsoft.com/en-us/library/aa328963(v=vs.71).aspx
Epub file is actually a zip archive that contains
- xml files for meta data, table of contents etc
- xhtml or dtbook (xml) + gif, jpeg, png, svg + css for content
To be able to display epub you will have to be able to handle all of the above. Here Reading ePub format you'll find what you have to do to open epub step by step - it's an example for iphone, but it should be enough.