简体   繁体   English

XSL-fo pdf的图像大小问题

[英]XSL-fo Image size issue with pdfs

I have a large number of XML documents which are created in docbook and, through maven, are published in both an html for and a pdf form. 我有大量的XML文档,它们是在docbook中创建的,并且通过maven,以html for和pdf形式发布。 The generations works fine, and the html looks fine. 几代人工作正常,html看起来很好。 The issue i'm having is in the size of the images in the pdf version. 我遇到的问题是pdf版本中图像的大小。 The images are a collection of screenshots, some are full screen, some about 2/3rds width and height, and others are small search boxes. 图像是截图的集合,一些是全屏的,一些是大约2 / 3rds的宽度和高度,其他是小搜索框。 It's obvious that I need to do a massive refactor of the attributes of the imagedata. 很明显,我需要对imagedata的属性进行大规模的重构。 I was wondering what should I refactor it to? 我想知道我该怎么重构它? I'm looking for a way to create up to 4 'types' of images and for these to enforce their own sizing. 我正在寻找一种方法来创建最多4种类型的图像,并为这些图像强制执行自己的尺寸调整。 An example of an image looks like this: 图像的示例如下所示:

  <section><title>Screenshot</title>
     <mediaobject>
       <imageobject>
        <imagedata fileref="./views/screenshots/editNote.png" scalefit="0" width="100%"/>
       </imageobject>
     </mediaobject>
  </section>

And it only works for some of my screenshot sizes. 它只适用于我的一些屏幕截图尺寸。

I've played around with scalefit, width, and contentwidth/contentheight and they seem solve different portions of the problem. 我已经玩过scalefit,width和contentwidth / contentheight,它们似乎解决了问题的不同部分。 Should I be looking into viewports as well? 我也应该关注视口吗?

NOTE: There is not fear of breaking html generation since I can turn on 'exclude properties' in the XSL. 注意:因为我可以打开XSL中的“排除属性”,所以不用担心会破坏html生成。

This isn't strictly what you're asking, but have you normalized the DPI settings in your image files? 这不是您要求的严格要求,但是您是否已将图像文件中的DPI设置标准化? Though ignored in HTML rendering, they're crucial in docbook->PDF rendering. 虽然在HTML渲染中被忽略,但它们在docbook-> PDF渲染中至关重要。

When I've dealt with this in the past, fixing the DPI left me with no need to further tweak the DocBook source. 当我在过去处理这个问题时,修复DPI让我无需进一步调整DocBook源代码。

You have @scalefit="0" try with @scalefit="1" : 你有@scalefit="0"试试@scalefit="1"

<section><title>Screenshot</title>
     <mediaobject>
       <imageobject>
        <imagedata fileref="./views/screenshots/editNote.png" 
                   scalefit="1" width="100%" contentdept="100%"/>
       </imageobject>
     </mediaobject>
  </section>  

Here is some guidance for using the scaling attributes. 以下是使用缩放属性的一些指导。

  • To scale a graphic to a given width, set the contentwidth in the imagedata element to that size, for example contentwidth="8.5cm". 要将图形缩放到给定宽度,请将imagedata元素中的contentwidth设置为该大小,例如contentwidth =“8.5cm”。 If you specify a number without units, it is assumed to be pixels. 如果指定不带单位的数字,则假定为像素。

  • To scale a graphic to fit the available width in printed output, use width="100%" and scalefit="1" attributes. 要缩放图形以适合打印输出中的可用宽度,请使用width =“100%”和scalefit =“1”属性。 For indented text as in a list, the available width is from the current indent to the right margin. 对于列表中的缩进文本,可用宽度是从当前缩进到右边距。

  • To keep a graphic for printed output at its natural size unless it is too large to fit the available width, in which case shrink it to fit, use scalefit="1", width="100%", and contentdepth="100%" attributes. 为了使打印输出的图形保持其自然尺寸,除非它太大而不适合可用宽度,在这种情况下缩小它以适应,使用scalefit =“1”,width =“100%”,contentdepth =“100% “属性。

... ...

  • Some XSL-FO processors do not support all of these attributes. 某些XSL-FO处理器不支持所有这些属性。 You may need to experiment to see what works. 您可能需要尝试查看哪些有效。 For example, FOP version 0.20.5 treats width as if it were contentwidth and ignores any real contentwidth attribute. 例如,FOP版本0.20.5将宽度视为contentwidth,并忽略任何实际的contentwidth属性。

http://www.sagehill.net/docbookxsl/ImageSizing.html http://www.sagehill.net/docbookxsl/ImageSizing.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM