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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to print a file (word doc, pdf or infopath form) from a URL using code?

How to print a file (word doc, pdf or infopath form) from a URL using code?

Scheduled Pinned Locked Moved C#
helpcsharptutorialquestion
2 Posts 2 Posters 3 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.
  • B Offline
    B Offline
    bin_bin1
    wrote on last edited by
    #1

    Hello there, I am trying to print a file(could be word, pdf or infopath form) from URL using c# code. But I always got "The parameter is incorrect" error. The following is the code that I used. WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); Process printJob = new Process(); printJob.StartInfo.FileName = @"http://testsrv/test1/Shared Documents/test.txt"; printJob.StartInfo.UseShellExecute = true; printJob.StartInfo.Verb = "print"; printJob.Start(); I am sure the URL is correct. I also tried to download the file to local drive and use the local full file path instead. In that case, it doesn't print and there is no exception either. I am really confused. Please help. My code is running in an ashx handler. I don't know whether that makes different or not. Thank you very much in advance. Bin

    _ 1 Reply Last reply
    0
    • B bin_bin1

      Hello there, I am trying to print a file(could be word, pdf or infopath form) from URL using c# code. But I always got "The parameter is incorrect" error. The following is the code that I used. WindowsImpersonationContext wic = WindowsIdentity.GetCurrent().Impersonate(); Process printJob = new Process(); printJob.StartInfo.FileName = @"http://testsrv/test1/Shared Documents/test.txt"; printJob.StartInfo.UseShellExecute = true; printJob.StartInfo.Verb = "print"; printJob.Start(); I am sure the URL is correct. I also tried to download the file to local drive and use the local full file path instead. In that case, it doesn't print and there is no exception either. I am really confused. Please help. My code is running in an ashx handler. I don't know whether that makes different or not. Thank you very much in advance. Bin

      _ Offline
      _ Offline
      _Erik_
      wrote on last edited by
      #2

      bin_bin1 wrote:

      My code is running in an ashx handler

      So your code is running on the server, isn't it?

      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