CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Hybrid View

  1. #1
    Join Date
    Apr 2004
    Posts
    11

    Printing Crystal report thro' ASp.Net

    Hi,

    I am develpoing an intranet application using ASP.Net which uses crystal reports. The IIS is installed in my machine. But the printer is connected to some other. When I try to take printout it raises an error as:

    Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user.

    The code I used is:

    crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
    crpt.PrintToPrinter(1, False, 1, 1)

    Note: This code works when I connect & install the printer to my machine.

    Can any one please say me how to fix this problem.

    Thankyou for your reply.
    reg
    Banupriya

  2. #2
    Join Date
    Apr 2004
    Posts
    11

    re: printing crystal report using asp dot net

    Hi,

    I am sending this again since I don't get any reply yet.

    I am develpoing an intranet application using ASP.Net which uses crystal reports. The IIS is installed in my machine. But the printer is connected to some other. When I try to take printout it raises an error as:

    Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user.

    The code I used is:

    crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
    crpt.PrintToPrinter(1, False, 1, 1)

    Note: This code works when I connect & install the printer to my machine.

    Can any one please say me how to fix this problem.

    Thankyou for your reply.
    reg
    Banupriya

  3. #3
    Join Date
    Apr 2004
    Posts
    10
    Hi..

    Use this
    crpt.PrintOptions.PrinterName = "hp LaserJet 1300 PCL 6"
    instead of crpt.PrintOptions.PrinterName = "\\banupriya\hp LaserJet 1300 PCL 6"
    crpt.PrintToPrinter(1, False, 1, 1)

    It will work.
    Printer should be installed on your machine and printer may be anyother machine in network.

  4. #4
    Join Date
    Apr 2004
    Posts
    11
    Hi

    I tried with

    crpt.PrintOptions.PrinterName = "hp LaserJet 1300 PCL 6"

    or

    crpt.PrintOptions.PrinterName = "hp LaserJet 1300 PCL 6 on Bharath"

    or

    crpt.PrintOptions.PrinterName = "\\Bharath\hp LaserJet 1300 PCL 6"

    Since the printer is installed in machine Bharath and is connected to the network with the share name: hp LaserJet 1300 PCL 6 on Bharath.

    But the print is not functioning.

    It raises the error:

    Error in File C:\DOCUME~1\BANUPR~1\ASPNET\LOCALS~1\Temp\temp_72da1e2d-ec31-4955-8666-378f164f2274.rpt: Invalid printer specified.


    by
    Banupriya

  5. #5
    Join Date
    Apr 2004
    Posts
    10
    Hi , you are missing something somewhere.

    Steps
    1) Go to My Computer - > Control Panel - > Printers ->
    Now see there is any printer connected to your machine ?
    If yes then there is printer name , Copy that name to your code.

    If no printer is connected to your machine the connect it with 'Add Printer' (Ask it support how to add printer in yoyr machine)

    No you will get Printer Name.

    Use that name in your Code.

    It will Works 101%

    I was facing same problem for 2 days then i got this solution.

    If you have problem ask me.

  6. #6
    Join Date
    Apr 2004
    Posts
    11


    Hi

    I have the printer set to default named hp LaserJet 1300 PCL 6 on Bharath

    hence I specified the printer in code as

    crpt.PrintOptions.PrinterName = "hp LaserJet 1300 PCL 6 on Bharath"

    is it correct?

    but on executing, I get the error msg

    Error in File C:\DOCUME~1\BANUPR~1\ASPNET\LOCALS~1\Temp\temp_bbd09d23-df2d-49fc-aef3-448285e29365.rpt: Invalid printer specified.

    by
    Banupriya

  7. #7
    Join Date
    Apr 2004
    Posts
    10
    Pl go step by step

    Steps
    1) Go to My Computer - > Control Panel - > Printers ->
    Now see there is any printer connected to your machine ?
    If yes then Press F2 and copy that name to your code.

    If no printer is connected to your machine the connect it with 'Add Printer' to your machine and do the same procedure press F2 and copy name of printer.

    Use that name in your Code.
    It will really work

  8. #8
    Join Date
    Apr 2004
    Posts
    11
    hi

    I tried the same way but the error is again & again raising.

    Note: F2 key press has no effect.

    by
    Banupriya

  9. #9
    Join Date
    Apr 2004
    Posts
    10
    Steps
    1) Go to My Computer - > Control Panel - > Printers ->

    Now Tell me what are there after clicking to Printer ?

    Please give me all names.

  10. #10
    Join Date
    Apr 2004
    Posts
    11
    hp LaserJet 1300 PCL 6 on Bharath

    and

    Add Printer


    Note: The printer name is hp LaserJet 1300 PCL 6 connected to the system Bharath. My machine name is Banupriya

  11. #11
    Join Date
    Apr 2004
    Posts
    10
    Do one thing ,
    Delete that printer hp LaserJet 1300 PCL 6 on Bharath from your Printer.

    Now add one again using 'Add printer' with name only "hp LaserJet 1300 PCL 6" Take help from your compan's IT Support people. The name must be "hp LaserJet 1300 PCL 6"
    Then try by using Printer Name name = "hp LaserJet 1300 PCL 6"
    It will work.

    On my machine printer name is "hp LaserJet 1010" and "Add Printer" . Its working properly when i used name = '"hp LaserJet 1010"

    Try out this.

  12. #12
    Join Date
    Apr 2004
    Posts
    10
    Hello Did you get solution
    Do one thing

    In Control Panel -> printer

    Right click on this 'hp LaserJet 1300 PCL 6 on Bharath'
    Go to Peoperties -> General tab - >
    Change this name 'hp LaserJet 1300 PCL 6 on Bharath' to
    'hp LaserJet 1300 PCL 6' , Dont keep any blank spaces to left and right.

    And try to use this name to printer name.

    Thanks
    Vilas Meshram

  13. #13
    Join Date
    May 2004
    Posts
    1
    I think you didn't understand the problem. I have exactly the same.
    It work fine with a local printer but if you want to use a printer on the network it doesn't work !
    If he change the name of the network printer in the parameters his computer won't recognize the printer after this.
    I think it's a bug (one more !!) of crystal !!
    But if someone has the solution it could be great !!

    Thanks

    Nicolas

  14. #14
    Join Date
    Jun 2004
    Posts
    1

    Crystal Report

    The problem is a security problem.

    I copied for you the relevant section from this document by crystal solutions:
    http://support.businessobjects.com/c...p_printing.pdf

    Printing the report on the server side
    (PrintToPrinter method)
    Server side printing results in the report being generated on the Web Server and
    being printed to a printer that is installed to the Web server.
    Printing to a printer installed to the Web server requires that the process under
    which ASP.NET is running have sufficient permissions to access Network
    printers. In order to provide these permissions, changes to the account that the
    ASPNET worker process runs under are necessary as well as changes to the
    registry on the Web server.
    By default, ASP.NET runs with the permissions of the local “machine”
    (ASPNET account for the ASPNET worker process) account. In order to
    achieve network printing through IIS (Internet Information Services), the
    Framework should be run under the local SYSTEM account. To make this
    change, it is necessary to edit the default configuration settings in the
    Machine.config file. This file is located by default at:
    C:\WINNT\Microsoft.NET\Framework\<VersionNumber>\CONFIG\
    Where <VersionNumber> is the version of the .NET Framework installed to the
    computer. The account setting is contained within the <ProcessModel> tag of
    this file. The default setting for the account is:
    userName="machine" password="AutoGenerate"
    This can be changed to:
    userName="SYSTEM" password="AutoGenerate"
    Then save the file.
    It is now possible to give the local SYSTEM account on the server permissions
    to print. If the printer is a network printer, we must expose the network printer
    to the local SYSTEM account. The reason behind this is that when a printer is
    installed to a computer, the settings for this printer are stored in the registry
    under the HKEY_CURRENT_USER registry hive (Registry file). The IIS
    process will never use this registry hive since it always runs under the context of
    the local SYSTEM account and cannot be logged onto a server as a “Current
    User”. By default, the SYSTEM account does not have any printers set up in
    the registry. There are two Microsoft knowledge base articles, Q152451 and
    Q184291 that explain how to expose the printer settings to the System account.
    Both of these articles require editing the registry on the Web server and copying
    the printer settings from the HKEY_CURRENT_USER hive to the
    HKEY_USERS/.DEFAULT hive

  15. #15
    Join Date
    Aug 1999
    Location
    India, TamilNadu, Chennai.
    Posts
    269

    Solution for Printer Problem

    Dear Friends,

    Iam sorry for the delay reply.

    1. robinash, what you says is correct, the network printer won't recognize without network path.

    2. if you want to view the installed printer list, refer the following code.

    (But It's not a bug).


    Code:
    Imports System.Drawing.Printing
    
    Dim fwPrintSetting As new System.Drawing.Printing.PrinterSettings
    Dim nCnt As Integer
    
            With cboPrinter.Items
                For nCnt = 0 To (PrinterSettings.InstalledPrinters.Count - 1)
                    .Add(PrinterSettings.InstalledPrinters.Item(nCnt))
                    fwPrintSetting.PrinterName = fwPrintSetting.InstalledPrinters.Item(nCnt)
                Next
            End With
    3. The reported error is

    "Error in File C:\DOCUME~1\banupriya\ASPNET\LOCALS~1\Temp\temp_2924ba53-898a-4038-a402-b1504cbdbe18.rpt: Request cancelled by the user . "

    a. Make sure the security permissions are correctly.

    b. Do Testing printout from other reports.

    Thanks.

    Originally posted by robinash
    I think you didn't understand the problem. I have exactly the same.
    It work fine with a local printer but if you want to use a printer on the network it doesn't work !
    If he change the name of the network printer in the parameters his computer won't recognize the printer after this.
    I think it's a bug (one more !!) of crystal !!
    But if someone has the solution it could be great !!

    Thanks

    Nicolas
    Please avoid sending emails to my personal mail:
    write your doubts as thread in Codeguru
    Crystal Reports Forum
    .

    This will help all people having similar matters, and will let people who know solutions on the specific topic
    share their knowledge.

    Visit my company web site (Qmax Test Equipments Private Limited)

    Yours friendly,
    K.Babu

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured