Εργασία με σχόλια και σημειώσεις ομιλητών Aspose.Slides FOSS για Java

Aspose.Slides FOSS for Java supports two types of annotations: Σκηνές Slide Comments (που είναι διαθέσιμο σε λειτουργία αναθεώρησης) και Μιλάμε για τα σημειώματα (Εμφάνιση στο Πίνακας και το Σημείωμα).


Κριτικές Comments

Οι σχολιασμοί είναι συνδεδεμένοι με ένα σάιτ και σχετίζονται με έναν συγγραφέα. prs.getCommentAuthors() Η συλλογή διαχειρίζεται όλους τους συγγραφείς, κάθε συγγραφή έχει ένα getComments() Συλλογή για προσθήκη και ανάγνωση σχολίων.

Προσθέστε ένα σχόλιο

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.drawing.PointF;
import org.aspose.slides.foss.export.SaveFormat;
import java.time.LocalDateTime;

try (Presentation prs = new Presentation()) {
    // Create a comment author with initials
    var author = prs.getCommentAuthors().addAuthor("Jane Smith", "JS");

    var slide = prs.getSlides().get(0);

    // Add a comment at position (2.0, 2.0) centimeters from the slide top-left
    author.getComments().addComment(
        "Please review the figures on this slide",
        slide,
        new PointF(2.0f, 2.0f),
        LocalDateTime.now()
    );

    prs.save("commented.pptx", SaveFormat.PPTX);
}

Η PointF Η θέση είναι σε εκατοστά από την κορυφή αριστερή γωνία του σκιού (εσωτερικά αποθηκευμένο ως EMU; 1 cm = 360.000 EMI).Πολλοί σχόλιο μπορούν να προστιθέσουν στο ίδιο σιντ κάνοντας κλήση addComment() και πάλι.

Πολλοί συγγραφείς και σχόλια

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.drawing.PointF;
import org.aspose.slides.foss.export.SaveFormat;
import java.time.LocalDateTime;

try (Presentation prs = new Presentation()) {
    var author1 = prs.getCommentAuthors().addAuthor("Alice Brown", "AB");
    var author2 = prs.getCommentAuthors().addAuthor("Bob Davis", "BD");

    var slide = prs.getSlides().get(0);

    author1.getComments().addComment("Initial draft", slide, new PointF(1.0f, 1.0f), LocalDateTime.now());
    author2.getComments().addComment("Approved", slide, new PointF(3.0f, 1.0f), LocalDateTime.now());

    prs.save("multi-author.pptx", SaveFormat.PPTX);
}

Διαβάστε σχόλια από ένα υπάρχον αρχείο

import org.aspose.slides.foss.Presentation;

try (Presentation prs = new Presentation("commented.pptx")) {
    for (int a = 0; a < prs.getCommentAuthors().size(); a++) {
        var author = prs.getCommentAuthors().get(a);
        System.out.println("Author: " + author.getName() + " (" + author.getInitials() + ")");
        for (int c = 0; c < author.getComments().size(); c++) {
            var comment = author.getComments().get(c);
            System.out.println("  " + comment.getText());
        }
    }
}

Ομιλητής σημειώσεις

Οι σημειώσεις ομιλητών αποθηκεύονται σε ανά-σύνδεση μέσω ενός NotesSlide Ετικέτα: Διαθέσιμο μέσω slide.getNotesSlideManager().

Προσθήκη σημειώσεων ομιλητών σε ένα Slide

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.export.SaveFormat;

try (Presentation prs = new Presentation()) {
    var slide = prs.getSlides().get(0);
    slide.getShapes().addAutoShape(ShapeType.RECTANGLE, 50, 50, 400, 200);

    // Create the notes slide and set text
    var notes = slide.getNotesSlideManager().addNotesSlide();
    notes.getNotesTextFrame().setText(
        "Mention the Q3 revenue increase on this slide. Emphasize the 24% growth."
    );

    prs.save("with-notes.pptx", SaveFormat.PPTX);
}

Απλό παράδειγμα σημειώσεων

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.export.SaveFormat;

try (Presentation prs = new Presentation()) {
    var slide = prs.getSlides().get(0);
    slide.getShapes().addAutoShape(ShapeType.RECTANGLE, 100, 100, 500, 250)
         .addTextFrame("Main Content");

    var notes = slide.getNotesSlideManager().addNotesSlide();
    notes.getNotesTextFrame().setText("These are the speaker notes for this slide.");

    prs.save("notes.pptx", SaveFormat.PPTX);
}

Δείτε αν υπάρχει ήδη ένα σάιτ σημειώσεων

getNotesSlideManager().getNotesSlide() Επιστροφή null Αν δεν έχει δημιουργηθεί ακόμα κανένα σημειωματάριο:

import org.aspose.slides.foss.Presentation;

try (Presentation prs = new Presentation("existing.pptx")) {
    for (int i = 0; i < prs.getSlides().size(); i++) {
        var slide = prs.getSlides().get(i);
        var existingNotes = slide.getNotesSlideManager().getNotesSlide();
        if (existingNotes != null) {
            String text = existingNotes.getNotesTextFrame().getText();
            System.out.println("Slide " + (i + 1) + " notes: " + text);
        } else {
            System.out.println("Slide " + (i + 1) + ": no notes");
        }
    }
}

Προσθήκη σημειώσεων σε Multiple Slides

import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.export.SaveFormat;

String[] noteTexts = {
    "Opening remarks: introduce the agenda.",
    "Key metrics: emphasize Q4 results.",
    "Closing: call to action.",
};

try (Presentation prs = new Presentation()) {
    // Add slides 2 and 3
    var layout = prs.getSlides().get(0).getLayoutSlide();
    prs.getSlides().addEmptySlide(layout);
    prs.getSlides().addEmptySlide(layout);

    for (int i = 0; i < prs.getSlides().size(); i++) {
        var slide = prs.getSlides().get(i);
        slide.getShapes().addAutoShape(ShapeType.RECTANGLE, 50, 50, 600, 300)
             .addTextFrame("Slide " + (i + 1));
        var n = slide.getNotesSlideManager().addNotesSlide();
        n.getNotesTextFrame().setText(noteTexts[i]);
    }

    prs.save("all-notes.pptx", SaveFormat.PPTX);
}

Δείτε επίσης

 Ελληνικά