简体   繁体   English

使用 C# 在预打印纸表单上的特定位置打印文本

[英]Printing text at a particular position on pre printed paper form using C#

I need to print as in printing paper texts at a particular position of the print paper.我需要像在打印纸的特定位置打印纸文本一样进行打印。 The reason is that the printing is done on already printed form with fields such as first and last names.原因是打印是在已打印的表单上完成的,其中包含名字和姓氏等字段。 So when I get the name of the person and it should print within that allocated space in paper form.所以当我得到这个人的名字时,它应该以纸质形式在分配的空间内打印。

Wondering if there are any exisiting libraries that will allow me to print at a particular position using a coordinate system like X and Y coordinate.想知道是否有任何现有的库可以让我使用像 X 和 Y 坐标这样的坐标系在特定位置进行打印。

Here is something to get you started.......这里有一些东西可以让你开始......
http://msdn.microsoft.com/en-us/library/aa287530(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/aa287530(v=vs.71).aspx

Using that tutorial, I would suggest you print roughly at the four corners of a page, that way you know the printing coordinate system.使用该教程,我建议您大致在页面的四个角进行打印,这样您就知道了打印坐标系。

Using that, and a good ol' ruler, you can figure out where the fields on your paper form are, and translate them to xy coordinates on the code.使用它和一个好的尺子,您可以找出纸质表单上的字段所在的位置,并将它们转换为代码上的 xy 坐标。

Try making a PDF the same size as the form page, with the text appropriately positioned on it.尝试制作与表单页面大小相同的 PDF,并在其上适当放置文本。 Then print the PDF to the printer that has your pre-printed forms loaded in the paper try.然后将 PDF 打印到在纸张中加载了预打印表格的打印机。

I'll leave it up to you to find a library that can work with PDFs.我会让你去寻找一个可以处理 PDF 的库。 On Python I'd use reportlab .在 Python 上,我会使用reportlab Find your local C# equivalent.找到您本地的 C# 等效项。

Try to make a C# form and add a print function from that you can manually set x and y coordinates at which your text will be printed on the form.尝试制作一个 C# 表单并添加一个打印函数,您可以从中手动设置 x 和 y 坐标,您的文本将打印在表单上。

Just edit new Point(x,y)只需编辑新的 Point(x,y)

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        e.Graphics.DrawString("Rangoli Travels", new Font("Arial",12,FontStyle.Regular),Brushes.Black, new Point(10,10);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM