[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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.
0
Richard_Clayton
Asked:
Richard_Clayton
  • 2
3 Solutions
 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now