Class MailBodyConverterUtil
- java.lang.Object
-
- com.levigo.jadice.server.mail.worker.internal.util.MailBodyConverterUtil
-
public class MailBodyConverterUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
appendAdditionalBodyPages(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc, org.apache.pdfbox.pdmodel.PDDocument pdfBodyWithOffsetDoc)
static void
convertHTMLXmlHeaderToPDF(OutputStream out, com.levigo.jadice.server.mail.worker.internal.FopPDFContext context, Stream sHeader, QualifiedLogEventReceiver qualifiedLogEventReceiver, MailBodyCreatorNode node, String language)
protected static com.levigo.jadice.server.mail.worker.internal.CoverPDFDocWithFopContext
createPlainCoverWithPageMetadata(OutputStream os, int pageOffset, StreamDescriptor headerInfo, MailBodyCreationContext mailBodyCreationContext)
Create a plain cover for the given header information and also return the pdf document's fop context.static Stream
createXmlHeader(StreamDescriptor descriptor)
Extract the mail header information (FROM, TO, subject, ...) from aStreamDescriptor
.static com.levigo.jadice.server.mail.worker.internal.CoverPDFDocWithFopContext
generateMailMetaCoverPageDoc(int attachmentOffset, StreamDescriptor headerInfo, MailBodyCreationContext mailBodyCreationContext)
static int
getPageCount(Stream pdfStream)
Count the number of pages of an XML streamstatic Stream
mergeAttachment(Stream s, int pageOffset, boolean hasAttachments, AttachmentDirectory attachmentDirectory)
Merges theAttachmentDirectory
data and the header of the given Mail.protected static void
mergeFirstBodyPageWithLastMailMetaPage(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc, org.apache.pdfbox.pdmodel.PDDocument pdfBodyWithOffsetDoc)
static org.apache.pdfbox.pdmodel.PDDocument
mergeMailMetaAndBody(org.apache.pdfbox.pdmodel.PDDocument mailMetaDataCoverPageDoc, com.levigo.jadice.document.io.SeekableInputStream bodyPDFStream, MailBodyCreationContext mailBodyCC)
-
-
-
Method Detail
-
createXmlHeader
public static Stream createXmlHeader(StreamDescriptor descriptor) throws FactoryConfigurationError, IOException, XMLStreamException
Extract the mail header information (FROM, TO, subject, ...) from aStreamDescriptor
.- Parameters:
descriptor
- theStreamDescriptor
containing the mail header- Returns:
- an XML stream containing the mail header.
- Throws:
FactoryConfigurationError
IOException
XMLStreamException
-
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 occurscom.levigo.jadice.document.JadiceException
- In some circumstances
-
mergeAttachment
public static Stream mergeAttachment(Stream s, int pageOffset, boolean hasAttachments, AttachmentDirectory attachmentDirectory) throws XMLStreamException, IOException
Merges theAttachmentDirectory
data and the header of the given Mail.- Parameters:
s
- The Mail bodyStream
that contains the information of the mail headerpageOffset
- 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 failsIOException
- If an I/O error occurs
-
convertHTMLXmlHeaderToPDF
public static void convertHTMLXmlHeaderToPDF(OutputStream out, com.levigo.jadice.server.mail.worker.internal.FopPDFContext context, Stream sHeader, QualifiedLogEventReceiver qualifiedLogEventReceiver, MailBodyCreatorNode node, String language) throws TransformerException, IOException, SAXException
-
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 DocumentpageOffset
- 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
-
-