1

フィールドを特定のページの場所に印刷するにはどうすればよいですか?たとえば、印刷されたフォームがあり、それらの特定の/区切られたスペースにデータを印刷したいとします。

私はいくつかの例を見てきましたが、それらは私のニーズには当てはまりません。

http://www.codeproject.com/Articles/10180/How-to-print-text-in-C

https://stackoverflow.com/questions/7703274/how-to-create-page-with-text-in-specific-location

最後のものは閉じていなかったら答えがあると思います。

何か案は?

ありがとう。

4

2 に答える 2

1

紙のフォームがある場合は、それをスキャンして、CutePDFなどのプログラムでPDFフォームに変換できます。次に、(長方形をドラッグして)入力できるフィールドを作成し、名前を付けて、フォームを保存します。iTextSharpは、プログラムによる方法でフォームフィールドに入力できるC#ライブラリです。

例:

//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

于 2012-10-22T16:57:52.290 に答える
0

最初の記事で述べたように、C#でのプリンターへの印刷は、キャンバスへの描画とまったく同じです(レポートフレームワークを使用する場合を除く)。

PrintDocument.PrintPageイベントには、ページに必要なものを描画するために使用できるグラフィックパラメータがあります。

Graphicsには、パラメーターの1つとして位置をとるGraphics.DrawString関数があります。

好きな場所にテキストを描くためにそれを使用するだけです。

長方形も描画する場合は、Graphics.MeasureString関数とGraphics.DrawRectangleメソッドを使用して、TextBoxのようなフィールドを描画できます。

于 2012-10-22T17:15:16.393 に答える