09-09-2010 10:57 AM
var word_doc = html_doc.transformDocument("application/msword");
private void transformDocument(NodeRef sourceNodeRef, NodeRef targetNodeRef, String sourceMimetype, String targetMimetype)
{
ContentService contentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
ContentReader reader = contentService.getReader(sourceNodeRef, ContentModel.PROP_CONTENT);
// If there is a reader…
if (reader.exists() && reader != null)
{
// …we create the transformer…
ContentTransformer transformer = contentService.getTransformer(sourceMimetype, targetMimetype);
// …and if it is valid…
if (transformer != null)
{
ContentWriter writer = contentService.getWriter(targetNodeRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype(targetMimetype);
try
{
// …we transform the content.
transformer.transform(reader, writer);
reader = writer.getReader();
if (!reader.exists())
throw new ContentIOException("The transformation did not write any content, yet: \n" + " transformer: " + transformer + "\n" + " temp writer: " + writer);
}
catch (ContentIOException e) {
logger.debug(e.getMessage());
}
}
else
logger.debug("Transformer wasn't created successfully…");
}
else
logger.debug("Reader doesn't exist…");
}
transformDocument(html_doc, word_doc, MimetypeMap.MIMETYPE_HTML, MimetypeMap.MIMETYPE_WORD);
09-10-2010 10:33 AM
var html_doc = … // Reference your doc
var word_doc = html_doc.transformDocument("application/msword");
ScriptNode html_doc = new ScriptNode(htmlDocNodeRef, serviceRegistry);
NodeRef word_doc = html_doc.transformDocument("application/msword").getNodeRef();
09-10-2010 10:39 AM
09-14-2010 05:42 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.