I'm using Printer()->func to print custom data. When I print to Microsoft Office Image Writer it's fine, when I print to either PDF or my HP DeskJet I get garbage for the most part. Lines of the table don't appear where they should be. The code is below.
My question is, why am I getting different results on different print devices? What can I do to fix this?
My question is, why am I getting different results on different print devices? What can I do to fix this?
Code:
// Print action
//---------------------------------------------------------------------------
void __fastcall TfMJTuner::aPrintExecute(TObject *Sender)
{
if(pdPrintDialog->Execute())
{
Printer()->BeginDoc();
Printer()->Title = "Megajolt Lite Jr Ignition Map";
PrintCurrentData();
Printer()->EndDoc();
}
}
// Print current MJTuner data
//---------------------------------------------------------------------------
void TfMJTuner::PrintCurrentData()
{
// Setup the font
Printer()->Canvas->Font->Name = "Courier New";
Printer()->Canvas->Font->Color = clBlack;
Printer()->Canvas->Font->Size = 10;
Printer()->Canvas->Font->Size = -Printer()->Canvas->Font->Height * 72 / Printer()->Canvas->Font->PixelsPerInch;
Printer()->Canvas->Font->Pitch = fpFixed;
Printer()->Refresh();
int pgLine = 2;
int left = Printer()->Canvas->Font->PixelsPerInch/2;
int textHeight = Printer()->Canvas->TextHeight("X");
int tblSpaceBetweenCol = Printer()->Canvas->TextWidth(" 10000");
// Print a banner
Printer()->Canvas->TextOut( left,
(10+textHeight)*pgLine,
Config.CurrentFileName + " - Ignition Map by Megajolt Lite Jr Tuner" );
// Print engine description
pgLine+=5;
Printer()->Canvas->TextOut( left,
(10+textHeight)*pgLine,
AnsiString("ENGINE: ") + Config.EngineDescription );
// Print map description
pgLine+=1;
Printer()->Canvas->TextOut( left,
(10+textHeight)*pgLine,
AnsiString(" MAP: ") + Config.MapDescription );
// Print number of cylinders
pgLine+=2;
Printer()->Canvas->TextOut( left,
(10+textHeight)*pgLine,
AnsiString("Cylinder Count: ") + AnsiString(Config.IgnConfig.NumCylinders) );
// Print engine load units
pgLine+=1;
Printer()->Canvas->TextOut( left,
(10+textHeight)*pgLine,
AnsiString("Engine Load Units: ")
+ ((Config.ThrottleNotMap)?("%, TP (throttle position)"):("kPA, MAP (manifold absolute pressure)")) );
pgLine+=5;
for(int i=0; i<Consts::NUM_RPM_BINS; ++i)
{
Printer()->Canvas->TextOut( (left*3) + 60 + i*tblSpaceBetweenCol - Printer()->Canvas->TextWidth(AnsiString(Config.IgnConfig.RpmBinGrid[i])),
(10+textHeight)*pgLine,
AnsiString(Config.IgnConfig.RpmBinGrid[i]) );
}
pgLine+=2;
for(int i=0; i<Consts::NUM_MAP_BINS; ++i)
{
Printer()->Canvas->TextOut( (left*2) - Printer()->Canvas->TextWidth(AnsiString(Config.IgnConfig.MapBinGrid[i])),
(12+textHeight)*pgLine,
AnsiString(Config.IgnConfig.MapBinGrid[i]) );
pgLine+=1;
}
pgLine-=10;
int lineTop = pgLine;
Printer()->Canvas->MoveTo((left*3)-70, (12+textHeight)*pgLine - 5);
Printer()->Canvas->LineTo((left*3)+(10*tblSpaceBetweenCol)-70, (12+textHeight)*pgLine - 5);
Printer()->Canvas->MoveTo((left*3) + 105 - tblSpaceBetweenCol, (12+textHeight)*lineTop-5);
Printer()->Canvas->LineTo((left*3) + 105 - tblSpaceBetweenCol, (12+textHeight)*(lineTop+10)-5);
for(int mapIndex=0; mapIndex<Consts::NUM_MAP_BINS; ++mapIndex)
{
for(int rpmIndex=0; rpmIndex<Consts::NUM_RPM_BINS; ++rpmIndex)
{
Printer()->Canvas->TextOut( (left*3) + 60 + (rpmIndex*tblSpaceBetweenCol) - Printer()->Canvas->TextWidth(AnsiString(Config.IgnConfig.IgnAdvTable[mapIndex][rpmIndex])),
(12+textHeight)*pgLine,
AnsiString(Config.IgnConfig.IgnAdvTable[mapIndex][rpmIndex]) );
Printer()->Canvas->MoveTo((left*3) + 105 + rpmIndex*tblSpaceBetweenCol, (12+textHeight)*lineTop-5);
Printer()->Canvas->LineTo((left*3) + 105 + rpmIndex*tblSpaceBetweenCol, (12+textHeight)*(lineTop+10)-5);
}
pgLine+=1;
Printer()->Canvas->MoveTo((left*3)-70, (12+textHeight)*pgLine - 5);
Printer()->Canvas->LineTo((left*3)+(10*tblSpaceBetweenCol)-70, (12+textHeight)*pgLine - 5);
}
}