Skip to content
Snippets Groups Projects
Commit 76c55612 authored by felmer's avatar felmer
Browse files

Merge branch 'master' of sissource.ethz.ch:sispub/openbis

parents 7cb912b7 192aa705
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,7 @@ public class DOCXBuilder
docx.addHeader("MetaA");
docx.addProperty("PropertyA", "ValueA");
docx.addProperty("PropertyB", "ValueB");
docx.addProperty("PropertyC",
"<p>I am normal</p><p style=\"color:red;\">I am red</p><p style=\"color:blue;\">I am blue</p><p style=\"font-size:36px;\">I am big</p>");
docx.addProperty("PropertyC", "<p>I am normal</p><p style=\"color:red;\">I am red</p><p style=\"color:blue;\">I am blue</p><p style=\"font-size:36px;\">I am big</p>");
FileOutputStream out = new FileOutputStream(new File("wordFromHTML.docx"));
out.write(docx.getDocBytes());
......
......@@ -72,6 +72,8 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions import SampleT
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetTypeSearchCriteria;
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions import DataSetTypeFetchOptions;
from ch.ethz.sis.openbis.generic.asapi.v3.dto.property import DataType
#V3 API - Files
from ch.ethz.sis.openbis.generic.dssapi.v3 import IDataStoreServerApi;
from ch.ethz.sis.openbis.generic.dssapi.v3.dto.datasetfile.search import DataSetFileSearchCriteria;
......@@ -103,6 +105,12 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset import DataSet
#DOCX
from ch.ethz.sis import DOCXBuilder
#Images export for word
from org.jsoup import Jsoup;
from org.jsoup.nodes import Document;
from org.jsoup.nodes import Element;
from org.jsoup.select import Elements;
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
......@@ -489,6 +497,12 @@ def getDOCX(entityObj, v3, sessionToken, isHTML):
propertyType = propertyAssigment.getPropertyType();
if propertyType.getCode() in properties:
propertyValue = properties[propertyType.getCode()];
if propertyType.getDataType() is DataType.MULTILINE_VARCHAR:
doc = Jsoup.parse(propertyValue);
imageElements = doc.select("img");
for imageElement in imageElements:
imageSrc = imageElement.attr("src");
propertyValue = propertyValue.replace(imageSrc, DataStoreServer.getConfigParameters().getServerURL() + imageSrc + "?sessionID=" + sessionToken);
if propertyValue != u"\uFFFD(undefined)":
docxBuilder.addProperty(propertyType.getLabel(), propertyValue);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment