عارض العروض التقديمية

مثال حي

يمكنك تجربة عارض Aspose.Slides تطبيق مجاني لترى ما يمكنك تنفيذه باستخدام واجهة برمجة التطبيقات Aspose.Slides:

todo:image_alt_text

إنشاء صورة SVG من الشريحة

لإنشاء صورة SVG من أي شريحة مرغوبة باستخدام Aspose.Slides لجافا، يرجى اتباع الخطوات أدناه:

  • أنشئ مثيلًا من Presentation class.
  • احصل على مرجع الشريحة المرغوبة باستخدام معرفها أو فهرسها.
  • احصل على صورة SVG في تدفق الذاكرة.
  • احفظ تدفق الذاكرة في ملف.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("CreateSlidesSVGImage.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Create a memory stream object
    FileOutputStream svgStream = new FileOutputStream("Aspose_out.svg");

    // Generate SVG image of slide and save in memory stream
    sld.writeAsSvg(svgStream);

    svgStream.close();
} catch (IOException e) {
} finally {
    pres.dispose();
}

إنشاء SVG مع معرفات أشكال مخصصة

يمكن استخدام Aspose.Slides لجافا لإنشاء SVG من الشريحة مع معرف الشكل المخصص. لذلك، استخدم خاصية ID من ISvgShape، والتي تمثل معرفًا مخصصًا للأشكال في SVG الناتج. يمكن استخدام CustomSvgShapeFormattingController لتعيين معرف الشكل.

Presentation pres = new Presentation("pptxFileName.pptx");
try {
    FileOutputStream stream = new FileOutputStream("Aspose_out.svg");
    try {
        SVGOptions svgOptions = new SVGOptions();
        svgOptions.setShapeFormattingController(new CustomSvgShapeFormattingController());

        pres.getSlides().get_Item(0).writeAsSvg(stream, svgOptions);
    } finally {
        if (stream != null) stream.close();
    }
} catch (IOException e) {
} finally {
    pres.dispose();
}
class CustomSvgShapeFormattingController implements ISvgShapeFormattingController
{
    private int m_shapeIndex;

    public CustomSvgShapeFormattingController()
    {
        m_shapeIndex = 0;
    }
    
    public CustomSvgShapeFormattingController(int shapeStartIndex)
    {
        m_shapeIndex = shapeStartIndex;
    }

    public void formatShape(ISvgShape svgShape, IShape shape)
    {
        svgShape.setId(String.format("shape-%d", m_shapeIndex++));
    }
}

إنشاء صورة مصغرة للشرائح

تساعدك Aspose.Slides لجافا في إنشاء صور مصغرة للشرائح. لإنشاء الصورة المصغرة لأي شريحة مرغوبة باستخدام Aspose.Slides لجافا:

  1. أنشئ مثيلًا من Presentation class.
  2. احصل على مرجع لأي شريحة مرغوبة باستخدام معرفها أو فهرسها.
  3. احصل على الصورة المصغرة للشريحة المراجع على مقياس محدد.
  4. احفظ الصورة المصغرة بأي تنسيق صورة مرغوب.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailFromSlide.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // Create a full scale image
    IImage slideImage = sld.getImage(1f, 1f);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}

إنشاء صورة مصغرة بأبعاد محددة من قبل المستخدم

  1. أنشئ مثيلًا من Presentation class.
  2. احصل على مرجع لأي شريحة مرغوبة باستخدام معرفها أو فهرسها.
  3. احصل على الصورة المصغرة للشريحة المراجع على مقياس محدد.
  4. احفظ الصورة المصغرة بأي تنسيق صورة مرغوب.
// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailWithUserDefinedDimensions.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // User defined dimension
    int desiredX = 1200;
    int desiredY = 800;

    // Getting scaled value of X and Y
    float ScaleX = (float)(1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
    float ScaleY = (float)(1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;
    
    // Create a full scale image
    IImage slideImage = sld.getImage(ScaleX, ScaleY);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}

إنشاء صورة مصغرة من الشريحة في عرض الملاحظات

لإنشاء الصورة المصغرة لأي شريحة مرغوبة في عرض الملاحظات باستخدام Aspose.Slides لجافا:

  1. أنشئ مثيلًا من Presentation class.
  2. احصل على مرجع لأي شريحة مرغوبة باستخدام معرفها أو فهرسها.
  3. احصل على الصورة المصغرة للشريحة المرجعية على مقياس محدد في عرض الملاحظات.
  4. احفظ الصورة المصغرة بأي تنسيق صورة مرغوب.

تنتج الشيفرة أدناه صورة مصغرة للشرائح الأولى من عرض تقديمي في عرض الملاحظات.

// Instantiate a Presentation class that represents the presentation file
Presentation pres = new Presentation("ThumbnailWithUserDefinedDimensions.pptx");
try {
    // Access the first slide
    ISlide sld = pres.getSlides().get_Item(0);

    // User defined dimension
    int desiredX = 1200;
    int desiredY = 800;

    // Getting scaled value of X and Y
    float ScaleX = (float)(1.0 / pres.getSlideSize().getSize().getWidth()) * desiredX;
    float ScaleY = (float)(1.0 / pres.getSlideSize().getSize().getHeight()) * desiredY;

    RenderingOptions opts = new RenderingOptions();
    opts.getNotesCommentsLayouting().setNotesPosition(NotesPositions.BottomTruncated);
    
    // Create a full scale image
    IImage slideImage = sld.getImage(opts, ScaleX, ScaleY);

    // Save the image to disk in JPEG format
    try {
          slideImage.save("Thumbnail_out.jpg", ImageFormat.Jpeg);
    } finally {
         if (slideImage != null) slideImage.dispose();
    }
} finally {
    pres.dispose();
}