Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

HTML-file to pdf

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morten Snedker - 23 Aug 2007 09:23 GMT
From an aspx I wish to grab a html-file from the same directory and
push it to PDF via Response.ContentType = "application/pdf".

Alternatively the html-content can be held in a string variable, which
can be used instead.

Can someone push me in the right direction as to how?

Regards /Snedker
Mark Rae [MVP] - 23 Aug 2007 09:55 GMT
> From an aspx I wish to grab a html-file from the same directory and push
> it to PDF via Response.ContentType = "application/pdf".

In order to stream a PDF file, you need to actually have a PDF file to
stream in the first place - you can't e,g, open an HTML file and just
"pretend" it's a PDF by changing the MIME type...

There are many utilities which will convert an HTML file to PDF:
http://www.google.co.uk/search?sourceid=navclient&aq=t&hl=en-GB&ie=UTF-8&rlz=1T4
GGIH_en-GBGB220GB220&q=HTML+PDF+convert


> Alternatively the html-content can be held in a string variable, which can
> be used instead.

using System.IO;

string strFileContents = String.Empty;
using (StreamReader objSR = new StreamReader("TestFile.txt"))
{
   strFileContents = objSR.ReadToEnd();
}

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Morten Snedker - 23 Aug 2007 11:37 GMT
Thanks for your response. I came across http://www.primopdf.com/ which
will generate the PDF. It's quite free, which is the way I prefer it.  :-)

Regards /Snedker
Mark Rae [MVP] - 23 Aug 2007 12:05 GMT
> Thanks for your response. I came across http://www.primopdf.com/ which
> will generate the PDF. It's quite free, which is the way I prefer it.  :-)

The desktop version which installs a printer driver and allows PDF
conversion that way is free - I don't think any of the server-side versions
are, though...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

bruce barker - 23 Aug 2007 16:32 GMT
almost all the html to pdf converters work by loading the html in an ie
instance, then having ie print to a fake printer  via the pdf driver and
capturing the printer output.

there are some converters that do the paring, but they are limited to
simple html or more often simple xhtml.

-- bruce (sqlwork.com)

>> Thanks for your response. I came across http://www.primopdf.com/ which
>> will generate the PDF. It's quite free, which is the way I prefer it.  
[quoted text clipped - 3 lines]
> conversion that way is free - I don't think any of the server-side
> versions are, though...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.