PdfContentEditor.ReplaceText

ReplaceText(string, int, string, TextState)

تستبدل النص في ملف PDF في الصفحة المحددة. يمكن تحديد كائن TextState (عائلة الخط، اللون) للنص المستبدل.

public bool ReplaceText(string srcString, int thePage, string destString, TextState textState)
ParameterTypeDescription
srcStringStringالسلسلة التي سيتم استبدالها.
thePageInt32رقم الصفحة (0 يعني “جميع الصفحات”).
destStringStringالسلسلة المستبدلة.
textStateTextStateحالة النص (لون النص، الخط، إلخ).

Return Value

ترجع true إذا تم الاستبدال.

Examples

توضح المثال كيفية استبدال النص في الصفحة الأولى من مستند PDF وتعيين خصائص نص TextState للنص الجديد.

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

See Also


ReplaceText(string, string)

تستبدل النص في ملف PDF.

public bool ReplaceText(string srcString, string destString)
ParameterTypeDescription
srcStringStringالسلسلة التي سيتم استبدالها.
destStringStringالسلسلة المستبدلة.

Return Value

ترجع true إذا تم الاستبدال.

Examples

توضح المثال كيفية استبدال النص في مستند 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);

See Also


ReplaceText(string, int, string)

تستبدل النص في ملف PDF في الصفحة المحددة.

public bool ReplaceText(string srcString, int thePage, string destString)
ParameterTypeDescription
srcStringStringالسلسلة التي سيتم استبدالها.
thePageInt32رقم الصفحة (0 لجميع الصفحات)
destStringStringالسلسلة المستبدلة.

Return Value

ترجع true إذا تم الاستبدال.

Examples

توضح المثال كيفية استبدال النص في مستند 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", 1, "hi world");

// save document
doc.Save(outFile);

See Also


ReplaceText(string, string, TextState)

تستبدل النص في ملف PDF باستخدام كائن TextState المحدد.

public bool ReplaceText(string srcString, string destString, TextState textState)
ParameterTypeDescription
srcStringStringالسلسلة التي سيتم استبدالها
destStringStringالسلسلة المستبدلة
textStateTextStateحالة النص (لون النص، الخط، إلخ)

Return Value

ترجع true إذا تم الاستبدال.

Examples

توضح المثال كيفية استبدال النص وتعيين خصائص نص TextState للنص الجديد.

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

See Also


ReplaceText(string, string, int)

تستبدل النص في ملف PDF وتحدد حجم الخط.

public bool ReplaceText(string srcString, string destString, int fontSize)
ParameterTypeDescription
srcStringStringالسلسلة التي سيتم استبدالها.
destStringStringالسلسلة المستبدلة.
fontSizeInt32حجم الخط.

Return Value

ترجع true إذا تم الاستبدال.

Examples

توضح المثال كيفية استبدال النص وتحديد حجم الخط للنص الجديد.

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

See Also