PdfContentEditor.ReplaceText
محتويات
[
يخفي
]ReplaceText(string, int, string, TextState)
تستبدل النص في ملف PDF في الصفحة المحددة. يمكن تحديد كائن TextState (عائلة الخط، اللون) للنص المستبدل.
public bool ReplaceText(string srcString, int thePage, string destString, TextState textState)
| Parameter | Type | Description |
|---|---|---|
| srcString | String | السلسلة التي سيتم استبدالها. |
| thePage | Int32 | رقم الصفحة (0 يعني “جميع الصفحات”). |
| destString | String | السلسلة المستبدلة. |
| textState | TextState | حالة النص (لون النص، الخط، إلخ). |
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
- class TextState
- class PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string)
تستبدل النص في ملف PDF.
public bool ReplaceText(string srcString, string destString)
| Parameter | Type | Description |
|---|---|---|
| srcString | String | السلسلة التي سيتم استبدالها. |
| destString | String | السلسلة المستبدلة. |
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
- class PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, int, string)
تستبدل النص في ملف PDF في الصفحة المحددة.
public bool ReplaceText(string srcString, int thePage, string destString)
| Parameter | Type | Description |
|---|---|---|
| srcString | String | السلسلة التي سيتم استبدالها. |
| thePage | Int32 | رقم الصفحة (0 لجميع الصفحات) |
| destString | String | السلسلة المستبدلة. |
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
- class PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string, TextState)
تستبدل النص في ملف PDF باستخدام كائن TextState المحدد.
public bool ReplaceText(string srcString, string destString, TextState textState)
| Parameter | Type | Description |
|---|---|---|
| srcString | String | السلسلة التي سيتم استبدالها |
| destString | String | السلسلة المستبدلة |
| textState | TextState | حالة النص (لون النص، الخط، إلخ) |
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
- class TextState
- class PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF
ReplaceText(string, string, int)
تستبدل النص في ملف PDF وتحدد حجم الخط.
public bool ReplaceText(string srcString, string destString, int fontSize)
| Parameter | Type | Description |
|---|---|---|
| srcString | String | السلسلة التي سيتم استبدالها. |
| destString | String | السلسلة المستبدلة. |
| fontSize | Int32 | حجم الخط. |
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
- class PdfContentEditor
- namespace Aspose.Pdf.Facades
- assembly Aspose.PDF