Class MailBodyConverterUtil


  • public class MailBodyConverterUtil
    extends Object
    • Method Detail

      • getPageCount

        public static int getPageCount​(Stream pdfStream)
                                throws IOException,
                                       com.levigo.jadice.document.JadiceException
        Count the number of pages of an XML stream
        Parameters:
        pdfStream - a PDF stream
        Returns:
        the stream's number of pages
        Throws:
        IOException - If an I/O error occurs
        com.levigo.jadice.document.JadiceException - In some circumstances
      • mergeAttachment

        public static Stream mergeAttachment​(Stream s,
                                             int pageOffset,
                                             boolean hasAttachments,
                                             AttachmentDirectory attachmentDirectory)
                                      throws XMLStreamException,
                                             IOException
        Merges the AttachmentDirectory data and the header of the given Mail.
        Parameters:
        s - The Mail body Stream that contains the information of the mail header
        pageOffset - The offset for the "table of contents" of the attachments (i.e. if the mail body + title page are n sides long -> pageOffset = n)
        Returns:
        the XML data of mail header together with the attachment summary
        Throws:
        XMLStreamException - If the creation of an XMLStreamReader fails
        IOException - If an I/O error occurs
      • generateMailMetaCoverPageDoc

        public static com.levigo.jadice.server.mail.worker.internal.CoverPDFDocWithFopContext generateMailMetaCoverPageDoc​(int attachmentOffset,
                                                                                                                           StreamDescriptor headerInfo,
                                                                                                                           MailBodyCreationContext mailBodyCreationContext)
                                                                                                                    throws Throwable
        Throws:
        Throwable
      • createPlainCoverWithPageMetadata

        protected static com.levigo.jadice.server.mail.worker.internal.CoverPDFDocWithFopContext createPlainCoverWithPageMetadata​(OutputStream os,
                                                                                                                                  int pageOffset,
                                                                                                                                  StreamDescriptor headerInfo,
                                                                                                                                  MailBodyCreationContext mailBodyCreationContext)
                                                                                                                           throws Throwable
        Create a plain cover for the given header information and also return the pdf document's fop context.
        Parameters:
        os - the outputStream containing the PDF Document
        pageOffset - the offset of the attachments (page n)
        Returns:
        a PDF Document with the original fop context that was used to create the pdf page.
        Throws:
        Throwable - in case of failure
      • mergeMailMetaAndBody

        public static org.apache.pdfbox.pdmodel.PDDocument mergeMailMetaAndBody​(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc,
                                                                                com.levigo.jadice.document.io.SeekableInputStream bodyPDFStream,
                                                                                MailBodyCreationContext mailBodyCC)
                                                                         throws IOException
        Throws:
        IOException
      • appendAdditionalBodyPages

        protected static void appendAdditionalBodyPages​(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc,
                                                        org.apache.pdfbox.pdmodel.PDDocument pdfBodyWithOffsetDoc)
      • mergeFirstBodyPageWithLastMailMetaPage

        protected static void mergeFirstBodyPageWithLastMailMetaPage​(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc,
                                                                     org.apache.pdfbox.pdmodel.PDDocument pdfBodyWithOffsetDoc)
                                                              throws IOException
        Throws:
        IOException