ReplaceText

ReplaceText(string, int, string, TextState)

Reemplaza el texto del archivo PDF en la página especificada.TextState El objeto (familia de fuentes, color) se puede especificar para reemplazar el texto.

public bool ReplaceText(string srcString, int thePage, string destString, TextState textState)
ParámetroEscribeDescripción
srcStringStringLa cadena a ser reemplazada.
thePageInt32Número de página (0 significa “todas las páginas”).
destStringStringLa cadena reemplazada.
textStateTextStateEstado del texto (color del texto, fuente, etc.).

Valor_devuelto

Devuelve verdadero si se realizó un reemplazo.

Ejemplos

El ejemplo muestra cómo reemplazar texto en la primera página del documento PDF y establecerTextState propiedades de texto para el nuevo texto.

// abrir documento
Document doc = new Document(inFile);

// Crear fuente y marcarla para incrustarla
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;

// crear objeto PdfContentEditor para editar texto
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);

// crear objeto de estado de texto
TextState textState = new TextState();
textState.Font = font;
textState.FontSize = 17;
textState.FontStyle = FontStyle.Bold | FontStyle.Italic;
textState.ForegroundColor = Color.Red;

// cambia el texto con la fuente especificada
editor.ReplaceText("hello world", 1, "hi world", textState);

// guardar documento
doc.Save(outFile);

Ver también


ReplaceText(string, string)

Reemplaza texto en el archivo PDF.

public bool ReplaceText(string srcString, string destString)
ParámetroEscribeDescripción
srcStringStringLa cadena a ser reemplazada.
destStringStringReemplazo de cuerda.

Valor_devuelto

Devuelve verdadero si se realizó un reemplazo.

Ejemplos

El ejemplo muestra cómo reemplazar texto en un documento PDF.

// abrir documento
Document doc = new Document(inFile);

// crear objeto PdfContentEditor para editar texto
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);

// cambiar texto 
editor.ReplaceText("hello world", "hi world");

// guardar documento
doc.Save(outFile);

Ver también


ReplaceText(string, int, string)

Reemplaza el texto en el archivo PDF en la página especificada.

public bool ReplaceText(string srcString, int thePage, string destString)
ParámetroEscribeDescripción
srcStringStringLa picadura a ser reemplazada.
thePageInt32Número de página (0 para todas las páginas)
destStringStringReemplazo de cuerda.

Valor_devuelto

Devuelve verdadero si se realizó un reemplazo.

Ejemplos

El ejemplo muestra cómo reemplazar texto en un documento PDF en la página especificada.

// abrir documento
Document doc = new Document(inFile);

// crear objeto PdfContentEditor para editar texto
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);

// cambiar texto 
editor.ReplaceText("hello world", 1, "hi world");

// guardar documento
doc.Save(outFile);

Ver también


ReplaceText(string, string, TextState)

Reemplaza el texto en el archivo PDF utilizandoTextState objeto.

public bool ReplaceText(string srcString, string destString, TextState textState)
ParámetroEscribeDescripción
srcStringStringCadena a reemplazar
destStringStringReemplazo de cuerda
textStateTextStateEstado del texto (color del texto, fuente, etc.)

Valor_devuelto

Devuelve verdadero si se realizó un reemplazo.

Ejemplos

El ejemplo muestra cómo reemplazar texto y establecerTextState propiedades de texto para el nuevo texto.

// abrir documento
Document doc = new Document(inFile);

// Crear fuente y marcarla para incrustarla
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;

// crear objeto PdfContentEditor para editar texto
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);

// crear objeto de estado de texto
TextState textState = new TextState();
textState.Font = font;
textState.FontStyle = FontStyle.Bold | FontStyle.Italic;

// cambia el texto con la fuente especificada
editor.ReplaceText("hello world", "hi world", textState);

// guardar documento
doc.Save(outFile);

Ver también


ReplaceText(string, string, int)

Reemplaza el texto en el archivo PDF y establece el tamaño de fuente.

public bool ReplaceText(string srcString, string destString, int fontSize)
ParámetroEscribeDescripción
srcStringStringCadena a ser reemplazada.
destStringStringReemplazo de cuerda.
fontSizeInt32Tamaño de fuente.

Valor_devuelto

Devuelve verdadero si se realizó un reemplazo.

Ejemplos

El ejemplo muestra cómo reemplazar texto y establecer el tamaño de fuente para el nuevo texto.

// abrir documento
Document doc = new Document(inFile);

// Crear fuente y marcarla para incrustarla
Aspose.Pdf.Text.Font font = FontRepository.FindFont("Courier New");
font.IsEmbedded = true;

// crear objeto PdfContentEditor para editar texto
PdfContentEditor editor = new PdfContentEditor();
editor.BindPdf(doc);

// cambia el texto con la fuente especificada
editor.ReplaceText("hello world", "hi world", 14);

// guardar documento
doc.Save(outFile);

Ver también