في هذا الموضوع البسيط ، سنرشدك إلى ** كيفية إنشاء PowerPoint Presentation باستخدام Java ** في أنظمة تشغيل MS Windows أو macOS أو Ubuntu. يغطي هذا الموضوع الخطوات التفصيلية لإعداد البيئة وباستخدام بضعة أسطر من التعليمات البرمجية السهلة في العرض التقديمي * Java PPT * يمكن إنشاؤه.
خطوات إنشاء عرض تقديمي بوربوينت في جافا
- قم بتنزيل وتثبيت Aspose.Slides for Java من مستودع Maven
- إنشاء كائن فئة Presentation لإنشاء عرض تقديمي فارغ
- قم بإنشاء شريحة فارغة وأضف ذلك إلى مجموعة شرائح العرض التقديمي
- باستخدام أسلوب AddAutoShape ، قم بإدراج شكل مستطيل في الشريحة التي تم إنشاؤها حديثًا
- أدخل إطار نص باستخدام طريقة addTextFrame وقم بتعيين الخصائص المتعلقة بالنص
- احفظ العرض التقديمي على القرص بتنسيق PPTX
الخطوات المذكورة أعلاه في * Java تنشئ ملف PPTX * على القرص باستخدام واجهة API البسيطة وبدون الاعتماد على PowerPoint. أولاً ، يتم إنشاء عرض تقديمي فارغ باستخدام مثيل فئة العرض التقديمي ، والذي يتبعه إضافة شريحة فارغة داخل العرض التقديمي. بعد ذلك ، يتم إضافة إطار نص داخل الشكل ويتم تعيين خصائصه النصية قبل حفظ العرض التقديمي على القرص باستخدام طريقة الحفظ.
رمز لإنشاء عرض تقديمي PowerPoint باستخدام Java
import com.aspose.slides.FillType; | |
import com.aspose.slides.IAutoShape; | |
import com.aspose.slides.IPortionFormat; | |
import com.aspose.slides.ISlide; | |
import com.aspose.slides.ITextFrame; | |
import com.aspose.slides.License; | |
import com.aspose.slides.NullableBool; | |
import com.aspose.slides.Presentation; | |
import com.aspose.slides.SaveFormat; | |
import com.aspose.slides.ShapeType; | |
import com.aspose.slides.SlideLayoutType; | |
import java.awt.Color; | |
public class CreatePresentation { | |
public static void main(String[] args){ | |
// Setting the linence for the product | |
License SlidesLicense = new License(); | |
SlidesLicense.setLicense("Aspose.Total.lic"); | |
// Create an empty presentation using the Presentation class instance | |
Presentation presentation = new Presentation(); | |
// Insert a Blank slide inside the presentation | |
ISlide slide = presentation.getSlides().addEmptySlide(presentation.getLayoutSlides() | |
.getByType(SlideLayoutType.Blank)); | |
// Add an auto-shape of Rectangle type | |
IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Rectangle, 50, 150, 300, 0); | |
// Fill the shape with Green color | |
autoShape.getFillFormat().setFillType(FillType.Solid); | |
autoShape.getFillFormat().getSolidFillColor().setColor(Color.GREEN); | |
// Adding some text inside the shape | |
ITextFrame textFrame = autoShape.addTextFrame("This is Aspose.Slides"); | |
// Set text related properties | |
IPortionFormat portionFormat = textFrame.getParagraphs().get_Item(0) | |
.getPortions().get_Item(0).getPortionFormat(); | |
portionFormat.getFillFormat().setFillType(FillType.Solid); | |
portionFormat.getFillFormat().getSolidFillColor().setColor(Color.RED); | |
portionFormat.setFontBold(NullableBool.True); | |
portionFormat.setFontItalic(NullableBool.True); | |
portionFormat.setFontHeight(14); | |
// Save the generated presentation on the disk | |
presentation.save("NewJavaPresentation.pptx", SaveFormat.Pptx); | |
} | |
} |
في * عرض جافا * يمكن إنشاءه باستخدام بضعة أسطر من التعليمات البرمجية كما هو موضح في المثال أعلاه. يمكنك أيضًا حفظ العرض التقديمي بتنسيقات أخرى مثل PPT و PPS و PPSX و ODP و POT و POTX باستخدام العداد SaveFormat. يمكن تخصيص النص داخل العرض التقديمي باستخدام الخيارات المختلفة المعروضة بواسطة فئتي ParagraphFormat و PortionFormat والتي تتضمن تعيين الخيارات مثل التفاف النص ، والاحتواء التلقائي للنص ، والمسافات البادئة ، والهوامش ، والرموز النقطية ، وإبراز النص والتوسط.
في هذا الموضوع ، تعلمنا كيف يمكن إنشاء * عرض تقديمي باستخدام Java PowerPoint * بتنسيقات مختلفة. إذا كنت مهتمًا بتحويل شرائح العرض التقديمي إلى SVG ، فيرجى زيارة التفاصيل المذكورة في المقالة على كيفية تحويل PPTX إلى SVG باستخدام Java.