Image scaling depending on output
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 44
- Joined: Tue Mar 13, 2012 5:01 pm
Image scaling depending on output
If I put screenshots and other graphics in what seem like normal sizes, e.g. 500px wide, they come out as far too large in my PDF output.
If I use "scale=50" attribute, that solves that and they come out well for the PDF, but then are far too small in my Eclipse Infocenter HTML output.
If I remove the scale attribute and set "scalefit" to "yes", the image vanishes completely in the PDF output.
Does anyone have any advice about general image scaling strategies? My first thought is that I could include each image twice, scaled two different ways, and use conditional profiling to exclude one from PDF output and the other from HTML, but it seems like there's probably a better way.
Mac OS 10.6
XEP RenderX
Oxygen Editor 13.2
Dita Bookmaps
If I use "scale=50" attribute, that solves that and they come out well for the PDF, but then are far too small in my Eclipse Infocenter HTML output.
If I remove the scale attribute and set "scalefit" to "yes", the image vanishes completely in the PDF output.
Does anyone have any advice about general image scaling strategies? My first thought is that I could include each image twice, scaled two different ways, and use conditional profiling to exclude one from PDF output and the other from HTML, but it seems like there's probably a better way.
Mac OS 10.6
XEP RenderX
Oxygen Editor 13.2
Dita Bookmaps
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Image scaling depending on output
Hi,
I think there have been discussions in the past on the DITA Users List about this.
Indeed conditional profiling is one option.
My suggested solution would be to leave the images in the DITA content without a @scale attribute set to them and then customize the XSLT stylesheets which generate PDF output to add this scale to all images when the XSL-FO output is generated.
If you look in this XSLT stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/commons.xsl
it's got some code like:
which looks at the @scale attribute set on the image.
You could replace it with something like:
If you want various opinions from our users I would suggest you to join the Oxygen Users mailing List and ask the question there:
http://www.oxygenxml.com/mailman/listinfo/oxygen-user/
Regards,
Radu
I think there have been discussions in the past on the DITA Users List about this.
Indeed conditional profiling is one option.
My suggested solution would be to leave the images in the DITA content without a @scale attribute set to them and then customize the XSLT stylesheets which generate PDF output to add this scale to all images when the XSL-FO output is generated.
If you look in this XSLT stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/commons.xsl
it's got some code like:
Code: Select all
<xsl:if test="not($width) and not($height) and @scale">
<xsl:attribute name="content-width">
<xsl:value-of select="concat(@scale,'%')"/>
</xsl:attribute>
</xsl:if>
You could replace it with something like:
Code: Select all
<xsl:attribute name="content-width">
<xsl:value-of select="'50%')"/>
</xsl:attribute>
http://www.oxygenxml.com/mailman/listinfo/oxygen-user/
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 44
- Joined: Tue Mar 13, 2012 5:01 pm
Re: Image scaling depending on output
That would be a great solution.
It doesn't seem to like that code- just to be clear, you're talking about replacing the top one entirely with the bottom code, right? Eliminating the "if test" code and just telling it the scale to use?
Could you take a quick look at the code again? It doesn't like the single ) it seems, but if I remove it then the build works, but the image isn't scaled, plus then I see this message:
transform.fo2pdf.xep:
[java] ERROR: no space for an element, trying to recover
[java] ERROR: no space for an element, trying to recover
I don't really know enough about XSL syntax to know what's wrong myself.
I did look at various DITA forums but I saw nothing that addressed this directly, as far as I could find anyway.
Thanks a million.
It doesn't seem to like that code- just to be clear, you're talking about replacing the top one entirely with the bottom code, right? Eliminating the "if test" code and just telling it the scale to use?
Could you take a quick look at the code again? It doesn't like the single ) it seems, but if I remove it then the build works, but the image isn't scaled, plus then I see this message:
transform.fo2pdf.xep:
[java] ERROR: no space for an element, trying to recover
[java] ERROR: no space for an element, trying to recover
I don't really know enough about XSL syntax to know what's wrong myself.
I did look at various DITA forums but I saw nothing that addressed this directly, as far as I could find anyway.
Thanks a million.
-
- Posts: 9421
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Image scaling depending on output
Hi,
I should have tried what I suggested to you first.
You were right in removing the extra ) from the replacement code.
There is another stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/flagging.xsl
in which there is the same code which needs to be replaced.
Somehow the template in this XSL overwrites the one in the XSL I told you to modify in the first post. I will discuss this with the DITA OT developers.
In my sample DITA Map I'm not getting the extra warnings you are mentioning when running XEP, the warnings may not be generated by this modification.
Regards,
Radu
I should have tried what I suggested to you first.
You were right in removing the extra ) from the replacement code.
There is another stylesheet:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/xsl/fo/flagging.xsl
in which there is the same code which needs to be replaced.
Somehow the template in this XSL overwrites the one in the XSL I told you to modify in the first post. I will discuss this with the DITA OT developers.
In my sample DITA Map I'm not getting the extra warnings you are mentioning when running XEP, the warnings may not be generated by this modification.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 44
- Joined: Tue Mar 13, 2012 5:01 pm
Re: Image scaling depending on output
Great. That seems to work perfectly now.
With the other error message, I think I see what happened. When I took off the scale attribute to try the modification above, then one of the images was too large for the system and it didn't appear at all, thus that error. Now that the modification works, and that one is automatically scaled at 50% like the rest, it appears again and that error is gone.
Thanks again. Much easier than inserting the images twice. Plus explaining to whoever will be maintaining these documents why there are two images side by side would be a long story, much more elegant solution this way.
With the other error message, I think I see what happened. When I took off the scale attribute to try the modification above, then one of the images was too large for the system and it didn't appear at all, thus that error. Now that the modification works, and that one is automatically scaled at 50% like the rest, it appears again and that error is gone.
Thanks again. Much easier than inserting the images twice. Plus explaining to whoever will be maintaining these documents why there are two images side by side would be a long story, much more elegant solution this way.
-
- Posts: 90
- Joined: Tue Mar 31, 2015 10:43 pm
Re: Image scaling depending on output
I am experiencing the same issue when transforming PDF and HTML output with a svg image. I would like to assign a max-width for both outputs, but I am not sure how to do this with the PDF. I have tried as you suggested above and have not had success. I am using Oxygen 18.1.
-
- Posts: 404
- Joined: Thu Aug 21, 2003 11:36 am
- Location: Craiova
- Contact:
Re: Image scaling depending on output
Post by radu_pisoi »
Hi,
A possible implementation is to set the max-width property for the XSL-FO external-graphic element generated for the corresponding DITA image.
https://www.w3.org/TR/xsl/#fo_external-graphic
To implement this, you need to override the following XSLT template from your PDF customization:
The XSLT stylesheet that defines this template is:
To specify the max-width information in the DITA image element, you can use the outputclass attribute.
A possible implementation is to set the max-width property for the XSL-FO external-graphic element generated for the corresponding DITA image.
https://www.w3.org/TR/xsl/#fo_external-graphic
Code: Select all
<fo:external-graphic max-width="2in" src="url('images/batik3D.svg')"/>
Code: Select all
<xsl:apply-templates select="." mode="placeImage">
Code: Select all
DITA-OT-DIR/plugins/org.dita.pdf2/xsl/fo/commons.xsl
Code: Select all
<image href="../images/batik3D.svg" id="image_xqs_dvd_zz" outputclass="max-width=100;"/>
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service