printing and saving from EV_RICH_TEXT

33 views
Skip to first unread message

r...@amalasoft.com

unread,
Sep 23, 2020, 9:42:50 AM9/23/20
to Eiffel Users Group
Hi All

I guess I should know this, after all these years, but I don't.
I can't seem to find a hook to print the contents of an EV_RICH_TEXT widget, or even to save it's contents as an RTF file.
Actually, I can't seem to find any way to print any text at all from an Eiffel application.
Suggestions?
Thanks
R

r...@amalasoft.com

unread,
Sep 27, 2020, 11:58:42 AM9/27/20
to Eiffel Users Group
Hi Again

I haven't heard anything from my initial question yet, but ..  the first issue, of saving to an RTF file, has been solved (years ago, as it happens).
To save the contents of an EV_RICH_TEXT widget, use <widget>.save_to_named_path (<path>).
I guess that might have been obvious to some - though not to me at the time, apparently :)

The save-to-a-file logic is implementation-specific, but it strikes me that a minor, and yet rather nifty, enhancement might be to break that routine into a buffer generator and a save-buffer-to-file sort of thing.
Armed with a buffer and a file descriptor, it would then be easy enough to send the buffer's RTF contents to a socket or pipe.

This still does not address the print-from-a-widget, or frankly the print-at-all challenge.  The print dialog (EV_PRINT_DIALOG) is easy enough to instantiate and show, but it has no context, so to speak.  It does have a 'context' feature, but that doesn't seem (to me) to relate to anything resembling a get-this-to-the-selected-printer functionality.  The missing part seems to be connecting the content to the printer.  Having the content as a buffer, and the ability to send the buffer the printer object would be very nice indeed.

I'll readily concede that I could have missed something, perhaps an obvious something, but I have yet to find it.  Any and all suggestions welcomed
Thanks
R

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/20200923064216.cf48dd763fcaf5d42559c6c92f6fc53b.1d3eec793d.wbe%40email25.godaddy.com.

jjj

unread,
Sep 28, 2020, 9:14:26 PM9/28/20
to Eiffel Users
I am going from memory from years ago, and I never got it working.

If I recall you have to use a PROJECTOR and related files to project the output to the printer.  It became so cumbersome that I never got around to it in the project.

Maybe that could give you a rabbit to chase.  Sorry, I don't remember anything more.

jjj

To unsubscribe from this group and stop receiving emails from it, send an email to eiffel...@googlegroups.com.

r...@amalasoft.com

unread,
Sep 29, 2020, 7:43:56 AM9/29/20
to eiffel...@googlegroups.com
I've looked around for anything having to do with printers and it seems that, apart from the model and figure world elements, there aren't any suitable.  There is EV_PRINTER, but that's a friend only to a model or figure projector, and it takes a WEL_PRINTER_DC as argument (in the Windows implementation).
Having a projector of some kind makes sense when dealing with a collection of items (as with *world), but text seems to me to be closer to being a single element (though rich text has its formatting parts).  Given that EV_RICH_TEXT offers the ability to save the contents, formatted, it would strike me that there should also be a rich text projector and yes, a plain text projector. too
Also, the print context from the EV_PRINT_DIALOG doesn't seem to relate to anything.  Again, I could have missed something there too.
It strikes me that there is enough, hidden under the covers, to make this work, but I just don't see it.  The drawing context (e.g. WEL_PRINTER_DC) might be the key.  Coincidentally, it might also be a good example of working with a C interface (the presently popular thread).

Thanks
R
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/98a7599f-7223-41ce-8efc-11f63895d3b0o%40googlegroups.com.

Jocelyn Fiat

unread,
Jan 12, 2021, 12:06:00 PM1/12/21
to Eiffel Users
Hi,

That may be a late answer, but for Windows, you can indeed use WEL to print the content of EV_RICH_TEXT.


local
    wnd: WEL_FRAME_WINDOW -- Needed to create the rich edit component.
    rich: WEL_RICH_EDIT
    pdc: WEL_PRINTER_DC
    txt: STRING
    l_loader: WEL_RICH_EDIT_BUFFER_LOADER
do
    create wnd.make_top ("_dummy_")
    create rich.make (wnd, "_dummy_", 10, 10, 300, 500, -1)
    create pdc.make_by_pointer (interface.context.printer_context)
    txt := interface.to_rtf   -- Get the RTF content from the EV_RICH_TEXT , see EV_RICH_TEXT.save_to_named_path (..)
    create l_loader.make (txt)
    rich.set_text_limit (txt.count)
    rich.rtf_stream_in (l_loader)
    if attached interface.job_name as jn then
        rich.print_all (pdc, jn)
    else
        rich.print_all (pdc, "From EV_RICH_TEXT_PRINTER")
    end
    wnd.destroy
end

On non Windows, the example is not complete as it requires other tools to be installed (to convert RTF to PDF, or PS), then use "lp" to send the job to the printer.

I hope this can help.

-- Jocelyn



--
Jocelyn
------------------------------------------------------------------------
Eiffel Software
https://www.eiffel.com
Customer support: https://support.eiffel.com
User group: https://groups.google.com/forum/#!forum/eiffel-users
------------------------------------------------------------------------

r...@amalasoft.com

unread,
Jan 12, 2021, 2:37:51 PM1/12/21
to eiffel...@googlegroups.com
Thanks Jocelyn
I'll give that a try.
R
Reply all
Reply to author
Forward
0 new messages