locked
Oskariok Data extension print preview RRS feed

  • Question

  • When using Printing.PrintPreview under Windows 7, I get a error dialog "Cannot read from a closed TextReader"

    I can see a preview of the document but get the dialog when I click the print button and the document (a text file) does not print.

    The Printing.Print works fine.

    Maybe a bug?

    Wednesday, February 9, 2011 8:16 PM

Answers

  • You don't have caused any troubles but this bug is very strange. I have never had any troubles with Print Preview on my Windows 7 and it uses default .Net print preview dialog so it shouldn't have any bugs.

    I have made some small compatibility changes to Data Extension 0.9.1.3 so maybe this bug will go away with them.


    Sorry My Bad English
    • Marked as answer by SFC-P33A Thursday, February 17, 2011 5:48 AM
    Wednesday, February 16, 2011 1:22 PM

All replies

  • I haven't heard of this bug, so I'll check it out then report on it.

    ~~AirWaves!!~~
    Thursday, February 10, 2011 12:53 AM
  • Try using this code, but first create a file under C:\Test.txt

    GraphicsWindow.Show()
    printfont = Printing.CreatePrintFont("printfont", 20, "Black")
    Printing.PrintPreview("C:\Test.txt", printfont)

     


    ~~AirWaves!!~~
    Thursday, February 10, 2011 2:11 AM
  • Still get the same dialog box, it will show the document in the print preview but when I click on the print button,  I get this;

    "Unhandled exception has occured in a component in your application: If you click Continue, the application will ignore this error and attempt to continue.

    Cannot read from closed TextReader."

    Clicking continue just brings it back to the print preview and clicking print again brings up the dialog box again, never prints the document.

    I'm wondering if other people using Windows 7 have had this problem or is it my computer?

    Friday, February 11, 2011 4:11 PM
  • I am using Windows 7, and I am not getting the same results. Maybe there is something wrong with your printer, or it is not compatible with this library thing. Maybe there is a setting on your printer you can change in the control panel.
    ~~AirWaves!!~~
    Friday, February 11, 2011 8:46 PM
  • hmmm, I tried the same code on my laptop running Windows XP, and got the same dialog box, even trying different default printers. I will see if I can try it on another computer/system.
    Saturday, February 12, 2011 4:55 AM
  • I think the problem may be because I'm not using the latest version of the Data Extension, I went to the Oskariok blog web site to get the latest but when I click download button, It is blocked by other information, is the site down?
    Monday, February 14, 2011 6:32 PM
  • Site is working and Print Preview should work in older versions. Are you sure you have access to read your file? And can you see your printer from control panel.

    For downloading go to http://download.dataextension.webatu.com/Data.exe . There you must fill recaptcha to download file. You also must have javascript enabled.

     


    Sorry My Bad English
    Monday, February 14, 2011 9:23 PM
  • Hi Oskariok,

    I went to your website and down loaded the latest version, thank you (I didn't have the complete address in my prior post when I was attempting download before (http://dataextension.webatu.com/).

    After downloading and trying to install by double clicking, I got a dialog box reading:

    "C:\Users\stevec\Desktop\Data.exe is not a valid Win32 application."

    I will try it on my home computer later this evening. I am currently using version 0.9.0.9 Do I have to un-install this version first?

    Yes I have access to read file and I can see the printer from the control panel. What is strange is that I have tried this on 3 different computers with the same dialog box. Perhaps it's something in my program?

    Here is code that will not will not print using printing.printpreview but will print using printing.print.

    'DIALOG FOR  PRINT
    Path = Program.Directory
    ItemNo = "T1"

    'Sub QuickPrint
    Qprint = Dialogs.ShowMessegeBox  ("Print this Item " + ItemNo + " ?","QUICK PRINT","OkCancel","Question")
    If Qprint = "OK" then
      'GraphicsWindow.BrushColor = "khaki"  USED IN ELSEWHERE PROGRAM
      'GraphicsWindow.FillRectangle (466,0,37,37) USED IN ELSEWHERE PROGRAM
      'GraphicsWindow.DrawResizedImage (QuickPrintIcon,472,8,15,15) USED IN ELSEWHERE PROGRAM
      GraphicsWindow.BrushColor  = "Black"
      If ItemNo = "" then
        Dialogs.ShowMessegeBox ("Need an item number!", "No Item Number","OKCancel","Exclamation")
      else
        SingleItemPrint ()
        Singleitemfont = Printing.CreatePrintFont  ("Arial",10,"Black")
        Printing.PrintPreview  (SingleItem, SingleItemfont)
        'Printing.Print (SingleItem, SingleItemfont)
      endif
    endif
    'endsub

    Sub SingleItemPrint
      SingleItem = (Path +"\" + ItemNo + ".txt")
      File.WriteContents (Path +"\" + ItemNo + ".txt","")'Creates blank file
      File.WriteLine (Path +"\" + ItemNo + ".txt",1"Line One")
      File.WriteLine (Path +"\" + ItemNo + ".txt",2"Line Two")
    EndSub

    Thanks for your input.

    Steve

     

    Tuesday, February 15, 2011 1:24 AM
  • Yes, I have gotten this error message before. But something I did happened to fix it.

    ~~AirWaves!!~~
    Tuesday, February 15, 2011 2:43 AM
  • I was able to install the latest Data extensions on my home laptop running XP.

    I tried the following program on my home laptop; I still get the error dialog using printing.printpreview but not when using printing.print. The only difference I could see between the two (other than the print preview window) is that when using printing.printpreview, there is a small print dialog box that briefly appears before the print preview window. The small dialog box reads 'printing1 of 1" I think, it happens so fast it is hard to read (it was so fast on my work computer, I never noticed it). The small dialog box seems to come later when using printing.print, maybe not the issue but it is the only diffence I see (other than the print preview window) when running the program.

    'DIALOG FOR  PRINT
    Path = Program.Directory
    ItemNo = "T1"
    GraphicsWindow.Show ()
    SingleItemPrint ()
    Singleitemfont = Printing.CreatePrintFont  ("Arial",10,"Black")
    Printing.PrintPreview  (SingleItem, SingleItemfont)
    'Printing.Print (SingleItem, SingleItemfont)

    Sub SingleItemPrint
      SingleItem = (Path +"\" + ItemNo + ".txt")
      File.WriteContents (Path +"\" + ItemNo + ".txt","")'Creates blank file
      File.WriteLine (Path +"\" + ItemNo + ".txt",1"Line One")
      File.WriteLine (Path +"\" + ItemNo + ".txt",2"Line Two")
    EndSub

     

    One more thing that may help, in the details of the error dialog box is this;

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

    Tuesday, February 15, 2011 3:57 AM
  • I downloaded the program again and it installed fine, for some reason the first time I downloaded it the file size was smaller . My apologies for any inconvenience I may have caused.

    Tuesday, February 15, 2011 11:17 PM
  • You don't have caused any troubles but this bug is very strange. I have never had any troubles with Print Preview on my Windows 7 and it uses default .Net print preview dialog so it shouldn't have any bugs.

    I have made some small compatibility changes to Data Extension 0.9.1.3 so maybe this bug will go away with them.


    Sorry My Bad English
    • Marked as answer by SFC-P33A Thursday, February 17, 2011 5:48 AM
    Wednesday, February 16, 2011 1:22 PM
  • thanks for the reply, Ill be sure to download it and give it a try.
    Thursday, February 17, 2011 6:00 AM