PdfContentEditor.ReplaceText
ReplaceText(string, int, string, TextState)
Sostituisce il testo nel file PDF nella pagina specificata. L’oggetto TextState
(famiglia di caratteri, colore) può essere specificato per il testo sostituito.
public bool ReplaceText(string srcString, int thePage, string destString, TextState textState)
Parametro | Tipo | Descrizione |
---|---|---|
srcString | String | La stringa da sostituire. |
thePage | Int32 | Numero di pagina (0 significa “tutte le pagine”). |
destString | String | La stringa sostituita. |
textState | TextState | Stato del testo (Colore del testo, Font, ecc.). |
Valore di ritorno
Restituisce true se la sostituzione è stata effettuata.
Esempi
L’esempio dimostra come sostituire il testo nella prima pagina del documento PDF e impostare le proprietà del testo TextState
per il nuovo testo.
// open document
Document doc = new Document(inFile);
// Create font and mark it to be embedded
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;
// create PdfContentEditor object to edit text
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);
// create textState object
TextState textState = new TextState();
textState.Font = font;
textState.FontSize = 17;
textState.FontStyle = FontStyle.Bold | FontStyle.Italic;
textState.ForegroundColor = Color.Red;
// change text with specified font
editor.ReplaceText("hello world", 1, "hi world", textState);
// save document
doc.Save(outFile);
Vedi anche
- classe TextState
- classe PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string)
Sostituisce il testo nel file PDF.
public bool ReplaceText(string srcString, string destString)
Parametro | Tipo | Descrizione |
---|---|---|
srcString | String | La stringa da sostituire. |
destString | String | Stringa di sostituzione. |
Valore di ritorno
Restituisce true se la sostituzione è stata effettuata.
Esempi
L’esempio dimostra come sostituire il testo nel documento PDF.
// open document
Document doc = new Document(inFile);
// create PdfContentEditor object to edit text
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);
// change text
editor.ReplaceText("hello world", "hi world");
// save document
doc.Save(outFile);
Vedi anche
- classe PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, int, string)
Sostituisce il testo nel file PDF nella pagina specificata.
public bool ReplaceText(string srcString, int thePage, string destString)
Parametro | Tipo | Descrizione |
---|---|---|
srcString | String | La stringa da sostituire. |
thePage | Int32 | Numero di pagina (0 per tutte le pagine) |
destString | String | Stringa di sostituzione. |
Valore di ritorno
Restituisce true se la sostituzione è stata effettuata.
Esempi
L’esempio dimostra come sostituire il testo nel documento PDF nella pagina specificata.
// open document
Document doc = new Document(inFile);
// create PdfContentEditor object to edit text
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);
// change text
editor.ReplaceText("hello world", 1, "hi world");
// save document
doc.Save(outFile);
Vedi anche
- classe PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string, TextState)
Sostituisce il testo nel file PDF utilizzando l’oggetto TextState
specificato.
public bool ReplaceText(string srcString, string destString, TextState textState)
Parametro | Tipo | Descrizione |
---|---|---|
srcString | String | Stringa da sostituire |
destString | String | Stringa di sostituzione |
textState | TextState | Stato del testo (Colore del testo, Font, ecc.) |
Valore di ritorno
Restituisce true se la sostituzione è stata effettuata.
Esempi
L’esempio dimostra come sostituire il testo e impostare le proprietà del testo TextState
per il nuovo testo.
// open document
Document doc = new Document(inFile);
// Create font and mark it to be embedded
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;
// create PdfContentEditor object to edit text
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);
// create textState object
TextState textState = new TextState();
textState.Font = font;
textState.FontStyle = FontStyle.Bold | FontStyle.Italic;
// change text with specified font
editor.ReplaceText("hello world", "hi world", textState);
// save document
doc.Save(outFile);
Vedi anche
- classe TextState
- classe PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string, int)
Sostituisce il testo nel file PDF e imposta la dimensione del carattere.
public bool ReplaceText(string srcString, string destString, int fontSize)
Parametro | Tipo | Descrizione |
---|---|---|
srcString | String | Stringa da sostituire. |
destString | String | Stringa di sostituzione. |
fontSize | Int32 | Dimensione del carattere. |
Valore di ritorno
Restituisce true se la sostituzione è stata effettuata.
Esempi
L’esempio dimostra come sostituire il testo e impostare la dimensione del carattere per il nuovo testo.
// open document
Document doc = new Document(inFile);
// Create font and mark it to be embedded
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;
// create PdfContentEditor object to edit text
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);
// change text with specified font
editor.ReplaceText("hello world", "hi world", 14);
// save document
doc.Save(outFile);
Vedi anche
- classe PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF