Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. printing html file without printdialog show up

printing html file without printdialog show up

Scheduled Pinned Locked Moved C#
htmlquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pnpfriend
    wrote on last edited by
    #1

    Hi there, Is there anyway that I can print the html file from commandline without showing print dialog? I tried ShellExecuteEx and it does nothing. Thank you.

    T 1 Reply Last reply
    0
    • P pnpfriend

      Hi there, Is there anyway that I can print the html file from commandline without showing print dialog? I tried ShellExecuteEx and it does nothing. Thank you.

      T Offline
      T Offline
      turbochimp
      wrote on last edited by
      #2

      Have you looked at PrintDocument? ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref8/html/T_System_Drawing_Printing_PrintDocument.htm Example:
      class Program { static Font printFont = new Font("Arial", 10); static void Main(string[] args) { PrintDocument doc = new PrintDocument(); doc.PrintPage += new PrintPageEventHandler(doc_PrintPage); doc.Print(); } static void doc_PrintPage(object sender, PrintPageEventArgs e) { float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; float yPos = topMargin + (printFont.GetHeight(e.Graphics)); // In the line below, 'Hello' would be replaced with the next line from // whatever you were trying to print. // It's actually a little more involved, but not terrible. e.Graphics.DrawString("Hello", printFont, Brushes.Black, leftMargin, yPos, new StringFormat()); e.HasMorePages = false; } }

      The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups