Class XWPFComments

java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFComments

public class XWPFComments extends POIXMLDocumentPart
specifies all of the comments defined in the current document
  • Constructor Details

    • XWPFComments

      public XWPFComments(POIXMLDocumentPart parent, PackagePart part)
      Construct XWPFComments from a package part
      Parameters:
      part - the package part holding the data of the footnotes,
    • XWPFComments

      public XWPFComments()
      Construct XWPFComments from scratch for a new document.
  • Method Details

    • onDocumentRead

      public void onDocumentRead() throws IOException
      read comments form an existing package
      Throws:
      IOException
    • addPictureData

      public String addPictureData(InputStream is, int format) throws InvalidFormatException, IOException
      Adds a picture to the comments.
      Parameters:
      is - The stream to read image from
      format - The format of the picture, see Document
      Returns:
      the index to this picture (0 based), the added picture can be obtained from getAllPictures() .
      Throws:
      InvalidFormatException - If the format of the picture is not known.
      IOException - If reading the picture-data from the stream fails.
      See Also:
    • addPictureData

      public String addPictureData(InputStream is, PictureType pictureType) throws InvalidFormatException, IOException
      Adds a picture to the comments.
      Parameters:
      is - The stream to read image from
      pictureType - The PictureType of the picture
      Returns:
      the index to this picture (0 based), the added picture can be obtained from getAllPictures() .
      Throws:
      InvalidFormatException - If the pictureType of the picture is not known.
      IOException - If reading the picture-data from the stream fails.
      Since:
      POI 5.2.3
    • addPictureData

      public String addPictureData(byte[] pictureData, int format) throws InvalidFormatException
      Adds a picture to the comments.
      Parameters:
      pictureData - The picture data
      format - The format of the picture, see Document
      Returns:
      the index to this picture (0 based), the added picture can be obtained from getAllPictures() .
      Throws:
      InvalidFormatException - If the format of the picture is not known.
    • addPictureData

      public String addPictureData(byte[] pictureData, PictureType pictureType) throws InvalidFormatException
      Adds a picture to the comments.
      Parameters:
      pictureData - The picture data
      pictureType - The PictureType of the picture.
      Returns:
      the index to this picture (0 based), the added picture can be obtained from getAllPictures() .
      Throws:
      InvalidFormatException - If the pictureType of the picture is not known.
      Since:
      POI 5.2.3
    • getAllPictures

      public List<XWPFPictureData> getAllPictures()
    • getCtComments

      public CTComments getCtComments()
      Gets the underlying CTComments object for the comments.
      Returns:
      CTComments object
    • setCtComments

      @Internal public void setCtComments(CTComments ctComments)
      set a new comments
    • getComments

      public List<XWPFComment> getComments()
      Get the list of XWPFComment in the Comments part.
    • getComment

      public XWPFComment getComment(int pos)
      Get the specified comment by position
      Parameters:
      pos - Array position of the comment
    • getCommentByID

      public XWPFComment getCommentByID(String id)
      Get the specified comment by comment id
      Parameters:
      id - comment id
      Returns:
      the specified comment
    • getComment

      public XWPFComment getComment(CTComment ctComment)
      Get the specified comment by ctComment
    • createComment

      public XWPFComment createComment(BigInteger cid)
      Create a new comment and add it to the document.
      Parameters:
      cid - comment Id
    • removeComment

      public boolean removeComment(int pos)
      Remove the specified comment if present.
      Parameters:
      pos - Array position of the comment to be removed
      Returns:
      True if the comment was removed.
    • getXWPFDocument

      public XWPFDocument getXWPFDocument()
    • setXWPFDocument

      public void setXWPFDocument(XWPFDocument document)