Hello to everyone,
I should insert my company's logos in every page of a document printed by wxRichTextPrinting (wxWidgets 3.0.2).
The document contains only text. At the moment, I have printed the image at the beginning, but I need it in every page, at the beginning for example. Or, alternatively, I'd like to add it in the header, so that it would be in every page, but it seems not to be possible.
Would anyone know how to help me please?
Thanks in advance.
Best regards
Magdalen
Printing a logo in every page of a document
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: Printing a logo in every page of a document
I don't think that's possible with wxRichTextPrinting. It's really designed to make printing ridiculously easy since it's extremely complicated to handle printing yourself using wxPrintout, but in this case, if you really want to power to make customizations like rendering images in headers or footers, then you really should switch to manual printouts using your own rendering and layout code.
Optionally, it might be worth contributing a patch to wxRichTextPrinting that offers a way to interrupt each page, that reserves some margin space for additional rendering in custom paint methods. I probably would have been in favor of that API instead of the current wxRichTextHeaderFooterData class back when this was first written, but it's certainly far too late for that now.
Optionally, it might be worth contributing a patch to wxRichTextPrinting that offers a way to interrupt each page, that reserves some margin space for additional rendering in custom paint methods. I probably would have been in favor of that API instead of the current wxRichTextHeaderFooterData class back when this was first written, but it's certainly far too late for that now.
Re: Printing a logo in every page of a document
There is no easy way to do this.
I'm not 100% sure, but looking through the source code, this might work:
Derive your own class from wxRichTextPrintout and override the method OnPrintPage(). The original code looks like this:Before or after RenderPage() render your own custom content onto the page.
Derive your own class from wxRichTextPrinting(), override the method CreatePrintout() and return an instance of your wxRichTextPrintout.
However this doesn't solve the problem that the "normal" content of the page must not overlap your custom content. I see no easy fix for that, that would require even deeper changes to the related classes.
I'm not 100% sure, but looking through the source code, this might work:
Derive your own class from wxRichTextPrintout and override the method OnPrintPage(). The original code looks like this:
Code: Select all
bool wxRichTextPrintout::OnPrintPage(int page)
{
wxDC *dc = GetDC();
if (dc)
{
if (HasPage(page))
RenderPage(dc, page);
return true;
}
else return false;
}
Derive your own class from wxRichTextPrinting(), override the method CreatePrintout() and return an instance of your wxRichTextPrintout.
However this doesn't solve the problem that the "normal" content of the page must not overlap your custom content. I see no easy fix for that, that would require even deeper changes to the related classes.
Use the source, Luke!
Re: Printing a logo in every page of a document
Thank you very much. I'll try yet by wxRichTextPrintout even if it seems a bit hard
- evstevemd
- Part Of The Furniture
- Posts: 2409
- Joined: Wed Jan 28, 2009 11:57 am
- Location: United Republic of Tanzania
Re: Printing a logo in every page of a document
Or Save XML, Parse it to add image and print with wxHtmlEasyPrinting
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?