如何使用C#打印文本的具体位置? [英] How to print text to specific position using c#?

查看:356
本文介绍了如何使用C#打印文本的具体位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何打印领域到指定的页面位置? 举例来说,我有一个印刷本,我想在这些特定/分隔空间的打印数据。

How can I print a field to a specific page location? For instance, I have a printed form and I want to print data in those specific/delimited spaces.

我已经看到了一些例子,但并不适用于我的需要。

I've seen some examples, but they do not apply to my need.

HTTP://www.codeproject.com /用品/ 10180 /怎样对打印的文本中-C

<一个href="http://stackoverflow.com/questions/7703274/how-to-create-page-with-text-in-specific-location">http://stackoverflow.com/questions/7703274/how-to-create-page-with-text-in-specific-location

最后一个,如果没有关闭,我认为它会找到了答案。

The last one if wasn't closed I think it'd have the answer.

任何想法?

感谢。

推荐答案

如果你有一个文件的形式,你可以扫描它,并将其转换为PDF表单与像CutePDF程序。接下来,创建你希望能够填补(通过拖动矩形),他们的名字,并保存表单中的字段。 iTextSharp的是一个C#库,可以让你在表单字段填写一个纲领性的方式。

If you have a paper form, you can scan it in, and convert it to a PDF form with a program like CutePDF. Next, create the fields you want to be able to fill in (by dragging rectangles), name them, and save the form. iTextSharp is a C# library that lets you fill in the form fields in a programmatic way.

例如:

//Replace with path to the form
var pdfFormLocation = "C:\\pdfForm.pdf"; 

//Adjust below path to a temp location
var pdfPath = String.Format("C:\\temp\\{0}", Guid.NewGuid().ToString());
File.Copy(pdfFormLocation, pdfPath, true);

var reader = new PdfReader(pdfPath);
var output = new FileStream();
var stamper = new PdfStamper(reader, output);

//the form field names can be a little hairy
stamper.AcroFields.SetField("topmostSubform[0].Page1[0].f1_01_0_[0]", "Your Name");

//make the form no longer editable
stamper.FormFlattening = true;

stamper.Close();
reader.Close();
//now you can go print this file from pdfPath

链接: iTextSharp的 CutePDF

Links: iTextSharp CutePDF

这篇关于如何使用C#打印文本的具体位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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