We have a requirement to print HTML documents using a .NET program.
We are using the following code to print. The print needs to happen in the background and should not ask for a print dialog. The problem we are facing is in case of multiple frames, multiple pages are being printed. Also, we only need first page to be printed. With this program we are not able to control these options.
I'd appreciate ideas on how we can control the number of pages while printing and adjusting the frames to print as they are on screen.
using System;
using System.Collections.Generic;
using System.Text;
using SHDocVw;
using System.Threading;
namespace htmconverter
{
class Program
{
static void Main(string[] args)
{
object missingValue = Type.Missing;
InternetExplorer iexp = new InternetExplorer();
iexp.Navigate("file://c:/c.mht", ref missingValue, ref missingValue, ref missingValue, ref missingValue);
// while(OLECMDID.OLECMDID_PRINT!=OLECMDF.OLECMDF_SUPPORTED)
iexp.ExecWB(OLECMDID.OLECMDID_PRINT, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref missingValue, ref missingValue);
Thread.Sleep(2000);
}
}
}