Blurry print with legacy borland software

104 views Asked by At

Here is my problem : I have to port an old sofware made for windows NT 4 (i thought) with an old Borland on Windows 7 or newer. The program is running well ( no problem with dependency walker, App Verifier shows a Bad DEVMODE buffer but this error exists on XP and it works well).

The programm have to print a label with some information, this works good on windows XP but on seven numbers are blurry, i don't know why and i don't how to troubleshoot that.

My printer works because i can print a text on seven perfectly and if i print with a pdf printer the problem still the same so i thought that the problem is from windows.

Any idea?

Edit 1 : I have some parts of the source code but parts that were included in the IDE are missing. The printer is not in cause i think because it's the same for the two tests and the problem still here with a PDF printer

here is the source code of print :

 //---------------------------------------------------------------------------
 #include <vcl.h>
 #pragma hdrstop
 #include <printers.hpp>
 #include "FileCtrl.hpp"
 #include "IniFileName.h"
 #include "PrnEtiQ.h"
 #include "CheckDll.h"
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 #pragma resource "*.dfm"
 TEtiquette *Etiquette;
 //---------------------------------------------------------------------------
 __fastcall TEtiquette::TEtiquette(TComponent* Owner) : TForm(Owner)
 {
 }
 //---------------------------------------------------------------------------
 void __fastcall TEtiquette::PrintEti(AnsiString Name,double OD,double           OG,double xrb,int PrnIndex)
 {
  if (PrnIndex==-1) return;
  TIniFile * pIni=new TIniFile(GetIniFileName());
  if (pIni)
  {
    DecalX=pIni->ReadInteger("ETIQUETTE","Decal_X",150);
    DecalY=pIni->ReadInteger("ETIQUETTE","Decal_Y",0);
    pIni->WriteInteger("ETIQUETTE","Decal_X",DecalX);
    pIni->WriteInteger("ETIQUETTE","Decal_Y",DecalY);
    delete pIni;
  } 
  else
  {
    DecalX=150;
    DecalY=0;
  }
  LblName->Caption=Name;
  PerimDroit->Caption=FormatFloat("##0.0000",OD);
  PerimGauche->Caption=FormatFloat("##0.0000",OG);
  XRB->Caption=FormatFloat("##0.00",xrb);
  Printer()->PrinterIndex=PrnIndex;
  int MemoWidth=Width;
  int MemoHeight=Height;
  Width=MemoWidth+DecalX;
  Height=MemoHeight+DecalY;
  Panel1->Left=DecalX;
  Panel1->Top=DecalY;
  Print();
  Width=MemoWidth;
  Height=MemoHeight;
  Panel1->Left=0;
  Panel1->Top=0;
 }
 //---------------------------------------------------------------------------

and here is the .DFM file which describe the shape of the label

object Etiquette: TEtiquette
Left = 167
Top = 149
HorzScrollBar.Visible = False
VertScrollBar.Visible = False
BorderIcons = []
BorderStyle = bsNone
ClientHeight = 33
ClientWidth = 142
Color = clWhite
UseDockManager = True
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Arial Black'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 18
object Panel1: TPanel
  Left = 0
  Top = 0
  Width = 143
  Height = 34
  BevelOuter = bvNone
  Color = clWhite
  Font.Charset = ANSI_CHARSET
  Font.Color = clWindowText
  Font.Height = -13
  Font.Name = 'Arial Black'
  Font.Style = []
  ParentFont = False
  TabOrder = 0
  object PerimGauche: TLabel
    Left = 4
    Top = 0
    Width = 65
    Height = 11
    AutoSize = False
    Caption = '200.00'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object PerimDroit: TLabel
    Left = 72
    Top = 0
    Width = 66
    Height = 11
    Alignment = taRightJustify
    AutoSize = False
    Caption = '100.00'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object XRB: TLabel
    Left = 40
    Top = 12
    Width = 57
    Height = 11
    Alignment = taCenter
    AutoSize = False
    Caption = '123.45'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = [fsBold]
    ParentColor = False
    ParentFont = False
  end
  object LblName: TLabel
    Left = 4
    Top = 20
    Width = 42
    Height = 14
    Caption = '18241_1'
    Color = clWhite
    Font.Charset = ANSI_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Arial'
    Font.Style = []
    ParentColor = False
    ParentFont = False
  end
end
end

As you can see, fonts are hardcoded so i don't think that the problem is there futhermore i checked the fonts and they are in the same version.

Edit 2 : https://drive.google.com/file/d/0B0AeGDmETlPXbGlPX3dUSG1WUzg/view?usp=sharing

1

There are 1 answers

17
Spektre On BEST ANSWER

As your question is not specific enough so here some hints that could help instead of answer:

Do you have the source code for the printing?

search source code for things like:

#include <Printers.hpp>
TPrinter *prn = Printer();
// here open dialog window... set the printing parameters
prn->BeginDoc();
// here draw the printed image to prn->Canvas
prn->NewPage();
// here draw the printed image to prn->Canvas
// ...
prn->EndDoc();

Try to copy the prn->Canvas to Graphics::TBitmap *bmp->CopyRect(...) and then save it to file bmp->SaveToFile("print.bmp");. To check if the problem is in rendering the image prior to printing it or not. Also post printing code here so we see if there is not anything suspicious. If you not familiar with Canvas/Bitmap under VCL see:

What about posting an image of correct and incorrect print.

Now I can think of few possibilities like:

  1. some Win7 enhance text feature altering used fonts

  2. different used font parameters from XP

    can try to copy XP fonts to your Win7 (do not forget to save the originals one)

  3. wrongly selected printer paper area in pixels

    (x64 Windows is running Win32 apps in WOW64 emulator which has different set of drivers at disposal may be it returns different printer/parameters or something)

  4. newer printer drivers (like HP)

    adds on default toner saving by scaling printed image to 97% making aliasing/blurring artifacts. Check printing dialog window for such things

  5. usage of some 3th party component

    I stop using those because they are quickly being outdated unsupported and makes my life a hell while porting to newer OS,compiler whatever. Not to mention they are usually insainly priced