Apache OpenOffice (AOO) Bugzilla – Issue 22012
XHTML doesn't export embedded graphics / images
Last modified: 2008-09-09 13:13:29 UTC
xthml export of writer docs doesn't export graphics, img etc, inside the document. It yields something like <img width="59" height="81" src="" class="fr2">.
Confirmed on OOo 1.1.0 on linux
Reporter: I have exported a XHTML file with an imnage inside. I just used Insert -> Graphics -> From File and File -> Export -> selected XHTML and it worked fine. How do you inserted the image? A clear description in future would be fine (and I don't know how 'cphennesy' could confirm it because I have used also Linux.
Created attachment 10898 [details] Writer->XHTML exported file with an image included
1. I followed what Joerg said but didnot worked. My machine is Win/XP professional. I got the same thing. 2. The images were included in the document because I am trying to convert my old word for mac documents. OOo writer reads all the documents and saves them in sxw format. (Thou there are some image placement problems, it works _well_.) BTW when I look at the content.xml I see that those images are in pct and object (ole) format. I can send an example doc if needed.
Reporter: Yes, please do it. Everytime you file a bug where a document is affected you should send the source and the result as an attachment. It is much more easier to resolve such issues.
Reporter: Ahhh, I read "content.xml" in your sentence. You mean not XHTML you mean trasnformation from mac:Word documents -> OpenOffice.org|StarOffice (.sxw) file format makes trouble, am I right? If so, we need the documents but you are in the wrong component. I will put it then in the correct one and will change also the title.
Created attachment 10910 [details] an example doc
mac:word -> OpenOffice (.sxw) conversion works _well_. As you can see there is some layout problems but they are not important at the moment. The problem is that when I try to export the document to xhtml the resultant document contains img tags like <img width="59" height="81" src="" class="fr2"> for the images.
Reporter: It is very easy: The EMBEDDED images are not exported by the external filter (XSLT stylesheet). Linked images are no problem. XHTML is a SAMPLE for the XSLT |external XML filter technology OOo 1.1.0 supports since that version. Thank you for reporting that issue!
Not invalid. It is an issue in the XSLT stylesheet AFAIK.
cc: Swante.
changed owner for piece of cake - thanks ;)
change owner, retry
Thank you for reporting the bug. I will fix it and provide a downloadable on OOo, the latter might cost some time, but I anounce it in the bug, when managed. A mailing list might be of interest, to get a notify of the latest updates.
Two tips for a better transforming of the orginal test document: 1.) The embedded pictures should be better of type PNG (or JPEG, GIF) than SVM and PCT. Otherwise the browsers gonna have problems to show them. (A different approach would be to express the math formulas by the office, but once you created the pictures already, it might be easier to transform the pictures). 2.) If you want to have a XHTML output close to the layout of your original office document, you might use a table in the office document to express the two columns. Otherwise you have to tweak the transformation to create these two columns. ;)
1. Exported images should be of type that browsers can handle. 2. I have no problem with the resultant layout. Once I get the xhtml document I can play with it:-D Note also that some of the graphics objects are OLE objects.
> 1. Exported images should be of type that browsers can handle. You are right, but XSLT itself does not provide this functionality, the automatic conversion would be a feature request itself, I will discuss it with the developer of the application side. But having our current feature list in mind, I see little change that this will be implemented soon, so you better convert the graphics by yourself ;) > Note also that some of the graphics objects are OLE objects. aye, yes thanks for the warning ;)
- (fixed) Embedded images working again - (fixed) ContentTable URL of Master document remains relative URL (feature only available with JAVA helper classes, currently not part of office filter) - (new feature) Added default implementation of <draw:object-ole> element, which represents objects that only have a binary representation. By default they will be handled like an <draw:image> element. This bug is not in a CWS (child work space) yet and the documentation on http://xml.openoffice.org/sx2ml/ has not been updated, either.
Swante/Lars: Just a question. Does it make sense to fix that issue in a OOo 1.1.2? It's just the stylesheet AFAIK. It could demonstrate better the benefit of using XSLT for converting documents...
You are totally right, as it is already fixed, this issue is only waiting for some others to join together in a CWS into the next version. As soon I am ready, we gonna have a chat about quality assurance ;)
Unfortunately the transformations need to get parameters from the filter environements to be able to show the embedded graphics. In this case a JAR URL is to the zipped document is necessary, as the graphics won't be unpacked by XSLT. Added dependency to the parameter enhancement i24398 Furthermore, in a patch only changes on the exisiting documents will be commited. In our case the whole filter (stylesheets) have been refactored and overworked, so I changed target to OOo2.0.
As this issue is also addressable for embedded pictures of any arbitrary document format, which can be imported into the office. LO and I decided to save the images into a directory quite similar named to the output file name aside of the output (similar to browsers). AFAIK LO won't be able to fixed this before OpenOffice 2.0
Lars this is of minor impact and you are able fix for the upcoming release, it would be great! When you are ready, please give me feed back about the parameter providing the image path (e.g. imageBaseURL) you going to provide for the stylesheets.
*** Issue 50855 has been marked as a duplicate of this issue. ***
Hi all, can someone please tell me the actual status of this issue? added jrahemipour to cc
The XHTML export filter as sample filter has currently a quite low priority. Sorry, there is no ongoing work for this issue. With very little change it might be done for OOo3.0. SUS->LO: AFAIK I have inherit these framework issues know, assigned to me.
*** Issue 67759 has been marked as a duplicate of this issue. ***
changed title to find it better in queries.
I believe this is a more general problem. "Save as HTML" has some very comfortable functions to handle embedded pictures _and_embedded_OLE_objects_, so from spreadsheets and charts gif images will be crated during HTML export; these images will be shown in the exported HTML document. IMHO it would be fine to have something similar for XHTML export.
*** Issue 72924 has been marked as a duplicate of this issue. ***
This issue effects more than graphics; it seems to prevent the export of virtually everything but text. I was surprised that the issue has been around as long as it has (5 years) while arguably being so basic to the operation of the product in an open environment (stylesheet wise). Specifically, the use of OOo for Mathematics or any area where equations are needed becomes problematic because OOo only default exports such equations as images. I am not clear on whether OOo stores equations in text format or as xml, but in either case one would think it would be critical for an export to xhtml to include the MathML. I did notice that an export to docBook xml format places the equation text in paran tags.....
i can try pack images into src="data:image/*;binary64,{base64-encoded-image}"
just added this lines <xsl:when test="self::draw:image[office:binary-data]"> <xsl:text>data:image/*;base64,</xsl:text><xsl:value-of select="office:binary-data"/> </xsl:when> into named template "create-href" in export/common/body.xsl - look like it work just fine (see odt&html attachment) here modified template <xsl:template name="create-href"> <xsl:param name="href"/> <xsl:choose> <!-- internal OOo URL used in content tables --> <xsl:when test="contains($href, '%7Coutline')"> <!-- the simple workaround for content tables in a single document is to create create an anchor from every heading element work-around downside: Multiple identical headings won't refer always to the first. --> <xsl:text>#</xsl:text> <xsl:variable name="title"> <xsl:apply-templates mode="concatenate"/> </xsl:variable> <xsl:value-of select="translate($title, '.,;: %()[]/\+', '_____________')"/> </xsl:when> <xsl:when test="self::draw:image[office:binary-data]"> <xsl:text>data:image/*;base64,</xsl:text><xsl:value-of select="office:binary-data"/> </xsl:when> <xsl:otherwise> <xsl:choose> <!-- in case of packed open office document --> <xsl:when test="starts-with($sourceBaseURL, 'jar:') or $isPackageFormat"> <xsl:choose> <!-- for images relative to open office document --> <xsl:when test="starts-with($href, '../')"> <!-- creating an absolute http URL to the packed image file (removing the '.')--> <xsl:value-of select="concat(substring-after(substring-before($sourceBaseURL, '!'), 'jar:'), '/', $href, $optionalURLSuffix)"/> </xsl:when> <!-- for absolute URLs & absolute paths --> <xsl:when test="contains($href, ':') or starts-with($href, '/')"> <xsl:value-of select="concat($href, $optionalURLSuffix)"/> </xsl:when> <!-- for images jared in open office document --> <xsl:otherwise> <xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> <!-- for absolute URLs & Paths --> <xsl:when test="contains($href, ':') or starts-with($href, '/')"> <xsl:value-of select="concat($href, $optionalURLSuffix)"/> </xsl:when> <!-- for relative URLs --> <xsl:otherwise> <xsl:value-of select="concat($sourceBaseURL, $href, $optionalURLSuffix)"/> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template>
Created attachment 53092 [details] document with images
Created attachment 53093 [details] resulted html with embedded images
JSI -> SUS: What about the idea to use byte64 code to embed images? Is that a possible solution? CHG: target. The need is there to decide what to do.
JSI->SUS: base64, not bye :-)
Thanks for the patch with this the encoded BASE64 pictures finally are used. Just tested on my Macbook with Mozilla 2, will check on other browsers before I adapt the patch. Any feedback is welcome. AFAIK there will be only critical fixes for the 3.0 for CWS, but I will adapt it to the 3.0.1 (bugfix release). I will creat a CWS 'xsltfilter10' as soon it is possible to do so for 3.0.1. In this CWS further XHTML issues can be bundled. BTW since DEV300 m13 there is now an real ODF to XHTML xslt filter in the Office, which can even be overwritten by an OOo extension being a XSLT filter. The fixes will than be easily testable in a OOo 3.0. Bests, Svante
I see a change to adapt this patch and will take it. Back to target 3.0 added to CWS. Thanks for the patch! Bests, Svante
Fixed, patch applied in CWS XSLTFILTER10
SUS to JSI: Just export the image file of the attachment. Images shall remain in XHTML.
moved to QA..
Yeah http://validator.w3.org says that it is "This Page Is Valid XHTML 1.1 plus MathML 2.0!"
Verified in OOO300m5 - Closing - Sophie