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. Web Development
  3. SharePoint
  4. How to print a file(could be word, pdf or infopath form) from a URL using c# code

How to print a file(could be word, pdf or infopath form) from a URL using c# code

Scheduled Pinned Locked Moved SharePoint
helpcsharptutorial
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.
  • 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

    N 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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      bin_bin1 wrote:

      My code is running in an ashx handler

      You do understand if this code is in an HTTP Handler it will only execute on the server correct? If you need to access SharePoint outside of the environment then you should be using the SharePoint Web Services or with 2010 the Client Object Model.

      bin_bin1 wrote:

      I am really confused.

      That makes two of us


      I know the language. I've read a book. - _Madmatt

      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