في هذا البرنامج التعليمي ، سنركز على كيفية ** تحويل SVG إلى Presentation باستخدام Python ** دون أي اعتماد على PowerPoint. يمكن استخدام التطبيق داخل أي من البيئات المكونة من .NET core و Python في أنظمة التشغيل مثل Windows أو Linux أو macOS ** لتحويل SVG إلى PPTX في Python **.
خطوات تصدير SVG إلى PPTX في Python
- قم بتكوين البيئة على استخدم Aspose.Slides لـ Python عبر .NET في تطبيقك لتحويل SVG إلى عرض تقديمي
- قم بإنشاء عرض تقديمي افتراضي باستخدام مثيل للفئة Presentation
- قم بتحميل الشريحة الأولى من مجموعة شرائح العرض التقديمي
- افتح ملف SVG ، واقرأ محتواه كسلسلة وأدخل ذلك في مجموعة صور العرض التقديمي
- أدخل إطار صورة داخل الشريحة مع صورة SVG مضافة باستخدام مثيل IPictureFrame
- احفظ ملف PPTX مع صورة SVG على القرص
الخطوات البسيطة المذكورة أعلاه في * تصدير Python SVG كعرض تقديمي PPT * باستخدام واجهة API بسيطة. سنبدأ بإنشاء عرض تقديمي افتراضي باستخدام مثيل لفئة العروض التقديمية والوصول إلى أول شريحة افتراضية من مجموعة شرائح العرض التقديمي. سنقوم بعد ذلك بتحميل وقراءة محتوى ملف SVG كسلسلة من القرص وإضافة ذلك إلى IPPImage داخل مجموعة صور العرض التقديمي. أخيرًا ، باستخدام مثيل فئة IPictureFrame ، سيتم إضافة شكل إطار صورة يستخدم ملف SVG المضاف قبل حفظ العرض التقديمي الناتج على القرص.
كود لتحويل SVG إلى PPTX في Python
import aspose.slides as slides | |
filepath = "C://Words//" | |
#Applying the licence for Aspose.Slides to convert SVG to PPTX | |
svgtoSlidesLicense = slides.License() | |
svgtoSlidesLicense.set_license(filepath + "Conholdate.Total.Product.Family.lic") | |
# Make an empty presentation using the Presentation class object | |
with slides.Presentation() as sampleSvgPres: | |
#Access the first slide of the newly created presentation | |
slideForSvg = sampleSvgPres.slides[0] | |
#Load the SVG file content and insert that inside the presentation image collection | |
with open(filepath + "410.svg", 'r') as svgfile: | |
svgContent = svgfile.read().rstrip() | |
ppSVGImage = slides.SvgImage(svgContent) | |
#Add an SVG Image from the disk inside the images collection of the presentation | |
svgImageForSlide = sampleSvgPres.images.add_image(ppSVGImage) | |
#Insert a picture frame inside the shapes collection of the slide | |
slideForSvg.shapes.add_picture_frame(slides.ShapeType.RECTANGLE, 0, 0, 720, 540, svgImageForSlide) | |
#Save the presentation in PPTX format with an SVG image on the disk | |
slideForSvg.save(filepath + "PresentationWithSvg.pptx", slides.export.SaveFormat.PPTX) | |
print("Process Completed") | |
يوضح هذا الموضوع كيفية * إدراج SVG في العرض التقديمي باستخدام Python *. إذا كنت مهتمًا بمعرفة كيفية إدراج جدول داخل شريحة PowerPoint ، فراجع المقالة على كيفية إنشاء جدول في PowerPoint باستخدام Python.