Hello,
Is there any possibility to get the absolute coordinates of table borders in header and footer? At the moment we build the document like that:
TParagraph *par; Cardinal txtplain; par = wp_Document->HeaderFooter->Get(wpIsHeader,wpraOnAllPages,"")->CreateTable(NULL); par->Name = "StandardHeader"; par->indentleft = 0; wp_Document->WritingAttr()->Clear(); wp_Document->WritingAttr()->SetFontName("Arial"); wp_Document->WritingAttr()->SetFontSize(10); txtplain = wp_Document->WritingAttr()->CharAttr; par->ClearText(true); par->ASet(WPAT_Alignment,Integer(paralRight)); par->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); par->ASet(WPAT_BorderColor,clBlack); TWPTableRowStyle *MyRow = par->CreateRow( NULL,true); MyRow->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); TParagraph *MyCell; TWPTextObj *Image; MyCell = MyRow->InputCell(); Image = MyCell->InsertNewObject(MaxInt,wpobjImage,false,false,txtplain); Image->IsImage(); TMemoryStream *MyStream = new TMemoryStream(); img_Logo->Picture->Bitmap->SaveToStream(MyStream); MyStream->Position = 0; Image->LoadObjFromStream(".bmp",MyStream); MyRow->InputCell(); par->EndRow(MyRow); MyRow = par->CreateRow( NULL,true); MyRow->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); MyCell = MyRow->InputCell(); MyCell = MyRow->InputCell(); MyCell->Insert(0,"Page ",txtplain); MyCell->InsertNewObject(MaxInt,wpobjTextObject,false,false,txtplain)->Name = WPTextFieldNames[wpoPageNumber]; MyCell->Insert(MaxInt," of ",txtplain); MyCell->InsertNewObject(MaxInt,wpobjTextObject,false,false,txtplain)->Name = WPTextFieldNames[wpoNumPages]; MyCell->ASet(WPAT_Alignment,Integer(paralRight)); MyCell->ASetColor(WPAT_BGColor,clLime); par->EndRow(MyRow); par = wp_Document->HeaderFooter->Get(wpIsFooter,wpraOnAllPages,"")->CreateTable(NULL); par->Name = "StandardFooter"; par->indentleft = 0; wp_Document->WritingAttr()->Clear(); wp_Document->WritingAttr()->SetFontName("Arial"); wp_Document->WritingAttr()->SetFontSize(10); txtplain = wp_Document->WritingAttr()->CharAttr; par->ClearText(true); par->ASet(WPAT_Alignment,Integer(paralRight)); par->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); par->ASet(WPAT_BorderColor,clBlack); MyRow = par->CreateRow( NULL,true); MyRow->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); MyCell = MyRow->InputCell(); Image = MyCell->InsertNewObject(MaxInt,wpobjImage,false,false,txtplain); Image->IsImage(); MyStream->Clear(); img_Logo->Picture->Bitmap->SaveToStream(MyStream); MyStream->Position = 0; Image->LoadObjFromStream(".bmp",MyStream); delete MyStream; MyRow->InputCell(); par->EndRow(MyRow); MyRow = par->CreateRow( NULL,true); MyRow->ASet(WPAT_BorderFlags,WPBRD_DRAW_All4); MyCell = MyRow->InputCell(); MyCell = MyRow->InputCell(); MyCell->Insert(0,"Page ",txtplain); MyCell->InsertNewObject(MaxInt,wpobjTextObject,false,false,txtplain)->Name = WPTextFieldNames[wpoPageNumber]; MyCell->Insert(MaxInt," of ",txtplain); MyCell->InsertNewObject(MaxInt,wpobjTextObject,false,false,txtplain)->Name = WPTextFieldNames[wpoNumPages]; MyCell->ASet(WPAT_Alignment,Integer(paralRight)); MyCell->ASetColor(WPAT_BGColor,clLime); par->EndRow(MyRow); wp_Document->DelayedReformat();
As border we draw a rectangle as stated in the demo:
void __fastcall Tfrm_Document::wp_DocumentPaintWatermark(TObject *Sender,
TWPRTFEnginePaint *RTFEngine, TCanvas *toCanvas, TRect &PageRect,
int PaintPageNr, int RTFPageNr, TObject *WaterMarkRef, int XRes,
int YRes, float CurrentZoom, TWPPaintModes PaintMode)
{
TRect r;
TParagraph *par;
int width = wp_Document->HeaderFooter->Get(wpIsHeader,wpraOnAllPages,"")->FirstPar->LineLength(0);
if( RTFPageNr > 0 )
{
r.Left = PageRect.Left +
MulDiv( wp_Document->DisplayedText->Pages[ RTFPageNr - 1]->PageMarginLeft, XRes, 1440);
r.Top = PageRect.Top +
MulDiv( wp_Document->DisplayedText->Pages[ RTFPageNr - 1]->PageMarginTop, YRes, 1440);
r.Right = PageRect.Right -
MulDiv( wp_Document->DisplayedText->Pages[ RTFPageNr - 1]->PageMarginRight, XRes, 1440);
r.Bottom = PageRect.Bottom -
MulDiv( wp_Document->DisplayedText->Pages[ RTFPageNr - 1]->PageMarginBottom, YRes, 1440);
toCanvas->Rectangle(r);
}
}
The Problem is that if you zoom in or render the document the lines don't match.
How Do I get the lines from the Header and Footer Tables have exactly the same coordinates as the lines we paint at the border of the page.
Thanks in advance,
Florian Fanderl