将VB6.Printer对象升级到.net [英] Upgrade VB6.Printer object to .net

查看:107
本文介绍了将VB6.Printer对象升级到.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这里有人可以帮助我。



我们正在忙着将VB6项目转换为.net。

我们的报告是使用旧的VB6打印机对象构建的,当我们使用.net时,我们使用了Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer,它运行正常,但它仍然是技术上纯粹的.net代码,它基本上是使用起来很慢。



如何或者用什么来升级到纯.net编码,使用第三方dll就好像iTextSharp。



另一个问题是我们真的无法改变其设计的工作原理,因为数据通过字符串发送到报表生成器并且字符串格式不能改变了。



当前代码是:

goPrinter是VB6.Printer对象

sReportData是一个数组string



任何帮助都会很棒,谢谢你这么久



Hi, I hope anyone here can help me.

We are busy converting a VB6 project to .net.
Some of our reports get build using the old VB6 printer object, when convered to .net we used "Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer", that works fine, but it's still technically pure .net code, it's basically to slow to use anymore.

How or what would I use to upgrade this to pure .net coding, using 3rd party dll's is fine like iTextSharp.

And the other issue is we really can't change much of how the design of it works because the data gets send through a string to the report builder and that string format can't be changed.

The current code is:
goPrinter is the VB6.Printer object
sReportData is an array string

Any help would be great, and thank you so long

For iL = 1 To ICnt
      strItem = sReportData(iL)

      Select Case strItem.Trim()
          Case "<BR>" ' Line Feed
              LCnt += 1
              goPrinter.Write("")
          Case "<LF>"
              goPrinter.Print("")
          Case "" ' Bold On
              goPrinter.FontBold = True
          Case "" ' Bold Off
              goPrinter.FontBold = False
          Case "<NP>" ' Page Break
              goPrinter.NewPage()
          Case Else
              goPrinter.Print(strItem)            'Prints Entire Line In One Go
      End Select

  Next iL
  goPrinter.EndDoc()
  goPrinter.Print()

推荐答案

晚上好,



为此在.NET中已经有很多解决方案,你可以通过程序集。 Drawing.Printing。查看即使在这里也可以找到的示例;)



PrintDocument Class



基本文本和图像打印



如何用C#打印更多页面



用C#打印



在你的情况下,根据开关的循环,你将改变e.Graphics.DrawString的设置(使粗体等等。)



Cordialement,

Claude T。
Good evening,

For that there are already many solutions in .NET, you go through the assembly. Drawing.Printing. See the examples that you can find everywhere even here;)

PrintDocument Class
or
Basic Text and Image Printing
or
How to print more pages in C#
or
Printing in C#

In your case, the loop according to the switch, you will change the settings of e.Graphics.DrawString (make bold, etc ..)

Cordialement,
Claude T.


这完全取决于您使用的UI框架/库。对于 System.Windows.Forms ,最好使用 PrintDocument (参见解决方案1)。对于WPF ...请参阅 http://www.c-sharpcorner.com/uploadfile/ mahesh / printing-in-wpf [ ^ ]。



-SA
It all depends on the UI framework/library you are using. For System.Windows.Forms, you should better use PrintDocument (See Solution 1). For WPF… see, for example, http://www.c-sharpcorner.com/uploadfile/mahesh/printing-in-wpf[^].

—SA


这篇关于将VB6.Printer对象升级到.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆