|
Hi,
I've a problem with daReport concern layout change during print.
I prepared report with few parameters and then I notice, that it prints with different top and left margins on different printers. Now I've to set each x and y coords for each printer I use (add or sub few points specified by user after test print).
Is this bug or I missed something?
best regards
Jaro
btw. great work, anyway
|
|
|
|
|
Hi there, Jaro.
You have noticed well. There is an issue with printer margins within .NET printing classes in .NET 1.1 runtime . It appears that left and top printer hard margins are not taken correctly into account when calculating page margins.
There is an article that deals with this problem : http://www.codeproject.com/csharp/DotNetprinterbounds.asp[^] .
The author even offers a possible solution, but I'm still not sure how to exactly implement it in design mode.
Hope to have some better answer for you soon!
Predrag Dukanac
|
|
|
|
|
Predrag,
Have you had any luck adjusting the print margins to accomodate Microsoft's stupidity? I have been struggling with this issue for approximately 3 weeks now. I have been able to get a rectangle to print correctly, outling the report that is generate with your daPrintDocument, though, I have not been able to produce any sort of usuable text.
I used the PrinterBounds suggestion that you mentioned above, and that seems to work properly, though when your code is reading the xlmNode, there is not PrinterEventArgs being passed, therefore there is no proper way to implement the PrinterBounds solution to yours, at least that I can see.
Your report designer is by far the best one I have seen, and I would really love to use this for my needs, but if I am unable to solve the margins issue soon, I am afraid that I will have to re-write my solution again (this would be my 5th time writing it).
I can get the information to print out correctly, using Rectangular bounds, and then "Drawing" the information in my specified bounds, but I am not sure how to incorporate this to your daPrintDocument.
Any ideas/suggestions?
Also, when I do a print preview, the Header text does not show up (3 parameters set on Report).
Kyle Schultz
C# Developer
Helios, LLC
|
|
|
|
|
Hello, Kyle.
First, let me thank you for nice things you wrote, and second, I appologize for late answer. Unfortunatelly, I'm too occupied these days with my regular job, so I don't mannage to keep track regularly with the project (even for checking messages). I'm afraid I do not have any news at all on this matter ! I did checkout some docs when previous message on printing issue was posted (and wrote some comments, you saw) ... but apart from that, i did pretty much nothing.
Sorry for not being much of a help ... I hope I'll have some spare time in the near future to make this margins thing work ! Meanwhile, like you wrote, any suggestions are welcome.
All the best,
Predrag Dukanac
Predrag Dukanac
|
|
|
|
|
Predrag,
Thanks for the update, I can totally understand being too busy with work. The good news is, since the time that I sent this previous message, I have been able to actually work out the printer margin issue. It required a lot of frustration, a lot of late nights, and almost a whole ream of paper, but I finally got it worked out.
After downloading your daReport project and stepping through it line by line in run-time I was able to pin-point the problem. I took your project, then added in the PrinterBounds class that was supplied on here by Philippe Leybaert here on CodeProject.
http://www.codeproject.com/csharp/DotNetprinterbounds.asp
After including the PrinterBounds class I then modified your code to accommodate a new rectangle, as well as a boolean PreviewMode value. You see, once I got the margins to print out correctly, they then would not Preview correctly (as the PrintPreviewControl doesn't know about the hard margins, and was then shifted to the left and up).
Now, if the document is in PrintPreview mode, the document is viewed correctly, then when you go to print, I use the rectangle that I generated from PrinterBounds and print it invisible on the form (no border) then line up my left and top margins based on the upper left corner of the rectangle. I would be more than happy to send you your project back, updated of course, for you to re-post, as I do not want to post it as my work.
Another change I did was for my own specific reason's and that was to include the xml report file in my DLL (embedded) and then generate it from a stream, I then pass the stream to the setXML function that now looks for an XmlDocument and not the string filename. I am generating the XmlDocument from a System.IO.Stream and then reading it from the System.Reflection.Assembly
I then changed all your functions that were looking for "Graphics g" as a parameter to "System.Drawing.Printing.PrintPageEventArgs e". This allowed me to pass the e variable and get the PrinterBounds using its graphics (it required a PrintPageEventArgs as a parameter, and I couldn't figure a way around it). I then create your "Graphics g" variable from the "e" that I passed.
The only peice of your project that I acutally updated was the StyledTable.cs, TextField.cs, and I believe just the DaPrintDocument.cs, as I have no need for charts at this time.
I hope that you are able to understand what I did to get the entire thing working. Just below is a small code sample of what I did to get it to work (based on the StyledTable.cs file) and if you have any questions about what I did please feel free to email me anytime at kyle@ksdinfusion.com (I have not even started on my website yet, so ksdinfusion.com is only for email at this time).
The best way for you to see what I did to get this working is to do a search for "rBounds" in your project. Hope all is well with your work.
Thanks for creating such a kick @$$ report generator.
###################################################################
Code Sample from drawHeader function (only the first few lines)
##Your Code:
private int drawHeader(Graphics g)
{
int MaxLinesDrawn = 0;
int leftBorder = theRegion.X;
ArrayList[] headerLabels = new ArrayList[columns.Length];
##My Code:
private int drawHeader(System.Drawing.Printing.PrintPageEventArgs e)
{
Graphics g = e.Graphics;
PrinterBounds objBounds = new PrinterBounds(e);
rBounds = objBounds.Bounds;
int leftBorder =0;
if( DaPrintDocument.PreviewMode )
leftBorder = theRegion.X; //MAKES DOCUMENT PREVIEW CORRECTLY
else
leftBorder = rBounds.Left; //THIS WAS THE KEY!!!!!! WOOHOO!
int MaxLinesDrawn = 0;
ArrayList[] headerLabels = new ArrayList[columns.Length];
###################################################################
I hope this helps, and again, if you would like the updated project sent back to you, just let me know, and get me an email address I can send it to.
Thanks again
Kyle Schultz
KS Design
"Technology infused with Imagination"
kyle@ksdinfusion.com
|
|
|
|
|
Great work !
This should solve the problem.
Can you say more about implementing DaPrintDocument.PreviewMode
variable ? How did you get it ?
Predrag Dukanac
|
|
|
|
|
First off let me explain some of the things that I added to your program. I added the following variables:
public static bool PreviewMode = true;
public int NumberOfPagesInDocument=0;
These two variables have become very handy to me. PreviewMode just needs to be set to true before you preview in a PrintPreviewControl. The NumberOfPagesInDocument is calculated in the DaPrintDocument_PrintPage function. I also base the last page printed on the "ToPage" from the Preview or Print Control. Now to the good stuff.
PreviewMode by default is true, therefore if you are previewing a document you just have to setXml and then open your PrintPreviewControl. When you want to print, you then change this variable to false. Here is a brief sample of how it could be used (I am not doing it like this at this time, but it should explain how I am using it).
daReport.DaPrintDocument thePrintDoc = new daReport.DaPrintDocument();
PrintDialog printer = new PrintDialog();
DialogResult dlgResult;
printer.Document = thePrintDoc;
printer.AllowSelection=true;
dlgResult = printer.ShowDialog();
if( dlgResult == DialogResult.OK )
{
//we have to set this to false here, b/c if not then it will use the Preview Margins
//therefore by setting this to false, we calculate based on the rBounds rectangle
daReport.DaPrintDocument.PreviewMode=false;
thePrintDoc.Print();
}
else
{
string msg = "Would you like to preview this document?"
dlgResult = MessageBox.Show(msg,"Prompt",MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if( dlgResult == DialogResult.OK )
{
//set this back to true so that we calculate based on the theRegion rectangle
daReport.DaPrintDocument.PreviewMode=true;
PrintPreviewDialog previewer = new PrintPreviewDialog();
previewer.Document = thePrintDoc;
previewer.ShowDialog();
}
}
That is all I am doing to accomplish both a successful Preview and Print. I used a static boolean value b/c of how I need to handle my calls to my custom DLL. You could in theory change this to a non-static type and then just set it as a property of the document, if you so desired.
The NumberOfPagesInDocument Integer value is set in the DaPrintDocument_PrintPage after the function determines if there are more pages or not. This is done after the function checks to see if the page it is on, is the ToPage of the Document.
//this if statement allows the user to select what pages they want to print
//(granted they start at one)
//therefore a user with a 10 page document can now print pages 1-7 if they want.
if( this.PrinterSettings.ToPage == (int)systemValues["pageNumber"] )
morePages=false;
e.HasMorePages = morePages;
//set the number of pages in the PrintDocument
NumberOfPagesInDocument = (int)systemValues["pageNumber"];
The above can only be accomplished by allowing the user the ability to select pages in the PrintDialog.
PrintDialog pd = new PrintDialog();
pd.Document = thePrintDoc;
pd.AllowPrintToFile = false;
pd.AllowSelection = false;
pd.AllowSomePages = true;
pd.ShowNetwork = true;
pd.ShowDialog();
I am currently working on a way to get rid of the PrintPreviewDialog Control, b/c this control in .NET, well just plainly put, SUCKS. I hate it, it is hard to work with and has just become a real pain in my arse. Once I get this worked out (I am designing a custom control using a windows form, PrintPreviewControl, and misc buttons and features), I will see if I can get it worked into your daReport, however in the mean time I have emailed my updated code to you, so that you can see what I have done.
I hope this information helps you, and answers your question. Thanks again for creating such a kick @$$ designer.
Kyle Schultz
KS Design
"Technology infused with Imagination"
kyle@ksdinfusion.com
|
|
|
|
|
For those who like their edges all new and bloody, the next version of daReport features a custom editor for the FormatMask property of a table column. You can select a data-type and it then gives you a listbox of standard FormatMasks. Enter some sample data into the form and hit the test button. The formatting uses the string.Format function so any valid format string you use with C#/VB.Net/etc/etc can be entered into the FormatMask combo-box.
This will also lead into a custom editor for rtf or HTML for text properties of objects in the version after that (0.6.0.4). Will most probably be rtf.
Bear in mind this code is not even in beta stage so buyer beware!!! Available from http://dareport.sourceforge.net/nightly.
Also includes RepeatOnMultiplePages (defining first page objects or a report header), lots of new properties for grouping (blank line before group, underline under new group (if you set table colour to transparent), display current group value above new group table header.
But I think the new FormatMask editor is pretty cool!!!
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
How about an update and make dareport.sourceforge.net look a bit nicer?
|
|
|
|
|
how rude!! But a very good point.
I am very much a programmer first and a designer 2nd (and maybe never). I am toying with the idea of changing the home page for the project to run under my personal website which is run by DotNetNuke. This way I could skin the portal and there would be a nicer set of components to use. Given that I don't know and don't want to know anything about Apache web programming (shtml, cgi, etc, etc), I am starting to lean towards this idea.
Besides, what's wrong with the blue I chose??? he he...
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
I have decided to release 0.6.0.2. I had the release candidate available for a month and no-one has sent in any bug reports. I figure that is because no-one sent them and my is not actually completely bug free.
Please go to http://dareport.sourceforge.net and click on the "0.6.0.2" link in the sidebar to get the release. If you prefer bleeding edge, have a look at the "nightly release" area. This grabs the code each night and zips it.
Please go to the home page and sign up to any relevant mailing lists. Also go there to submit bugs and suggestions to the relevant areas.
Thanks,
Angus.
http://dareport.sourceforge.net
|
|
|
|
|
Nice work!
I'will have this article updated with new release!
Predrag Dukanac
|
|
|
|
|
Hi,
I've been using the 0.6.0.2 code by loading the xml for a template sheet into a dataset,
editing the data in the dataset and then writing the dataset to a streamwriter.
I'm doing this by setting up a template with text values such as txtText and txtDate within the xml and searching the dataset for them, and then replacing the data.
Unfortunately, datasets don't like the same table being in two different nested tables.
This seems to cause problems when writing it out again, as it sends out a stream with multiple roots.
Is there a better way to do a search and replace on the data in the template?
Many thanks,
Joe
|
|
|
|
|
Hi Joe,
Loading the XML into a DataSet and parsing that way seems a little inefficient to me. It is already an XML document so why not use some tried and tested methods for changing XML data on the fly. A couple of CodeProject articles jump out. Do some searching on XPath as well.
Manipulate XML data with XPath and XmlDocument (C#)
XML File Parsing in VB.NET
The second one is ok, but the first one is a better example.
I have changed the way the XML template file is saved, and this opens the door to some XML manipulations.
Alternatively you could use the daPrintDocument api to change things as well. There are collections of dynamicObjects and staticObjects which represent objects in your document. These object's properties can be set at run-time before actually printing the document. Have a look at http://dareport.sourceforge.net/manual/DaReport/Docs/index.html for the 0.6.0.2's documentation. Look at the "daPrintDocument class" link's members and there is StaticObjects and DynamicObjects.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
Thanks Angus,
I'd tried working with XPath, but couldn't seem to get it to work...
I'll give these references a go...
Many thanks,
Joe
|
|
|
|
|
In a couple of versions I want to release some samples and documentation on manipulating the daPrintDocument object from code before it is sent for printing. I think using the object model is a better way to go than manipulating the XML on the fly. At least then you know you are working with properties and values which will be parsed correctly by the daReport assemblies.
Read this as there isn't much error handling as yet.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
- Report Header and Footer is not available.(Dareport.)
- Two or more items is not seleceted at the same time.(Dareport designer.)
I think ,these option should be add.
Good Work.
|
|
|
|
|
I have added these two as features for 0.6.0.3 release of the SourceForge project.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
I have just completed coding of the "RepeatOnMultiplePages" property. It will be available in the nightly build which will occur in 4 hours or so. Just check to see if the file date is from today.
http://dareport.sourceforge.net/nightly. This is still beta software so it would be great to get some reports back on the feature.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
Hi everybody,
I have made a feature freeze on 0.6.0.2 as I want to get grouping out and get people to start testing it. Have a look at Release Notes for details on this release.
You can make feature suggestions by following the "Enhancement Requests" link, and also lodge bugs by following the "Bug Database" link. You can also join the mailing lists for the project by following the "Mailing Lists" link.
If you go to the home page (http://dareport.sourceforge.net), you can sign up to mailing lists, report bugs, feature requests, request support, etc.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
Hey everybody,
I have added grouping to dynamic tables. At the moment it has only just been added (read this as bleeding edge) so if you want to do some beta testing and report bugs for me, that would be great. Go to http://dareport.sourceforge.net for the project home, and click on the Latest Snapshot link and download the zip file. If you want to look at the source and modify things you will need VS.Net 2003 and Framework 1.1.
You will then be able to add a GroupByField value to the report designer for dynamic tables. This value must be the same as a ColumnName value in the columns collection (note: NOT the column label). Hopefully this will then write out the rows in the same ordering you passed into the report, but grouped on the field. At the moment it simply prints out the table header again.
You can make feature suggestions by following the "Enhancement Requests" link, and also lodge bugs by following the "Bug Database" link. You can also join the mailing lists for the project by following the "Mailing Lists" link.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
Can i print on network printer by providing an IP address?
|
|
|
|
|
I beleive you can. Selecting printer to use is totally independent of creating report. If you have newtwork printer properly installed on your Windows, you can use it just like any other local printer. Take advantage of PrintDialog class for this issue.
|
|
|
|
|
Hi everybody,
I have made some changes to DaReport, and have a beta release available from the SourceForge website: http://sourceforge.net/projects/dareport/
I am releasing these changes under the LGPL. Basically this means you can use the applications, libraries in commercial or non-commercial applications, but must still contribute any code changes back to the community.
Of course you can take Predrag's code and make any mods yourself, but I thought it would be cool to get everybody modifying the same code base.
Additions:
Selectable property on all the document objects. If you set this to false then the object can not selected in the design pane. You can still select it in the tree view of objects though. Helpful for background images, etc.
Fixes:
No bugs for this point release.
If you find any problems, please go to the SourceForge site and into the "Bugs" forum. Place details in there. Place feature suggestions in the RFE (Request for Enhancements) forum.
Predrag has joined the project as well as Rob so I will be sitting in front of the PC this week and doing a heap of work. Mostly on documentation and the website.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|
Hi everybody,
I have made some changes to DaReport, and have a beta release available from the SourceForge website: http://sourceforge.net/projects/dareport/
I am releasing these changes under the LGPL. Basically this means you can use the applications, libraries in commercial or non-commercial applications, but must still contribute any code changes back to the community.
Of course you can take Predrag's code and make any mods yourself, but I thought it would be cool to get everybody modifying the same code base.
Additions:
MaskFormat: this can be used to format values when producing the
report. "c" for currency, "yyyyMMdd" for datetimes, etc. Any of the
default .NET string formatting possibilities
HeaderFontColor: colour of font in header
BorderColor property of a styled table
Fixes:
Header Background colour spans two rows instead of just one.
If you find any problems, please go to the SourceForge site and into the "Bugs" forum. Place details in there. Same for feature suggestions.
If you want to join the project, then sign up as a member of SourceForge and shoot me an email with your SourceForge id. Predrag, would you consider joining? It is your code base after all, and would be nice to have one centre for the code.
Thanks,
Angus.
Angus
3 out of every 4 people make up 75% of the worlds' population
|
|
|
|
|