Python via Java kullanarak Sunumlarda Madde İşaretli ve Numaralı Listeleri Yönetme
Genel Bakış
Aspose.Slides for Python via Java, PowerPoint ve OpenDocument sunumlarında madde işaretli ve numaralı listeler oluşturmanıza ve biçimlendirmenize olanak tanır. Bir liste öğesi, madde işareti ayarları paragraf formatı aracılığıyla kontrol edilen bir paragraftır.
Paragraf düzeyindeki liste ayarlarına erişmek için Paragraph.getParagraphFormat yöntemini kullanın. Ana giriş noktası ParagraphFormat.getBullet, bu yöntem bir BulletFormat nesnesi döndürür. Bu nesne ile madde işareti türünü, sembolünü, resmini, rengini, boyutunu, numaralandırma stilini ve başlangıç numarasını ayarlayabilirsiniz.
Bu makale şu konuları göstermektedir:
- özel bir simge ile madde işaretli liste oluşturma
- resimli madde işareti oluşturma
- paragraf derinliğini ayarlayarak çok seviyeli liste oluşturma
- numaralı liste oluşturma
- varolan bir sunumda liste biçimlendirmesini inceleme ve değiştirme
- paragraf metniyle birlikte gerçek liste işaretçilerini ve numaralarını okuma
Madde İşaretli Liste Oluşturma
Madde işaretli bir liste oluşturmak için, bir TextFrame içine Paragraph nesneleri ekleyin ve BulletFormat.setType değerini BulletType.Symbol olarak ayarlayın. Ardından, madde işaretinin görünümünü kontrol etmek için BulletFormat.setChar, BulletFormat.getColor ve BulletFormat.setHeight yöntemlerini kullanabilirsiniz.
İşte bir slaytta madde işaretli liste oluşturmayı gösteren Python kodu:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import BulletType, NullableBool, Paragraph, Presentation, SaveFormat, ShapeType
from java.awt import Color
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
auto_shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 200, 50)
text_frame = auto_shape.getTextFrame()
text_frame.getParagraphs().clear()
bullet_color = Color(205, 92, 92)
first_paragraph = Paragraph()
first_paragraph.getParagraphFormat().getBullet().setType(BulletType.Symbol)
first_paragraph.getParagraphFormat().getBullet().setChar('*')
first_paragraph.getParagraphFormat().setIndent(15)
first_paragraph.getParagraphFormat().getBullet().setBulletHardColor(NullableBool.True_)
first_paragraph.getParagraphFormat().getBullet().getColor().setColor(bullet_color)
first_paragraph.getParagraphFormat().getBullet().setHeight(100)
first_paragraph.setText("The first paragraph")
text_frame.getParagraphs().add(first_paragraph)
second_paragraph = Paragraph()
second_paragraph.getParagraphFormat().getBullet().setType(BulletType.Symbol)
second_paragraph.getParagraphFormat().getBullet().setChar('*')
second_paragraph.getParagraphFormat().setIndent(15)
second_paragraph.getParagraphFormat().getBullet().setBulletHardColor(NullableBool.True_)
second_paragraph.getParagraphFormat().getBullet().getColor().setColor(bullet_color)
second_paragraph.getParagraphFormat().getBullet().setHeight(100)
second_paragraph.setText("The second paragraph")
text_frame.getParagraphs().add(second_paragraph)
presentation.save("symbol_bullets.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Sonuç:

Numaralı Liste Oluşturma
Öğe sırasının önemli olduğu durumlarda numaralı listeler kullanın. BulletFormat.setType değerini BulletType.Numbered olarak ayarlayın. Ayrıca bir numaralandırma biçimi seçmek için BulletFormat.setNumberedBulletStyle kullanabilir veya listenin 1 yerine başka bir değerden başlaması gerektiğinde BulletFormat.setNumberedBulletStartWith yöntemini kullanabilirsiniz.
İşte bir slaytta numaralı liste oluşturmayı gösteren Python kodu:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import BulletType, Paragraph, Presentation, SaveFormat, ShapeType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
auto_shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 90, 80)
text_frame = auto_shape.getTextFrame()
text_frame.getParagraphs().clear()
first_paragraph = Paragraph()
first_paragraph.getParagraphFormat().getBullet().setType(BulletType.Numbered)
first_paragraph.setText("Apple")
text_frame.getParagraphs().add(first_paragraph)
second_paragraph = Paragraph()
second_paragraph.getParagraphFormat().getBullet().setType(BulletType.Numbered)
second_paragraph.setText("Orange")
text_frame.getParagraphs().add(second_paragraph)
third_paragraph = Paragraph()
third_paragraph.getParagraphFormat().getBullet().setType(BulletType.Numbered)
third_paragraph.setText("Banana")
text_frame.getParagraphs().add(third_paragraph)
presentation.save("numbered_bullets.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Sonuç:

Resimli Madde İşareti Oluşturma
Aspose.Slides, düzenli bir madde işareti sembolünü bir görüntü ile değiştirebilmenizi sağlar. Resimli madde işaretleri, ikonlar veya küçük şeffaf PNG dosyaları gibi küçük boyutlarda okunabilirliğini koruyan basit görüntülerle en iyi şekilde çalışır.
Note
Eğer düzenli bir madde işareti sembolünü bir görüntü ile değiştirmeyi planlıyorsanız, şeffaf arka plana sahip basit bir grafik seçin. Bu tür görüntüler, özel madde işareti sembolleri olarak iyi çalışır.Resimli bir madde işareti oluşturmak için, bir görüntüyü Presentation.getImages metoduna ekleyin ve döndürülen görüntü nesnesini BulletFormat.getPicture ‘a atayın. Görüntüyü atamadan önce BulletFormat.setType değerini BulletType.Picture olarak ayarlayın.
Diyelim ki “image.png” adlı bir görüntümüz var:

İşte bir slaytta resimli madde işaretleri oluşturmayı gösteren Python kodu:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import BulletType, Images, Paragraph, Presentation, SaveFormat, ShapeType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
auto_shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 200, 50)
text_frame = auto_shape.getTextFrame()
text_frame.getParagraphs().clear()
image = Images.fromFile("image.png")
try:
bullet_image = presentation.getImages().addImage(image)
finally:
image.dispose()
first_paragraph = Paragraph()
first_paragraph.getParagraphFormat().getBullet().setType(BulletType.Picture)
first_paragraph.getParagraphFormat().getBullet().getPicture().setImage(bullet_image)
first_paragraph.getParagraphFormat().setIndent(15)
first_paragraph.getParagraphFormat().getBullet().setHeight(100)
first_paragraph.setText("The first paragraph")
text_frame.getParagraphs().add(first_paragraph)
second_paragraph = Paragraph()
second_paragraph.getParagraphFormat().getBullet().setType(BulletType.Picture)
second_paragraph.getParagraphFormat().getBullet().getPicture().setImage(bullet_image)
second_paragraph.getParagraphFormat().setIndent(15)
second_paragraph.getParagraphFormat().getBullet().setHeight(100)
second_paragraph.setText("The second paragraph")
text_frame.getParagraphs().add(second_paragraph)
presentation.save("picture_bullets.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Sonuç:

Çok Seviyeli Liste Oluşturma
Liste öğelerini farklı seviyelere yerleştirmek için ParagraphFormat.setDepth metodunu kullanın. Seviye 0 en üst seviyedir, seviye 1 onun altında iç içe bir seviyedir ve bu şekilde devam eder.
İşte çok seviyeli madde işaretli bir liste oluşturmayı gösteren Python kodu:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import Paragraph, Presentation, SaveFormat, ShapeType
presentation = Presentation()
try:
slide = presentation.getSlides().get_Item(0)
auto_shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 20, 20, 260, 110)
text_frame = auto_shape.getTextFrame()
text_frame.getParagraphs().clear()
first_paragraph = Paragraph()
first_paragraph.getParagraphFormat().setDepth(0)
first_paragraph.setText("My text - Depth 0")
text_frame.getParagraphs().add(first_paragraph)
second_paragraph = Paragraph()
second_paragraph.getParagraphFormat().setDepth(1)
second_paragraph.setText("My text - Depth 1")
text_frame.getParagraphs().add(second_paragraph)
third_paragraph = Paragraph()
third_paragraph.getParagraphFormat().setDepth(2)
third_paragraph.setText("My text - Depth 2")
text_frame.getParagraphs().add(third_paragraph)
fourth_paragraph = Paragraph()
fourth_paragraph.getParagraphFormat().setDepth(3)
fourth_paragraph.setText("My text - Depth 3")
text_frame.getParagraphs().add(fourth_paragraph)
presentation.save("multilevel_bullets.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Sonuç:

Varolan Bir Listeyi Değiştirme
Varolan bir sunumda liste biçimlendirmesini değiştirmek için hedef paragrafı erişin ve ParagraphFormat.getBullet ayarlarını güncelleyin. Listeleri oluşturmak için kullanılan aynı özellikler, PPT, PPTX veya ODP dosyasından yüklenen listeleri incelemek veya değiştirmek için de kullanılabilir.
İşte bir metin çerçevesindeki ilk paragrafı numaralı liste stiline dönüştüren Python kodu:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import BulletType, NumberedBulletStyle, Presentation, SaveFormat
presentation = Presentation("input.pptx")
try:
slide = presentation.getSlides().get_Item(0)
auto_shape = slide.getShapes().get_Item(0)
paragraph = auto_shape.getTextFrame().getParagraphs().get_Item(0)
paragraph.getParagraphFormat().getBullet().setType(BulletType.Numbered)
paragraph.getParagraphFormat().getBullet().setNumberedBulletStyle(NumberedBulletStyle.BulletRomanUCPeriod)
paragraph.getParagraphFormat().getBullet().setNumberedBulletStartWith(1)
paragraph.getParagraphFormat().setMarginLeft(30)
paragraph.getParagraphFormat().setIndent(-20)
presentation.save("updated_list.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
Gerçek Madde İşareti Değerlerini Okuma
Sunum içeriği çıkarılırken, liste işaretçilerini paragraf metniyle birlikte tutun. Etkili madde işareti biçimini elde etmek için ParagraphFormat.getEffective çağırın ve getBullet‘a erişin. getActualBulletValue‘yi okumadan önce getType‘ını kontrol edin.
Numaralı listeler için bu üç değeri ayırın:
getNumberedBulletStylebiçimi belirler, örneğin nokta ile biten Arap rakamları veya nokta ile biten küçük harfler.getNumberedBulletStartWithnumaralı paragraf grubunun başlangıç numarasını belirtir.getActualBulletValuebelirli bir paragraf için biçimlendirilmiş işareti döndürür. Örneğin, 5’ten başlayan bir listedeki ikinci öğe6.döndürür.
Her paragrafta getDepth değerini koruyarak iç içeleme seviyesini tutun. Gerçek işaretçi tam hiyerarşiyi kodlamaz: iç içe bir öğe c. döndürebilir, 6.c. gibi birleşik bir etiket yerine.
Aşağıdaki bağımsız örnek listeler oluşturur, bir sunuma kaydeder ve sunuyu yeniden yükleyerek her paragrafın metnini, derinliğini, madde işareti türünü ve gerçek değerini raporlar. Küçük mavi resim işaretçi, satır içi SVG’den oluşturulur.
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import BulletType, FillType, NullableBool, NumberedBulletStyle, Paragraph, Presentation, SaveFormat, ShapeType, SlideSizeScaleType, SvgImage
from java.awt import Color
presentation = Presentation()
try:
presentation.getSlideSize().setSize(720, 440, SlideSizeScaleType.DoNotScale)
slide = presentation.getSlides().get_Item(0)
shape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 30, 20, 660, 400)
shape.getFillFormat().setFillType(FillType.NoFill)
shape.getLineFormat().getFillFormat().setFillType(FillType.NoFill)
text_frame = shape.getTextFrame()
text_frame.getParagraphs().clear()
# Harici bir görüntü dosyası olmadan bir resim işareti oluştur.
svg = SvgImage("<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><rect width='16' height='16' rx='4' fill='#0078D4'/></svg>")
bullet_image = presentation.getImages().addImage(svg)
def add_paragraph(text, depth, bullet_type, start, style):
paragraph = Paragraph()
paragraph.setText(text)
paragraph_format = paragraph.getParagraphFormat()
paragraph_format.setDepth(depth)
paragraph_format.setMarginLeft(30 + depth * 40)
paragraph_format.setIndent(-28)
paragraph_format.setSpaceAfter(8)
paragraph_format.getDefaultPortionFormat().setFontHeight(22)
paragraph_format.getDefaultPortionFormat().getFillFormat().setFillType(FillType.Solid)
paragraph_format.getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK)
paragraph_format.getBullet().setType(bullet_type)
paragraph_format.getBullet().setBulletHardColor(NullableBool.True_)
paragraph_format.getBullet().getColor().setColor(Color.BLACK)
if bullet_type == BulletType.Numbered:
paragraph_format.getBullet().setNumberedBulletStyle(style)
paragraph_format.getBullet().setNumberedBulletStartWith(start)
elif bullet_type == BulletType.Symbol:
paragraph_format.getBullet().setChar('\u2022')
elif bullet_type == BulletType.Picture:
paragraph_format.getBullet().getPicture().setImage(bullet_image)
text_frame.getParagraphs().add(paragraph)
add_paragraph("First item", 0, BulletType.Numbered, 5, NumberedBulletStyle.BulletArabicPeriod)
add_paragraph("Second item", 0, BulletType.Numbered, 5, NumberedBulletStyle.BulletArabicPeriod)
add_paragraph("Nested item", 1, BulletType.Numbered, 3, NumberedBulletStyle.BulletAlphaLCPeriod)
add_paragraph("Next nested item", 1, BulletType.Numbered, 3, NumberedBulletStyle.BulletAlphaLCPeriod)
add_paragraph("Deep item", 2, BulletType.Numbered, 4, NumberedBulletStyle.BulletRomanLCPeriod)
add_paragraph("Back to top level", 0, BulletType.Numbered, 5, NumberedBulletStyle.BulletArabicPeriod)
add_paragraph("Symbol marker", 0, BulletType.Symbol, 1, NumberedBulletStyle.BulletArabicPeriod)
add_paragraph("No bullet", 0, BulletType.None_, 1, NumberedBulletStyle.BulletArabicPeriod)
add_paragraph("Picture marker", 0, BulletType.Picture, 1, NumberedBulletStyle.BulletArabicPeriod)
presentation.save("actual_bullet_values.pptx", SaveFormat.Pptx)
finally:
presentation.dispose()
loaded_presentation = Presentation("actual_bullet_values.pptx")
try:
loaded_shape = loaded_presentation.getSlides().get_Item(0).getShapes().get_Item(0)
type_names = {
BulletType.Numbered: "Numbered",
BulletType.Symbol: "Symbol",
BulletType.None_: "None",
BulletType.Picture: "Picture",
}
print("Text | Depth | Type | Actual value")
for paragraph in loaded_shape.getTextFrame().getParagraphs():
bullet = paragraph.getParagraphFormat().getEffective().getBullet()
bullet_type = bullet.getType()
if bullet_type in (BulletType.Numbered, BulletType.Symbol):
marker = bullet.getActualBulletValue()
elif bullet_type == BulletType.None_:
marker = f"{bullet.getActualBulletValue()} (no bullet)"
elif bullet_type == BulletType.Picture:
marker = f"{bullet.getActualBulletValue()} (image required)"
else:
marker = "unsupported bullet type"
type_name = type_names.get(bullet_type, "Unknown")
print(f"{paragraph.getText()} | {paragraph.getParagraphFormat().getDepth()} | {type_name} | {marker}")
finally:
loaded_presentation.dispose()
Kaynak listeler aşağıda gösterilmiştir.

Rapor, PowerPoint’te gösterilen işaretçilerle eşleşir:
Text | Depth | Type | Actual value
First item | 0 | Numbered | 5.
Second item | 0 | Numbered | 6.
Nested item | 1 | Numbered | c.
Next nested item | 1 | Numbered | d.
Deep item | 2 | Numbered | iv.
Back to top level | 0 | Numbered | 7.
Symbol marker | 0 | Symbol | •
No bullet | 0 | None | None (no bullet)
Picture marker | 0 | Picture | None (image required)
BulletType.None_ ve BulletType.Picture için getActualBulletValue boş bir dize yerine None (Java null) döndürür. Bu türleri ayrı ayrı işleyin: ilki işaretçi içermez, ikincisi ise madde işareti resmini ayrı olarak çıkarmayı gerektirir. Resimli madde işareti yalnızca bir metin işaretçisi çıkartılarak yeniden oluşturulamaz.
SSS
Madde işaretli ve numaralı listeler PDF veya resimlere dışa aktarılabilir mi?
Evet. Aspose.Slides, hedef format ilgili metin düzeni ve madde işareti özelliklerini desteklediğinde liste biçimlendirmesini korur.
Varolan sunumlardaki listeleri düzenleyebilir miyim?
Evet. Sunumu yükleyin, hedef paragrafı erişin, ParagraphFormat.getBullet ayarlarını inceleyin veya güncelleyin ve sunumu kaydedin.
Listeler Latin olmayan metin içerebilir mi?
Evet. Liste öğesi metni Unicode karakterler içerebilir, bu sayede çok dilli sunumlarda listeler oluşturabilirsiniz. Sunumda kullanılan yazı tiplerinin ihtiyacınız olan karakterleri desteklediğinden emin olun.