Fop
  1. Fop
  2. FOP-1073

external-graphic dimensions and rendering

    Details

    • Type: Bug Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 0.20.5
    • Fix Version/s: None
    • Component/s: images
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC
    • External issue ID:
      37136

      Description

      ==========================================================================
      Sample1: The image will not be sized to the specified dimensions
      ==========================================================================

      <fo:block-container position="absolute" left="66.00mm" top="72.00mm"
      width="100.00mm" height="75.00mm">
      <fo:block>
      <fo:external-graphic src="file:your_image.jpg" width="100.00mm"
      height="75.00mm"/>
      </fo:block>
      </fo:block-container>

      ==========================================================================
      Sample2: The rendered PDF file fails to load, and fop reports exceptions

      java.lang.RuntimeException: Some content could not fit into a line/page after
      50 attempts. Giving up to avoid an endless loop.
      Exception
      javax.xml.transform.TransformerException: java.lang.RuntimeException: Some
      content could not fit into a line/page after 50 attempts. Giving up to avoid an
      endless loop.

      ==========================================================================

      <fo:block height="75.00mm">
      <fo:external-graphic src="file:your_image.jpg" width="100.00mm"/>
      </fo:block>

        Activity

        Hide
        Manuel Mall added a comment -

        Have you tried to use the content-height="scale-to-fit" and content-
        width="scale-to-fit" on the fo:external-graphic?

        FOP 1.0dev is attempting to be much more strict in applying the spec and will
        only scale if told to do so.

        Show
        Manuel Mall added a comment - Have you tried to use the content-height="scale-to-fit" and content- width="scale-to-fit" on the fo:external-graphic? FOP 1.0dev is attempting to be much more strict in applying the spec and will only scale if told to do so.
        Hide
        Jeremias Maerki added a comment -

        (In reply to comment #0)
        > ==========================================================================
        > Sample1: The image will not be sized to the specified dimensions
        > ==========================================================================
        >
        > <fo:block-container position="absolute" left="66.00mm" top="72.00mm"
        > width="100.00mm" height="75.00mm">
        > <fo:block>
        > <fo:external-graphic src="file:your_image.jpg" width="100.00mm"
        > height="75.00mm"/>
        > </fo:block>
        > </fo:block-container>

        This is something we've had a number of times now. The new FOP is much more
        strict about the interpretation of the XSL specification and has much less wrong
        behaviour than FOP 0.20.5. Under 0.20.5 the above probably did what you expected
        it to do but it was a faulty interpretation of the specification. width and
        height only specify the size of the box for the image, not the size of the
        image. If you want to scale the image so that it fits into the prepared box you
        will now have to add content-width="scale-to-fit". Otherwise, the image will be
        painted in its intrinsic size. It is no bug in FOP.

        > ==========================================================================
        > Sample2: The rendered PDF file fails to load, and fop reports exceptions
        >
        > java.lang.RuntimeException: Some content could not fit into a line/page after
        > 50 attempts. Giving up to avoid an endless loop.
        > Exception
        > javax.xml.transform.TransformerException: java.lang.RuntimeException: Some
        > content could not fit into a line/page after 50 attempts. Giving up to avoid an
        > endless loop.
        >
        > ==========================================================================
        >
        > <fo:block height="75.00mm">
        > <fo:external-graphic src="file:your_image.jpg" width="100.00mm"/>
        > </fo:block>

        You get the above error message if an element on a page (in your case the image)
        doesn't fit onto a page. The layout engine is then trying to put the element on
        the next page and if it still doesn't fit on the next and so on. After 50
        attempts it gives up and reports this. You will have to make sure that FOP is
        able to fit the image into a page. Without a complete example to run it myself
        it's difficult for me to tell you exactly what needs to be done. Try making the
        image smaller to begin with.

        BTW, the height property does not apply to the fo:block element. Your height
        there will be ignored! Better specify the height on the external-graphic and use
        content-width="scale-to-fit" as shown above.

        If you don't manage with this information please reopen the bug and attach a
        complete example file.

        Show
        Jeremias Maerki added a comment - (In reply to comment #0) > ========================================================================== > Sample1: The image will not be sized to the specified dimensions > ========================================================================== > > <fo:block-container position="absolute" left="66.00mm" top="72.00mm" > width="100.00mm" height="75.00mm"> > <fo:block> > <fo:external-graphic src="file:your_image.jpg" width="100.00mm" > height="75.00mm"/> > </fo:block> > </fo:block-container> This is something we've had a number of times now. The new FOP is much more strict about the interpretation of the XSL specification and has much less wrong behaviour than FOP 0.20.5. Under 0.20.5 the above probably did what you expected it to do but it was a faulty interpretation of the specification. width and height only specify the size of the box for the image, not the size of the image. If you want to scale the image so that it fits into the prepared box you will now have to add content-width="scale-to-fit". Otherwise, the image will be painted in its intrinsic size. It is no bug in FOP. > ========================================================================== > Sample2: The rendered PDF file fails to load, and fop reports exceptions > > java.lang.RuntimeException: Some content could not fit into a line/page after > 50 attempts. Giving up to avoid an endless loop. > Exception > javax.xml.transform.TransformerException: java.lang.RuntimeException: Some > content could not fit into a line/page after 50 attempts. Giving up to avoid an > endless loop. > > ========================================================================== > > <fo:block height="75.00mm"> > <fo:external-graphic src="file:your_image.jpg" width="100.00mm"/> > </fo:block> You get the above error message if an element on a page (in your case the image) doesn't fit onto a page. The layout engine is then trying to put the element on the next page and if it still doesn't fit on the next and so on. After 50 attempts it gives up and reports this. You will have to make sure that FOP is able to fit the image into a page. Without a complete example to run it myself it's difficult for me to tell you exactly what needs to be done. Try making the image smaller to begin with. BTW, the height property does not apply to the fo:block element. Your height there will be ignored! Better specify the height on the external-graphic and use content-width="scale-to-fit" as shown above. If you don't manage with this information please reopen the bug and attach a complete example file.
        Hide
        M.H. added a comment -

        Even though I added this content-width="scale-to-fit" to our external-grpahic:

        <fo:block padding-bottom="5mm">
        <fo:external-graphic content-width="scale-to-fit"
        height="{$LogoHeightValue}" src="{$Logo}"/>
        </fo:block>

        the error still occurs (FOP 1.0dev from 01.11.2005):

        javax.xml.transform.TransformerException: java.lang.RuntimeException: Some
        content could not fit into a line/page after 50 attempts. Giving up to avoid an
        endless loop.

        Anyway: what does "50 attempts" mean? Running my example 50 times also doesn't
        help anyfurther ...

        Show
        M.H. added a comment - Even though I added this content-width="scale-to-fit" to our external-grpahic: <fo:block padding-bottom="5mm"> <fo:external-graphic content-width="scale-to-fit" height="{$LogoHeightValue}" src="{$Logo}"/> </fo:block> the error still occurs (FOP 1.0dev from 01.11.2005): javax.xml.transform.TransformerException: java.lang.RuntimeException: Some content could not fit into a line/page after 50 attempts. Giving up to avoid an endless loop. Anyway: what does "50 attempts" mean? Running my example 50 times also doesn't help anyfurther ...
        Hide
        M.H. added a comment -

        I noticed that we also have svg images imported and that code is causing this
        (same) error message:

        <fo:instream-foreign-object >
        <svg:svg width="120mm" height="130mm"
        xmlns:xlink="http://www.w3.org/2000/svg">
        <svg:image width="120mm" height="130mm"
        xlink:href="{$chart_C_AssetSectorStructure2_H}"/>
        </svg:svg>
        </fo:instream-foreign-object>

        leads to:

        javax.xml.transform.TransformerException: java.lang.RuntimeException: Some
        content could not fit into a line/page after 50 attempts. Giving up to avoid an
        endless loop.

        I checked it when I removed just this section of code, the message disappeard
        (and also the SVG . Repasting it back reproduces the error message.
        Unfortunately, content-width="scale-to-fit" doesn't work with <svg:svg>
        and <svg:image>.

        Show
        M.H. added a comment - I noticed that we also have svg images imported and that code is causing this (same) error message: <fo:instream-foreign-object > <svg:svg width="120mm" height="130mm" xmlns:xlink="http://www.w3.org/2000/svg"> <svg:image width="120mm" height="130mm" xlink:href="{$chart_C_AssetSectorStructure2_H}"/> </svg:svg> </fo:instream-foreign-object> leads to: javax.xml.transform.TransformerException: java.lang.RuntimeException: Some content could not fit into a line/page after 50 attempts. Giving up to avoid an endless loop. I checked it when I removed just this section of code, the message disappeard (and also the SVG . Repasting it back reproduces the error message. Unfortunately, content-width="scale-to-fit" doesn't work with <svg:svg> and <svg:image>.
        Hide
        Manuel Mall added a comment -

        <fo:external-graphic content-width="scale-to-fit"
        height="{$LogoHeightValue}" src="{$Logo}"/>

        This will scale such that the logo fits into the width provided by the
        enclosing element. The error is more likely to be caused by the height not
        fitting into the area available. Have you tried using 'content-height="scale-to-
        fit"'? If that fixes your problem please close the bug. If not please attach a
        small sample fo and image which exhibits the problem.

        Show
        Manuel Mall added a comment - <fo:external-graphic content-width="scale-to-fit" height="{$LogoHeightValue}" src="{$Logo}"/> This will scale such that the logo fits into the width provided by the enclosing element. The error is more likely to be caused by the height not fitting into the area available. Have you tried using 'content-height="scale-to- fit"'? If that fixes your problem please close the bug. If not please attach a small sample fo and image which exhibits the problem.
        Hide
        M.H. added a comment -

        Please see response #4 for the SVG example.

        Show
        M.H. added a comment - Please see response #4 for the SVG example.
        Hide
        Manuel Mall added a comment -

        Comment #4 is not a working example showing the problem. It is just a snippet
        from your XML file. For us to investigate this we need the XSL-FO file (as
        small as possible just enough to show the problem) together with any related
        files (svg, jpeg, ...)

        Show
        Manuel Mall added a comment - Comment #4 is not a working example showing the problem. It is just a snippet from your XML file. For us to investigate this we need the XSL-FO file (as small as possible just enough to show the problem) together with any related files (svg, jpeg, ...)
        Hide
        Manuel Mall added a comment -

        Forgot to add:
        If you don't know how to just generate the XSL-FO file from the XML see here:
        http://xmlgraphics.apache.org/fop/trunk/running.html#check-input

        Show
        Manuel Mall added a comment - Forgot to add: If you don't know how to just generate the XSL-FO file from the XML see here: http://xmlgraphics.apache.org/fop/trunk/running.html#check-input
        Hide
        Andreas L. Delmelle added a comment -

        In reply to comment #4:

        See recent post on fop-users: specify content-height and content-width on the fo:instream-foreign-
        object, not on the svg element.

        Show
        Andreas L. Delmelle added a comment - In reply to comment #4: See recent post on fop-users: specify content-height and content-width on the fo:instream-foreign- object, not on the svg element.
        Hide
        ninouffff added a comment -

        Attachment bug example.zip has been added with description: shows size problems with bmp and rendering differences with the same svg

        Show
        ninouffff added a comment - Attachment bug example.zip has been added with description: shows size problems with bmp and rendering differences with the same svg
        Hide
        suresh koya added a comment -

        Specifying the content-width and content-height in a FO document does not render
        the image with the proper dimensions:
        <fo:external-graphic content-height="82px" content-width="294px"
        src="http://onjava.com/images/onjava/onjava_logo.jpg"/>

        Show
        suresh koya added a comment - Specifying the content-width and content-height in a FO document does not render the image with the proper dimensions: <fo:external-graphic content-height="82px" content-width="294px" src="http://onjava.com/images/onjava/onjava_logo.jpg"/>
        Hide
        Jeremias Maerki added a comment -

        (In reply to comment #11)
        > Specifying the content-width and content-height in a FO document does not render
        > the image with the proper dimensions:
        > <fo:external-graphic content-height="82px" content-width="294px"
        > src="http://onjava.com/images/onjava/onjava_logo.jpg"/>
        >

        Specifying sizes in pixels is generally bad practice in documents to be printed.
        The width of a pixel depends on the resolution used by the interpreting
        application. Some use 72dpi, some use 96 dpi as a default. FOP uses 72dpi by
        default but that can be changed in the configuration file or on the FopFactory.
        If you leave out content-height and content-width the image will be painted at
        its natural size.

        Show
        Jeremias Maerki added a comment - (In reply to comment #11) > Specifying the content-width and content-height in a FO document does not render > the image with the proper dimensions: > <fo:external-graphic content-height="82px" content-width="294px" > src="http://onjava.com/images/onjava/onjava_logo.jpg"/> > Specifying sizes in pixels is generally bad practice in documents to be printed. The width of a pixel depends on the resolution used by the interpreting application. Some use 72dpi, some use 96 dpi as a default. FOP uses 72dpi by default but that can be changed in the configuration file or on the FopFactory. If you leave out content-height and content-width the image will be painted at its natural size.
        Hide
        Glenn Adams added a comment -

        the attached test file does not contain the referenced external graphics or referenced setup.svg file; please provide in order to keep this bug open; otherwise, it will be moved to resolved+wontfix

        Show
        Glenn Adams added a comment - the attached test file does not contain the referenced external graphics or referenced setup.svg file; please provide in order to keep this bug open; otherwise, it will be moved to resolved+wontfix
        Hide
        Glenn Adams added a comment -

        resetting P2 open bugs to P3 pending further review

        Show
        Glenn Adams added a comment - resetting P2 open bugs to P3 pending further review

          People

          • Assignee:
            Unassigned
            Reporter:
            Rune Johansen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development