testing components
testing components
Hi,
We are testing the component TRichViewEdit and I have a question regarding print/printpreview. We have our own printing and previewing code. What's the best example (from demo) I should work on that will help me understand how I could print/printpreview the content of the control in our sourcecode. Currently using Delphi 7 and for printing something called ReportPrinter Pro Component Suite. This is something from '95-'96 years, so, yeah, it's old ... don't ask
Or, what's your take on this, how easy would be to print/preview the content in our custom code (probably we will have to paginate ourselves, etc)
TIA,
Lucian
We are testing the component TRichViewEdit and I have a question regarding print/printpreview. We have our own printing and previewing code. What's the best example (from demo) I should work on that will help me understand how I could print/printpreview the content of the control in our sourcecode. Currently using Delphi 7 and for printing something called ReportPrinter Pro Component Suite. This is something from '95-'96 years, so, yeah, it's old ... don't ask
Or, what's your take on this, how easy would be to print/preview the content in our custom code (probably we will have to paginate ourselves, etc)
TIA,
Lucian
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
To answer the question, I need to understand why do you need to use your own print and preview code for TRichViewEdit?
There are two ways to print TRichViewEdit:
- TRVPrint (with preview in TRVPrintPreview component)
- TRVReportHelper.
TRVPrint requires minimal code, because it uses the current printer settings, handles headers, footers, footnotes, endnotes (and text boxes in the new version, that will be released soon). For previewing, there is a special component TRVPrintPreview. A function for drawing TRVPrint's page on the specific canvas exists, but it's undocumented.
TRVReportHelper is useful if you want to implement a non-standard page layout, or draw TRichView document as a part of more complex document drawn by other tools. In TRVReportHelper, you just specify canvas and document width, then height for specific "pages". In TRVReportHelper, "page" is not necessary equal to paper size, it's just a rectangle. There is a function allowing to draw "page" at the specified coordinates. It does not support notes, boxes, headers and footers.
There are two ways to print TRichViewEdit:
- TRVPrint (with preview in TRVPrintPreview component)
- TRVReportHelper.
TRVPrint requires minimal code, because it uses the current printer settings, handles headers, footers, footnotes, endnotes (and text boxes in the new version, that will be released soon). For previewing, there is a special component TRVPrintPreview. A function for drawing TRVPrint's page on the specific canvas exists, but it's undocumented.
TRVReportHelper is useful if you want to implement a non-standard page layout, or draw TRichView document as a part of more complex document drawn by other tools. In TRVReportHelper, you just specify canvas and document width, then height for specific "pages". In TRVReportHelper, "page" is not necessary equal to paper size, it's just a rectangle. There is a function allowing to draw "page" at the specified coordinates. It does not support notes, boxes, headers and footers.
Hi, and thanks for answering this. The application I am working on is huge and very complex. It has tons of reporting. Some functionality involves sending emails. Currently the emails are plain text. The emails are not only sent out, but also stored in the application database for reviewing, deleting, whatever. The thing is, there's a print button everywhere , and in this case, for an email, the application would print some info at the top of the page (From, To, Subject, datetime, etc) and then the body of the email (which as of now is plain text as I said).
Now ... people want RTF and HTML in their email. That's why we think using this component we could do that. I'm the guy testing the components and most probably implementing the changes. So, I need to know the best way to print the content of the richview component. I believe all I have to communicate with the component is a DC, a device context (but I am not sure, I have to investigate more). Also, I am not sure about paginating. I believe I am going to code page breaking myself... or not, I don't know yet. Or perhaps you're right, we could try to fully use the print and preview that comes with the component, but than we have to be able to print additional stuff, eventually company logo, headers, footers, the whole nine yards.
That's about it. Let me know what you think and thanks.
Now ... people want RTF and HTML in their email. That's why we think using this component we could do that. I'm the guy testing the components and most probably implementing the changes. So, I need to know the best way to print the content of the richview component. I believe all I have to communicate with the component is a DC, a device context (but I am not sure, I have to investigate more). Also, I am not sure about paginating. I believe I am going to code page breaking myself... or not, I don't know yet. Or perhaps you're right, we could try to fully use the print and preview that comes with the component, but than we have to be able to print additional stuff, eventually company logo, headers, footers, the whole nine yards.
That's about it. Let me know what you think and thanks.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I suggest using TRVPrint and TRVPrintPreview components.
As for printing additional stuff. If you want to print something at very beginning or very end of the document, it's simpler to add this additional content to TRichViewEdit before printing (for example, by combining two documents together).
Also, you can assign another documents as a header or a footer (RVPrint.SetHeader/SetFooter). Special headers for the first page and odd/even pages are supported.
Also (in the new version, public trials are not available yet) you can print additional stuff in text boxes positioned at the specified coordinates on the page. Textboxes can be inserted in headers (but positioned everywhere on a page) to repeat on every page.
Finally, you can use OnPagePrepaint and OnPagePostpaint events to draw something yourself.
As for custom paginations, I am not sure what you mean. I suggest to control pagination using document features: keep-lines-together and keep-with-next paragraphs, and inserting pagebreaks in certain places.
As for printing additional stuff. If you want to print something at very beginning or very end of the document, it's simpler to add this additional content to TRichViewEdit before printing (for example, by combining two documents together).
Also, you can assign another documents as a header or a footer (RVPrint.SetHeader/SetFooter). Special headers for the first page and odd/even pages are supported.
Also (in the new version, public trials are not available yet) you can print additional stuff in text boxes positioned at the specified coordinates on the page. Textboxes can be inserted in headers (but positioned everywhere on a page) to repeat on every page.
Finally, you can use OnPagePrepaint and OnPagePostpaint events to draw something yourself.
As for custom paginations, I am not sure what you mean. I suggest to control pagination using document features: keep-lines-together and keep-with-next paragraphs, and inserting pagebreaks in certain places.
Ok, I'll have a look. With pagination, what I meant is, even when printing for example a TRichEdit, the developer must measure and split the content of the control, it's a classic 20-30 lines piece of code you can find in many places (where you send some startpos in the buffer plus some TRect bounds and get back some endpos in the RTF, you repeat this in a loop until you print the whole content). Don't know how you do it.
One other question, if we buy the component, does it come with 100% full source code?
One other question, if we buy the component, does it come with 100% full source code?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes, the full version includes full source code.
The analog of RichEdit's EM_FORMATRANGE is TRVReportHelper component.
TRVPrint component has a higher level programming interface: you specify page margins and other properties, and it does all the work for you.
In TRVReportHelper, you format like this:
I.e. you can define width and height for each page (width must be the same, heights may be different).
Then you can draw the helper's page at the specified coordinates using helper.DrawPageAt.
Examples of using TRVReportHelper:
- Demos\*\Assorted\Printing\ReportHelper - printing documents in two columns
- http://www.trichview.com/forums/viewtopic.php?t=327 (please note that this is an old topic, it contains obsolete information about TRVPrint: it now supports special headers for the first and odd/even pages (can be found already in the trial version) and page number fields (currently in the version available only for registered users)).
The analog of RichEdit's EM_FORMATRANGE is TRVReportHelper component.
TRVPrint component has a higher level programming interface: you specify page margins and other properties, and it does all the work for you.
In TRVReportHelper, you format like this:
Code: Select all
helper.Init(Canvas, Width);
while not helper.FormatNextPage(Height) do;
Then you can draw the helper's page at the specified coordinates using helper.DrawPageAt.
Examples of using TRVReportHelper:
- Demos\*\Assorted\Printing\ReportHelper - printing documents in two columns
- http://www.trichview.com/forums/viewtopic.php?t=327 (please note that this is an old topic, it contains obsolete information about TRVPrint: it now supports special headers for the first and odd/even pages (can be found already in the trial version) and page number fields (currently in the version available only for registered users)).
plain text
Hi Serghey,
Does the component have something like "PlainText" functionality, where I can extract the "Text" as plain text (string)?
Does the component have something like "PlainText" functionality, where I can extract the "Text" as plain text (string)?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The following functions allow retrieving a plain text
- SaveTextToStreamW and SaveTextToStream method
- GetAllText from RVGetTextW and RVGetText units
- GetTextRange from RVLinear unit
- SaveTextToStreamW and SaveTextToStream method
- GetAllText from RVGetTextW and RVGetText units
- GetTextRange from RVLinear unit
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Currently - only with help of additional components.
They are free with source code.
The best solution is TrvHtmlViewImporter: http://www.trichview.com/resources/ that uses THTMLViewer (also free with source code)
They are free with source code.
The best solution is TrvHtmlViewImporter: http://www.trichview.com/resources/ that uses THTMLViewer (also free with source code)
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Note that HTML emails are not simple HTML, but mime-encoded documents that may contain HTML, its text alternative, images, attached files.
You need to decode this mime-document and extract HTML and images in order to load them.
Some examples:
- http://www.trichview.com/forums/viewtopic.php?t=4123 - contains functions and examples using CleverComponents, including full functional email client
- http://www.trichview.com/forums/viewtopic.php?t=11 - examples for sending HTML email using Indy
- http://www.trichview.com/forums/viewtopic.php?t=6133 - example for sending HTML email using Synapse (not tested by me)
The last two example are only for saving. However, I believe, if these components support MIME-encoding, they support decoding as well.
You need to decode this mime-document and extract HTML and images in order to load them.
Some examples:
- http://www.trichview.com/forums/viewtopic.php?t=4123 - contains functions and examples using CleverComponents, including full functional email client
- http://www.trichview.com/forums/viewtopic.php?t=11 - examples for sending HTML email using Indy
- http://www.trichview.com/forums/viewtopic.php?t=6133 - example for sending HTML email using Synapse (not tested by me)
The last two example are only for saving. However, I believe, if these components support MIME-encoding, they support decoding as well.
Printing from preview
Hi,
One other question... is it possible to print from the preview itself. Like for example "Print current page" / "Print all" ?
Thx
One other question... is it possible to print from the preview itself. Like for example "Print current page" / "Print all" ?
Thx