Hello,
is there anybody who can explain me the easiest way to print the text of an ultratexteditor?
Best regardsIsiraider
Isiraider,
There are a set of samples that ship with the NetAdvantage SDK that should be able to illustrate the use of the various elements in the Documents engine, which might be of good use for you to familiarize yourself with the layout options at your disposal. With that being said, the quickest way to simply add a text element to a report would be:
Report report = new Report();ISection section = report.AddSection();IText textElem = section.AddText();textElem.AddContent(this.ultraTextEditor1.Text);report.Publish("MyPDF.pdf", FileFormat.PDF);
-Matt
Hello Matt,
thank you for your fast answer! The Infragistics samples for printing are not really simple and not easy to understand...
I need a simple solution which just takes the text of the UltraTexteEitor and shows it in an UltraPrintPreviewDialog, where the user can print it...How can I display the report you created in your five lines of code in the UltraPrintPreviewDialog?The layout options are not so interested for the moment...
-isiraider
There isn't any intrinsic support for displaying the contents of a Report object in a PrintPreviewDialog. Fortunately, a solution for accomplishing this was presented by another user in the following thread:
http://forums.infragistics.com/forums/t/1237.aspx
There isn't, however, a "quick and easy" approach to doing this since you have to work with the Report object in order for it to publish to a format that the print preview will understand.
I think I am maybe to stupid for this printing thing...
I just need a solution which gives me the opportunity to set the UltreTextEditor's text to any object (must not be such a Report object) you recommend and then print this object with a print dialog.The text's format and the document's format is not so important.
There is nothing specific to the UltraTextEditor in this case. What you need to do is use a .NET PrintDocument and PreviewPreviewDialog, setting the Document property of the dialog to the instance of the document on your form. Then, you need to handle the PrintPage event of the PrintDocument in order to draw the string yourself. Unfortunately, when you get to the point of wanting to control the layout of the object, you will still have to do some more complex positioning calculationgs, so you may want to revisit using the Documents engine later combined with the forum post that I linked earlier.
A quick sample of drawing the text would be, after setting up the PrintDocument and PrintPreviewDialog mentioned above:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){ e.Graphics.DrawString(this.ultraTextEditor1.Text, this.Font, Brushes.Black, new PointF(0, 0));}private void button1_Click(object sender, EventArgs e){ this.printPreviewDialog1.ShowDialog(this);}
thank you again! I was already at this point... I also added a UltraPrintDocument as Document to the UltraPrintPreviewDialog, but I didn't find out how to add my text to the UltraPrintDocument. With your following code I just can see some black points in the UltraPrintPreviewDialog:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){ e.Graphics.DrawString(this.ultraTextEditor1.Text, this.Font, Brushes.Black, new PointF(0, 0));}
I can say that this is more than I have had before :) but how I have to modify the UltraPrintDocument to see a whole page including my text in the PrintPreviewDialog?
I can't understand the code in the topic "Using the Infragistics.Documents code library with an UltraPrintPreviewDialog". :-(
Me again... :)
Now I know why I just saw some black points in the UltraPrintPreviewDialog. It was because of the printer's driver which is installed on the server. It seems like they are not compatible... I created a forwarding from LPT1 to a local Printer with another driver and it works!
Thank you very much! Now I can try to modify the document's layout... :)