XSL-fo pdf 的图像大小问题

发布于 2024-10-04 01:46:42 字数 702 浏览 4 评论 0原文

我有大量的 XML 文档,这些文档是在 docbook 中创建的,并通过 maven 以 html 和 pdf 形式发布。各代工作正常,html 看起来也不错。我遇到的问题是 pdf 版本中图像的大小。这些图像是屏幕截图的集合,有些是全屏的,有些是大约 2/3 的宽度和高度,还有一些是小搜索框。显然,我需要对图像数据的属性进行大规模重构。我想知道我应该将其重构为什么呢?我正在寻找一种方法来创建最多 4 种“类型”的图像,并让它们强制执行自己的尺寸调整。 图像的示例如下所示:

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

它仅适用于我的某些屏幕截图尺寸。

我尝试过scalefit、width和contentwidth/contentheight,它们似乎解决了问题的不同部分。我也应该查看视口吗?

注意:不用担心会破坏 html 生成,因为我可以在 XSL 中打开“排除属性”。

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. The generations works fine, and the html looks fine. The issue i'm having is in the size of the images in the pdf version. The images are a collection of screenshots, some are full screen, some about 2/3rds width and height, and others are small search boxes. It's obvious that I need to do a massive refactor of the attributes of the 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.
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. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑咖 2024-10-11 01:46:42

严格来说这并不是您要问的问题,但是您是否标准化了图像文件中的 DPI 设置?尽管在 HTML 渲染中被忽略,但它们在 docbook->PDF 渲染中至关重要。

当我过去处理过这个问题时,修复 DPI 使我无需进一步调整 DocBook 源。

This isn't strictly what you're asking, but have you normalized the DPI settings in your image files? Though ignored in HTML rendering, they're crucial in docbook->PDF rendering.

When I've dealt with this in the past, fixing the DPI left me with no need to further tweak the DocBook source.

不可一世的女人 2024-10-11 01:46:42

您有 @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>  

这里是一些使用指南
缩放属性。

  • 要将图形缩放到给定宽度,
    设置图像数据中的内容宽度
    例如,将元素调整为该大小
    内容宽度=“8.5厘米”。如果您指定一个
    没有单位的数字,假设
    是像素。

  • 缩放图形以适应
    打印输出中的可用宽度,使用
    宽度=“100%”和scalefit=“1”
    属性。对于缩进文本,如
    列表,可用宽度来自
    当前缩进到右边距。

  • 保留图形以供打印输出
    以其自然大小除非太
    大以适应可用宽度,在
    在哪种情况下将其缩小以适合,使用
    比例尺=“1”,宽度=“100%”,和
    contentdepth="100%" 属性。

...

  • 某些 XSL-FO 处理器不支持
    所有这些属性。您可能需要
    尝试看看什么有效。为了
    例如,FOP 版本 0.20.5 处理
    width 就好像它是 contentwidth 和
    忽略任何真实的内容宽度
    属性。

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

You have @scalefit="0" try with @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". 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. 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.

...

  • Some XSL-FO processors do not support
    all of these attributes. 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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文