Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I currently have an App that outputs part inspection results from a database to a text file for printing/viewing. The report contains fields like, nominal size, actual size, error, tolerance, etc. The inspection results are mostly displayed in tabular format but there is also some non-tabular data. I am currently creating the report file using the standard printline commands with padding added in to align the data where required. When I am done, I either display or print the report using the standard NotePad app.

When I first created the report format, I designed it around a certain font type/size. If the font in NotePad is set to that particular type/size, the report look proper. If, however, some user gets in and changes the font type/size via the NotePad GUI, then the next person viewing the data will not see the report in the proper format. With this in mind, I am trying to come up with a fool proof way to prevent this.

What I have tried:

I have read online that there might be ways of preventing the user from editing the font in NotePad via the registry but I don't go down that route at the moment. Also, these computers are running still running Windows 2000 OS with Dot.Net 2.0 so I don't want to load or use any non standard software if it is all possible (Sorry no MS Excel or MS Word). I would like to see what other options I have to accomplish my task? I have researched online and found out that I can output the raw data directly to a printer using various Win32 API calls. I think this might work for printing but how would I go about viewing the data for cases I just want to look at the data? I have also seen a couple of articles about using print document. I created a custom chart once using this option but it seems like it might be a little overkill for just basic text data. Are there any other options that I may have missed?
Posted
Updated 9-Mar-17 3:27am

1 solution

As you have an app for viewing this data then I would avoid using NotePad (or any other editor) for viewing/printing - you've already discovered why :-)

When faced with a similar issue I generated HTML reports using XML and XSLT.
This gave me full control over layout, font etc but enabled the reports to be easily altered when required - this will not be the case with using Win32 API calls.

You can load these directly into the default browser for viewing or printing or do as I did and use the WebBrowser control in your app.

(Warning - don't do as I did and learn XSLT 2.0 ... it doesn't apply to Win2000)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900