PdfContentEditor.ReplaceText

ReplaceText(string, int, string, TextState)

Belirtilen sayfadaki PDF dosyasındaki metni değiştirir. TextState nesnesi (yazı tipi ailesi, renk) değiştirilen metin için belirtilebilir.

public bool ReplaceText(string srcString, int thePage, string destString, TextState textState)
ParametreTürAçıklama
srcStringStringDeğiştirilecek dize.
thePageInt32Sayfa numarası (0 “tüm sayfalar” anlamına gelir).
destStringStringDeğiştirilen dize.
textStateTextStateMetin durumu (Metin Rengi, Yazı tipi vb).

Dönüş Değeri

Değiştirmenin yapılıp yapılmadığını belirtmek için true döner.

Örnekler

Örnek, PDF belgesinin ilk sayfasındaki metni nasıl değiştireceğinizi ve yeni metin için TextState metin özelliklerini nasıl ayarlayacağınızı gösterir.

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

Ayrıca Bakınız


ReplaceText(string, string)

PDF dosyasındaki metni değiştirir.

public bool ReplaceText(string srcString, string destString)
ParametreTürAçıklama
srcStringStringDeğiştirilecek dize.
destStringStringDeğiştiren dize.

Dönüş Değeri

Değiştirmenin yapılıp yapılmadığını belirtmek için true döner.

Örnekler

Örnek, PDF belgesindeki metni nasıl değiştireceğinizi gösterir.

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

Ayrıca Bakınız


ReplaceText(string, int, string)

Belirtilen sayfadaki PDF dosyasındaki metni değiştirir.

public bool ReplaceText(string srcString, int thePage, string destString)
ParametreTürAçıklama
srcStringStringDeğiştirilecek dize.
thePageInt32Sayfa numarası (tüm sayfalar için 0)
destStringStringDeğiştiren dize.

Dönüş Değeri

Değiştirmenin yapılıp yapılmadığını belirtmek için true döner.

Örnekler

Örnek, belirtilen sayfadaki PDF belgesindeki metni nasıl değiştireceğinizi gösterir.

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

Ayrıca Bakınız


ReplaceText(string, string, TextState)

Belirtilen TextState nesnesini kullanarak PDF dosyasındaki metni değiştirir.

public bool ReplaceText(string srcString, string destString, TextState textState)
ParametreTürAçıklama
srcStringStringDeğiştirilecek dize
destStringStringDeğiştiren dize
textStateTextStateMetin durumu (Metin Rengi, Yazı tipi vb)

Dönüş Değeri

Değiştirmenin yapılıp yapılmadığını belirtmek için true döner.

Örnekler

Örnek, metni nasıl değiştireceğinizi ve yeni metin için TextState metin özelliklerini nasıl ayarlayacağınızı gösterir.

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

Ayrıca Bakınız


ReplaceText(string, string, int)

PDF dosyasındaki metni değiştirir ve yazı tipi boyutunu ayarlar.

public bool ReplaceText(string srcString, string destString, int fontSize)
ParametreTürAçıklama
srcStringStringDeğiştirilecek dize.
destStringStringDeğiştiren dize.
fontSizeInt32Yazı tipi boyutu.

Dönüş Değeri

Değiştirmenin yapılıp yapılmadığını belirtmek için true döner.

Örnekler

Örnek, metni nasıl değiştireceğinizi ve yeni metin için yazı tipi boyutunu nasıl ayarlayacağınızı gösterir.

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

Ayrıca Bakınız