【问题标题】:Blurry print with legacy borland software使用旧版 borland 软件进行模糊打印
【发布时间】:2015-09-10 06:56:18
【问题描述】:

这是我的问题:我必须将一个为 Windows NT 4 制作的旧软件(我认为)移植到 Windows 7 或更高版本上的旧 Borland。程序运行良好(依赖 walker 没有问题,App Verifier 显示 Bad DEVMODE 缓冲区,但此错误在 XP 上存在并且运行良好)。

程序必须打印带有一些信息的标签,这在 Windows XP 上运行良好,但七个数字模糊,我不知道为什么,我不知道如何解决这个问题。

我的打印机可以正常工作,因为我可以完美地在 7 上打印文本,如果我用 pdf 打印机打印,问题还是一样,所以我认为问题出在 windows 上。

有什么想法吗?

编辑 1: 我有部分源代码,但缺少 IDE 中包含的部分。 我认为打印机不在原因,因为这两个测试相同,而 PDF 打印机的问题仍然存在

这里是打印的源代码:

 //---------------------------------------------------------------------------
 #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;
 }
 //---------------------------------------------------------------------------

这里是描述标签形状的.DFM文件

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

如您所见,字体是硬编码的,所以我认为问题不存在,而且我检查了字体,它们的版本相同。

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

【问题讨论】:

    标签: printing legacy borland-c++


    【解决方案1】:

    由于您的问题不够具体,所以这里有一些提示可以帮助而不是回答:

    你有打印的源代码吗?

    在源代码中搜索以下内容:

    #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();
    

    尝试将prn-&gt;Canvas 复制到Graphics::TBitmap *bmp-&gt;CopyRect(...),然后将其保存到文件bmp-&gt;SaveToFile("print.bmp");。检查问题是否在打印之前渲染图像。还要在此处发布打印代码,以便我们查看是否有任何可疑之处。如果您不熟悉 VCL 下的 Canvas/Bitmap,请参阅:

    张贴正确和错误打印的图像怎么样。

    现在我能想到几种可能性,例如:

    1. 某些 Win7 增强文本功能会更改使用的字体

    2. 与 XP 不同的使用字体参数

      可以尝试将XP字体复制到你的Win7(不要忘记保存原件)

    3. 错误选择的打印机纸张区域(以像素为单位)

      (x64 Windows 正在 WOW64 模拟器中运行 Win32 应用程序,它有不同的驱动程序集可供使用,可能是它返回不同的打印机/参数或其他东西)

    4. 较新的打印机驱动程序(如 HP)

      通过将打印图像缩放到97% 来添加默认墨粉节省,从而产生锯齿/模糊伪影。检查打印对话框窗口是否有此类内容

    5. 某些第 3 方组件的使用

      我停止使用这些,因为它们很快就会过时且不受支持,并且在移植到更新的操作系统、编译器等时让我的生活变得一团糟。更不用说它们通常价格不合理

    【讨论】:

    • 我无法添加图片:/
    • @FlorianGERARD 1. 您可以在某处发布图像并在此处发布指向它的链接,有人会在此处为您复制。 2.查看您的源代码后,我没有看到打印代码尝试在Printer()-&gt;EndDoc();调用打印的某处寻找Printer()函数体,您的代码只需移动/隐藏一些面板并在打印时调整备忘录(可能隐藏工具栏) .当你发现实际的打印例程截取它的图像时,看看问题是出在渲染还是打印本身。
    • @FlorianGERARD 如果您处于可编译状态,那么您可以在Print(); 行上放置断点并按 F7 进入。此外,您正在访问 ini 文件,因此请确保 ini 文件中的小数点 ,. 没有问题...
    • 这是软件最深的源代码,printers.hpp属于Borland,这是一个老的IDE,不能在windows 7(16位程序)上运行。我找到了 Printers.hpp 和 Printers.pas(是的,它是 pascal),但我不知道我是否可以再次编译它。
    • @FlorianGERARD 你弄错了,打印例程不是 VCL 的一部分,它是自定义源代码,不在 Printers.hpp 中你需要搜索应用程序的源代码,而不是 VCL 和 RTL 的东西博兰。
    猜你喜欢
    • 2012-06-29
    • 1970-01-01
    • 2020-10-23
    • 2016-08-29
    • 1970-01-01
    • 1970-01-01
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多