2016-03-25 12 views

cevap

1

Benim adım Tilal Ahmad ve Aspose şirketinde developer evangelist.

PDF belgesinin belirli bir sayfasındaki metni aramak ve değiştirmek için documentation link kullanabilirsiniz. Belgelerin alt kısmında önerilen özel sayfa dizini için Kabul yöntemini çağırmalısınız. Ayrıca metni büyük harfle değiştirmek için, aşağıdaki gibi String nesnesinin ToUpper() yöntemini kullanabilirsiniz.

.... 
textFragment.Text = textFragment.Text.ToUpper(); 
.... 

Düzenleme: örnek kod Bu iki nedenden dolayı çalışmaz bir specificed PDF sayfa

//open document 
Document pdfDocument = new Document(myDir + "testAspose.pdf"); 
//create TextAbsorber object to find all instances of the input search phrase 
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(""); 
//accept the absorber for all the pages 
pdfDocument.Pages[2].Accept(textFragmentAbsorber); 
//get the extracted text fragments 
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments; 
//loop through the fragments 
foreach (TextFragment textFragment in textFragmentCollection) 
{ 
    //update text and other properties 
    textFragment.Text = textFragment.Text.ToUpper(); 

} 

pdfDocument.Save(myDir+"replacetext_output.pdf"); 
+0

metin harfe geçiş yapmak için, lütfen varsayım ben yerine metni biliyorum ama yok olduğunu. Sadece sayfayı biliyorum ve büyük harfe dönüştürmek istiyorum. Ayrıca, textFragment sınıfını kullanmayı önerdiğiniz, ancak bu sınıf, elbette bir sayfada var olacak çok satırlı dizeleri desteklemiyor, bu da işe yaramıyor. – NYTom

+0

@NYTom, bir arama dizesini TextFragmentAbsorber nesnesine aktarmazsak, belirtilen sayfanın tam metnini TextFragmentCollection olarak arar ve Textfragment durumunu değiştirmek için koleksiyonda yineleyebiliriz. –

+0

Peki bu sınıfı kullanan çok satırlı sorun ne olacak? – NYTom

İlgili konular