Home » U++ Library support » RichText,QTF,RTF... » Can I place picture in background of page?
|
|
Re: Can I place picture in background of page? [message #40398 is a reply to message #40391] |
Tue, 30 July 2013 00:20   |
|
My question was about print on paper ability (sorry, that not point this)...
May I draw background picture/something while prepare report?
(It will be wished ability to draw Form design or background picture).
SergeyNikitin<U++>( linux, wine )
{
under( Ubuntu || Debian || Raspbian );
}
|
|
|
Re: Can I place picture in background of page? [message #40399 is a reply to message #40398] |
Tue, 30 July 2013 08:14  |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Well, the answer is the same... This is what I do, print some background picture (on the printer), then draw RichText over it.
One example is this code:
struct IsWatermark : RichText::Iterator
{
bool operator()(int pos, const RichPara& para) {
return para.format.label == "WATERMARK";
}
};
void DocPrint::Print(Draw& w, const RichText& text, const Rect& page, int firstpage, int lastpage,
int copies, bool collate, bool report)
{
IsWatermark iwm;
bool watermark = text.Iterate(iwm);
RichText watermark_text;
int wh;
int ph = Roman(75).Info().GetHeight();
Size pgsz = page.Size();
if(watermark) {
watermark_text = ParseQTF(watermark_qtf);
wh = watermark_text.GetHeight(pgsz.cx) + ph;
}
firstpage = max(0, firstpage);
int lpage = text.GetHeight(page).page;
lastpage = min(lastpage, text.GetHeight(page).page);
PrintPageDraw pw(w);
Size mmsz = w.GetPageMMs();
int x = (6000 * mmsz.cx / 254 - pgsz.cx) / 2;
int y = (6000 * mmsz.cy / 254 - pgsz.cy) / 2;
if(report)
x = y = 0;
for(int c = 0; c < (collate ? copies : 1); c++)
for(int i = firstpage; i <= lastpage; i++)
for(int c = 0; c < (collate ? 1 : copies); c++) {
w.StartPage();
PaintInfo paintinfo;
paintinfo.indexentry = Null;
paintinfo.hyperlink = Null;
if(watermark) {
pw.SetPage(0);
paintinfo.top = PageY(0, 0);
paintinfo.bottom = PageY(1, 0);
w.Offset(x, 6000 * mmsz.cy / 254 - wh);
watermark_text.Paint(pw, page, paintinfo);
w.End();
String pg = Format("%d / %d", i + 1, lpage + 1);
Size psz = GetTextSize(pg, Roman(75));
w.DrawText(x + (pgsz.cx - psz.cx) / 2, 6000 * mmsz.cy / 254 - psz.cy,
pg, Roman(75), Gray);
}
w.Offset(x, y);
pw.SetPage(i);
paintinfo.top = PageY(i, 0);
paintinfo.bottom = PageY(i + 1, 0);
text.Paint(pw, page, paintinfo);
w.End();
if(!IsNull(header) && i)
pw.Page(i).DrawText(x, y + pgsz.cy + 100, header, Arial(90).Italic());
if(!IsNull(footer) && lpage && !watermark) {
String n = Format(footer, i + 1, lpage + 1);
Size nsz = GetTextSize(n, Arial(90).Italic());
pw.Page(i).DrawText(
x + pgsz.cx - nsz.cx, y + pgsz.cy + 100,
n, Arial(90).Italic());
}
w.EndPage();
}
}
In this case, background watermark is actually another QTF, which gets repeated at the end of each page printed.
Mirek
|
|
|
Goto Forum:
Current Time: Fri Apr 25 11:53:56 CEST 2025
Total time taken to generate the page: 0.02769 seconds
|