-1
私はこの問題を試してみたが運がない。IText 7、PdfFormField内のテキストの配置?
これは私が試みたものです。
using (PdfDocument doc = new PdfDocument(new PdfReader(template), new
PdfWriter(newPath)))
{
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
// Replace form fields with correct data
form.GetField("Greet").SetValue("Hello world!");
// I have tried this to with no luck
form.GetField("Greet").SetJustification(1).SetValue("Hello World");
form.FlattenFields();
}
私の答えを受け入れられた答えとしてマークすることを検討してください。これは実際に仕様書に記載されているものです:p –
Thxあなたは素早い返信のために http://itextsupport.com/apidocs/itext7/7.0.1/com/itextpdf/forms/fields/PdfFormField。 html#setJustification-int- 私はこれを見つけました: パブリックPdfFormField setJustification(int justification) テキストを表示する際に使用される四辺形(ジャスティフィケーション)の形式を指定するコードを設定します:0左詰め1中央2右詰め パラメータ:justification - 両端揃え属性を に設定する値戻り値:編集されたフィールド これを読んで、なぜ "form.GetField(" Greet ")なのか疑問に思ってしまいます。SetJustification(1).SetValue(" Hello World "); "が中央にない場合 –
これは、フォームフィールドが(論理的に)このメソッドを提供するコンポーネントから継承するためです。むしろその方法をサポートしているからです。 –