# เพิ่มลายน้ำให้กับไฟล์นำเสนอ PPTX โดยใช้ Python

> ซอร์สโค้ด Python สำหรับเพิ่มลายน้ำในงานนำเสนอ PPTX

Source: https://products.aspose.com/slides/th/python-net/watermark/pptx/
Updated: 2023-06-14



## เพิ่มลายน้ำในงานนำเสนอ PPTX ผ่าน Python

เมื่อใช้ Aspose.Slides for Python via .NET คุณสามารถเพิ่มลายน้ำให้กับงานนำเสนอ PPTX ลายน้ำเป็นส่วนสำคัญของงานนำเสนอ ใช้เพื่อป้องกันเนื้อหาของงานนำเสนอจากการคัดลอกหรือนำไปใช้โดยไม่ได้รับอนุญาต ลายน้ำคือรูปภาพหรือข้อความที่มองเห็นหรือมองไม่เห็นที่วางอยู่ด้านบนของงานนำเสนอ สามารถใช้เพื่อระบุเจ้าของงานนำเสนอและเพื่อป้องกันการใช้งานโดยไม่ได้รับอนุญาต ลายน้ำสามารถใช้เพื่อเพิ่มความเป็นมืออาชีพให้กับงานนำเสนอและทำให้ดูสวยงามยิ่งขึ้น

### เพิ่มลายน้ำข้อความใน PPTX โดยใช้ Python

```py

import aspose.slides as slides
import aspose.pydrawing as draw

with slides.Presentation() as pres:
    master = pres.masters[0]

    watermarkShape = master.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 0, 0, 100, 100)
    watermarkTextFrame = watermarkShape.add_text_frame("Watermark")

    # Lock Watermark from Editing
    watermarkShape.shape_lock.select_locked = True
    watermarkShape.shape_lock.size_locked = True
    watermarkShape.shape_lock.text_locked = True
    watermarkShape.shape_lock.position_locked = True
    watermarkShape.shape_lock.grouping_locked = True

    # Set Text Watermark Transparency
    watermarkPortion = watermarkTextFrame.paragraphs[0].portions[0]
    watermarkPortion.portion_format.fill_format.fill_type = slides.FillType.SOLID
    watermarkPortion.portion_format.fill_format.solid_fill_color.color = draw.Color.from_argb(150, 200, 200, 200)

    # Set Font Size of Text Watermark
    watermarkPortion.portion_format.font_height = 16

    pres.save("watermark.pptx", slides.export.SaveFormat.PPTX)
```

### เพิ่มลายน้ำรูปภาพในงานนำเสนอ PPTX โดยใช้ Python

```py

import aspose.slides as slides

with slides.Presentation() as presentation:
    with open("image1.png", "rb") as fs:
        data = fs.read()
    image = presentation.images.add_image(data)

    master = presentation.masters[0]
    watermarkShape = master.shapes.add_auto_shape(slides.ShapeType.RECTANGLE, 0, 0, image.width, image.height)

    watermarkShape.fill_format.fill_type = slides.FillType.PICTURE
    watermarkShape.fill_format.picture_fill_format.picture.image = image
    watermarkShape.fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.STRETCH

    presentation.save("watermark2.pptx", slides.export.SaveFormat.PPTX)
```

## วิธีเพิ่มลายน้ำใน PPTX ผ่าน Python

นี่คือขั้นตอนในการเพิ่มลายน้ำข้อความในไฟล์ PPTX

โหลด PPTX ด้วยอินสแตนซ์ของงานนำเสนอ

เลือกงานนำเสนอหลัก

เพิ่มประเภทรูปร่างโดยใช้วิธี AddAutoShape

เพิ่มข้อความลายน้ำโดยใช้วิธี AddTextFrame

บันทึกผลลัพธ์ในรูปแบบ PPTX

## รูปแบบอื่นๆ ที่รองรับ
