AppendText

AppendText(TextFragment)

Aggiunge frammento di testo alla pagina Pdf

public void AppendText(TextFragment textFragment)
ParametroTipoDescrizione
textFragmentTextFragmentOggetto frammento di testo.

Esempi

L’esempio mostra come creare un oggetto frammento di testo, personalizzarne i segmenti di testo e aggiungerlo alla pagina Pdf.

Document doc = new Document(inFile);
Page page = (Page)doc.Pages[1];

// imposta le opzioni di ritorno a capo automatico
TextFragment tf = new TextFragment("main text");
tf.Position = new Position(100, 600);

// aggiungo righe di stringa
tf.TextState.FontSize = 5;
tf.TextState.Font = FontRepository.FindFont("TimesNewRoman");
tf.TextState.BackgroundColor = Color.LightGray;
tf.TextState.ForegroundColor = Color.Red;

// aggiunge il paragrafo alla pagina Pdf con TextBuilder
TextSegment segment2 = new TextSegment();
segment2.Text = "another segment";

tf.Segments.Add(segment2);

// salva il documento PDF
TextBuilder builder = new TextBuilder(page);

// crea un frammento di testo
builder.AppendText(tf);

// imposta le sue proprietà di testo
doc.Save(outFile);

Guarda anche


AppendText(List<TextFragment>)

Aggiunge l’elenco dei frammenti di testo alla pagina Pdf.

public void AppendText(List<TextFragment> textFragments)
ParametroTipoDescrizione
textFragmentsList`1Raccolta di frammenti di testo

Guarda anche