Class RenderSettings

java.lang.Object
org.apache.tika.renderer.RenderSettings
All Implemented Interfaces:
Serializable

public class RenderSettings extends Object implements Serializable
How a document is rendered to pixels: the "render" block of "pages". A renderer reads the effective settings from the ParseContext (class-keyed), scoped there by the parser around each render call.

dpi is the target; maxWidth/maxHeight is a ceiling: render at dpi, scale down to fit if either bound is exceeded, aspect preserved, never enlarge. maxImagePixels skips a page that would still be larger than that; minWidth/ minHeight skips one that would be smaller at the target dpi (a hairline rule, a spacer).

Every field is nullable so an instance can be an overlay: over(org.apache.tika.renderer.RenderSettings) applies the set fields of one instance to another. defaults() has every field set.

Since:
Apache Tika 4.1
See Also:
  • Field Details

  • Constructor Details

    • RenderSettings

      public RenderSettings()
  • Method Details

    • defaults

      public static RenderSettings defaults()
      300 dpi gray PNG at quality 0.5, at most 100 megapixels, no box, at least 2 x 2.
    • over

      public RenderSettings over(RenderSettings overlay)
      A copy of this with every set field of overlay applied; null overlay is this.
    • copy

      public RenderSettings copy()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • effectiveDpi

      public float effectiveDpi(double widthPoints, double heightPoints)
      The dpi a page of this size in points is rendered at: the target, reduced so the image fits the box, never raised. Fractional, so the box is met exactly. Requires every field set.
    • belowMinimum

      public boolean belowMinimum(double widthPoints, double heightPoints)
      True when the page rendered at the target dpi would be smaller than the minimum.
    • estimatedPixels

      public long estimatedPixels(double widthPoints, double heightPoints)
      Pixels of the page rendered at effectiveDpi(double, double); what maxImagePixels bounds.
    • estimatedPixels

      public static long estimatedPixels(double widthPoints, double heightPoints, double dpi)
      Pixels of the page rendered at this dpi; saturates rather than overflowing.
    • exceedsMaxPixels

      public boolean exceedsMaxPixels(long pixels)
      True when an image of this many pixels exceeds maxImagePixels.
    • fit

      public long[] fit(long width, long height)
      A pixel size scaled down to fit the box, aspect preserved, never enlarged: for renderers that start from a bitmap rather than a page size.
    • getDpi

      public Integer getDpi()
    • setDpi

      public void setDpi(Integer dpi)
    • getImageType

      public ImageType getImageType()
    • setImageType

      public void setImageType(ImageType imageType)
    • getImageFormat

      public ImageFormat getImageFormat()
    • setImageFormat

      public void setImageFormat(ImageFormat imageFormat)
    • getImageQuality

      public Float getImageQuality()
      ImageIO's compression quality. For PNG an inverted effort knob, not fidelity: 1.0 writes an uncompressed file, 0.0 spends ~10x the time of 0.5 for a few percent smaller output.
    • setImageQuality

      public void setImageQuality(Float imageQuality)
    • getMaxImagePixels

      public Long getMaxImagePixels()
    • setMaxImagePixels

      public void setMaxImagePixels(Long maxImagePixels)
      A page that would still be larger than this after the box is skipped; -1 for no limit.
    • getMaxWidth

      public Integer getMaxWidth()
    • setMaxWidth

      public void setMaxWidth(Integer maxWidth)
      Widest the image may be, in pixels; scaled down to fit, never enlarged; -1 for no bound.
    • getMaxHeight

      public Integer getMaxHeight()
    • setMaxHeight

      public void setMaxHeight(Integer maxHeight)
    • getMinWidth

      public Integer getMinWidth()
    • setMinWidth

      public void setMinWidth(Integer minWidth)
      Narrower than this at the target dpi and the document is not rendered at all; 0 for none.
    • getMinHeight

      public Integer getMinHeight()
    • setMinHeight

      public void setMinHeight(Integer minHeight)