Bu konu, Python kullanarak PowerPoint’te metni vurgulama sürecini içerir. IDE’yi ayarlamaya yönelik ayrıntıları, programlama adımlarının bir listesini ve Python** kullanarak bir **presentation vurgulama aracı geliştirmek için bir örnek kodu kapsar. Farklı seçenekleri kullanarak vurgulamak için istediğiniz metni aramayı öğreneceksiniz.
Python kullanarak PowerPoint’te Vurgulama Adımları
- Metni vurgulamak için .NET aracılığıyla Python için Aspose.Slides‘ı kullanacak ortamı oluşturun
- Presentation sınıfının bir örneğini kullanarak boş bir sunu oluşturun ve ilk varsayılan slaydına erişin
- Dikdörtgen türünden bir Autoshape ekleyin ve örnek metni içeren bir metin çerçevesi ekleyin
- Highlight_text yöntemini kullanarak eklenen metin çerçevesinin içindeki istenen metni vurgulayın
- Sunuyu vurgulanan metinle birlikte diske kaydedin
Yukarıda belirtilen adımlar Python* kullanarak bir PPTX veya *PPT vurgulayıcı geliştirme sürecini özetlemektedir. Bir PowerPoint sunum dosyası yükleyebilir veya Sunum sınıfının bir örneğini kullanarak yeni bir dosya oluşturabilir ve ilk varsayılan slaydına erişebilirsiniz. Metin çerçevesine bazı örnek metinler ekleyerek slaytta bir otomatik şekil oluştururuz, ardından vurgu_metin yöntemini kullanarak metnin gerekli kısmını vurgularız. Son olarak, vurgulanan metnin bulunduğu sunum diske kaydedilecektir.
Python kullanarak PowerPoint Sunum Vurgulayıcı Geliştirme Kodu
import aspose.pydrawing as draw | |
import aspose.slides as slides | |
filepath = "C://Words//" | |
# Applying the license for Aspose.Slides | |
LicForHighlight = slides.License() | |
LicForHighlight.set_license(filepath + "Total.lic") | |
# Generate an default empty presentation using the Presentation class object | |
with slides.Presentation() as samplePres: | |
# Load the first default slide of the newly created presentation | |
slideForText = samplePres.slides[0] | |
# Insert an auto-shape to highlight text | |
aShapeHighlight = slideForText.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 50, 150, 300, 200) | |
# Set the auto-shape fill type to no fill color | |
aShapeHighlight.fill_format.fill_type = slides.FillType.NO_FILL | |
#Insert sample text inside the text frame | |
aShapeHighlight.add_text_frame("students of the class. students to join session") | |
#Add the text highlight options | |
highlightOptions = slides.TextHighlightingOptions() | |
highlightOptions.whole_words_only = False | |
highlightOptions.case_sensitive = True | |
# Highlight all words inside the shape text frame containing 'students' | |
aShapeHighlight.text_frame.highlight_text("students", draw.Color.red, highlightOptions) | |
#Save the presentation with highlighted text on the disk | |
samplePres.save(filepath + "HighlightText.pptx", slides.export.SaveFormat.PPTX) | |
print("Done") |
Bu örnek, Python kullanarak PowerPoint’te nasıl vurgulanacağını gösterir. Hedef dizeyi içeren tüm dizeleri vurgulamanız gerekiyorsa, hedef dize ve vurgu metniyle birlikte Highlight_text() yöntemini kullanın. Metni aramak ve vurgulamak için yalnızca bütün_kelimeler ve büyük/küçük harfe duyarlı gibi metni vurgulama ayarlarını kullanarak metin vurgulamasını geliştirebilirsiniz.
Bu basit konu bize Python* kullanarak bir *sunum vurgulama aracı geliştirmeyi öğretti. Bir sunumdaki metnin üzerini çizmek istiyorsanız Python kullanarak PPTX’te metin nasıl çizilir ile ilgili makaleye bakın.