I'm using WPRichText contents as a field in a table and creating a report using RAVE (reportprinter pro - code based).
In the past (when editing), the ruler had darker gray areas on the left and right, along with the margin markers. When I created the report, the richtext contents would look correct and each page would end properly at the page end. Currently these older richtext fields still look good.
However, some how the dark gray area on the left and right on the ruler disappeared. When generating a report with the new contents of the field, the pages will run off the end/bottom. The only temporary solution is to add blank lines at the bottom of each page in the richtext document.
When I turn off text wrapping, the bottom is correct, but the text will run off the page on the right.
What happened and what can I do to correct this?
Thanks,
Craig.
void __fastcall TForm1::ReportSystem1Print(TObject *Sender)
{
TMetafile *MF = new TMetafile;
TMetafileCanvas *MFC;
TRect R,RR;
int i, num_pages;
double PaperWidth, PaperHeight;
HDC MyHDC;
TBaseReport *report;
TPrintPageMode pm_mode;
TStream *Stream1 = NULL;
// Create pointer to RP Pro BaseReport....
report = dynamic_cast<TBaseReport*>(Sender);
// Ensure WPRichText->ScreenResMode is rm1440...
// Get PaperWidth and PaperHeight of WPRichText...
// Get RichText field contents....
Stream1 = myWPtable->CreateBlobSteam(info_table->FieldByName("richtext_info"), bmRead);
WPRichText1->LoadFromStream(Stream1);
PaperWidth = WPRichText1->Header->PageWidth /1440.0;
PaperHeight =WPRichText1->Header->PageHeight /1440.0;
// Calculate pixel Height & Width based on screen resolution...
MyHDC = GetDC(0);
MF->Height = PaperHeight * GetDeviceCaps(MyHDC, LOGPIXELSY);
MF->Width = PaperWidth * GetDeviceCaps(MyHDC, LOGPIXELSX);
ReleaseDC(0,MyHDC);
// Define MetaFile "image" size....
R.Top = R.Left = 0;
R.Right = MF->Width;
R.Bottom = MF->Height;
// Set options for PrintPageOnCanvas....
pm_mode = << ppmUseEvents;
// Get number of pages in WPRichText document...
num_pages = WPRichText1->CountPages();
// For each page, print to the preview window....
for (i = 0; i < num_pages; i++) {
// Create a new MetaFileCanvas....
MFC = new TMetafileCanvas(MF,0);
// Print to canvas, based on screen resolution
WPRichText1->PrintPageOnCanvas(MFC,R,i,pm_mode,100);
delete MFC;
// ---------Create "image" size, based on printer resolution!!!!---------
RR = Rect(0.0,0.0,PaperWidth*report->XDPI,PaperHeight*report->YDPI);
// Stretch "image" based on printer resolution....
report->StretchDraw(RR,MF);
// If new WPRichText page.......
if (i < (num_pages-1)) {
report->NewPage();
}
}
delete MF;
}
Alles anzeigen