Want to print an HTML email

Having downloaded emails such as newletters or brochures (HTML, many pictures etc) I want to be able to print them out, but include some custom header information (our internal email number, who printed it etc).

Previuosly, I have used a TWebBrowser to load the file in, then print from there, not ideal as there is a lack of control and no option for header \ footer.
I have also converted the document into an image and printed from there - even less perfect.

I typically use QuickReport, so an answer involving that would be ideal.
If I have to buy a component in order to deal with this then I will.
Richard_ClaytonAsked:
Who is Participating?
 
saravananvgCommented:
Hello Sir,

   You can print a html file with certain modifications to it as follows.

procedure printreport;
var
 F:TextFile;
begin
  AssignFile(F,'C:\a.htm');
  RewriteFile(F);
  //Copy and paste your html source code using and rewrite it as follows for eg
  Writeln(F,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' );
 Writeln(F,'<head>');
  Writeln(F,' <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
  Writeln(F,'<title>Delphi Programming: Want to print an HTML email</title>');
  Writeln(F,'<link href="/images/ee.ico" rel="shortcut icon">');
  Writeln(F,'<link href="/scripts/ee_cd11083aff598d3b113980a519d4b987.css" rel="stylesheet" type="text/css">
  Writeln(F,'<script src="/scripts/eeSubs_88fcb4c868a5c02661171720cf388b79.js" type="text/javascript"></script>
Writeln(F,'<meta name="description" content="Having downloaded emails such as newletters or brochures (HTML, many pictures etc) I want to be able to print them out, but include some custom header information (our internal email number, who...">');
Writeln(F,'</head>');
Writeln(F,'<body>');
CloseFile(F);
end;

with regards,
padmaja.
0
 
Eddie ShipmanAll-around developerCommented:
You could use an IHTMLDocument2 instance to load the file into, then take the document's
body and assign it to a TWebBrowser and modify the HTML to include the header info you
require and then just use the ExecWB way of printing them using the TWebBrower.

If you'd like a sample, I can show you.
0
 
saravananvgCommented:
Hello Sir,

  Kindly let us know whether the sample works fine.

with regards,
padmaja.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.