Class CmsPdfUserAgent

java.lang.Object
org.xhtmlrenderer.swing.NaiveUserAgent
org.opencms.pdftools.CmsPdfUserAgent
All Implemented Interfaces:
org.xhtmlrenderer.event.DocumentListener, org.xhtmlrenderer.extend.UserAgentCallback

public class CmsPdfUserAgent extends org.xhtmlrenderer.swing.NaiveUserAgent
This class is responsible for loading external resources while generating PDF from XHTML. Resources will be loaded from the VFS. Additionally, if there are image scaler parameters in an image URI, the scaled image data will be returned. Please note that this class just reads the data from the linked resources; it will not go through OpenCms's resource loaders, so you can't e.g. use a JSP as a dynamic stylesheet.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Pattern
    The regex to match image scaler parameters.

    Fields inherited from class org.xhtmlrenderer.swing.NaiveUserAgent

    _imageCache
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
     
    org.xhtmlrenderer.resource.CSSResource
     
    org.xhtmlrenderer.resource.ImageResource
     
    org.xhtmlrenderer.layout.SharedContext
    Gets the shared context.
     
    void
    setSharedContext(org.xhtmlrenderer.layout.SharedContext sharedContext)
    Sets the shared context.

    Methods inherited from class org.xhtmlrenderer.swing.NaiveUserAgent

    clearImageCache, createImageResource, documentLoaded, documentStarted, getBaseURL, getXMLResource, isVisited, needsRedirect, onHttpConnection, onLayoutException, onRenderException, openConnection, openStream, resolveAndOpenStream, setBaseURL, shrinkImageCache

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getBinaryResource

      public byte[] getBinaryResource(String uri)
      Specified by:
      getBinaryResource in interface org.xhtmlrenderer.extend.UserAgentCallback
      Overrides:
      getBinaryResource in class org.xhtmlrenderer.swing.NaiveUserAgent
      See Also:
      • NaiveUserAgent.getBinaryResource(java.lang.String)
    • getCSSResource

      public org.xhtmlrenderer.resource.CSSResource getCSSResource(String uri)
      Specified by:
      getCSSResource in interface org.xhtmlrenderer.extend.UserAgentCallback
      Overrides:
      getCSSResource in class org.xhtmlrenderer.swing.NaiveUserAgent
      See Also:
      • NaiveUserAgent.getCSSResource(java.lang.String)
    • getImageResource

      public org.xhtmlrenderer.resource.ImageResource getImageResource(String uri)
      Specified by:
      getImageResource in interface org.xhtmlrenderer.extend.UserAgentCallback
      Overrides:
      getImageResource in class org.xhtmlrenderer.swing.NaiveUserAgent
      See Also:
      • NaiveUserAgent.getImageResource(java.lang.String)
    • getSharedContext

      public org.xhtmlrenderer.layout.SharedContext getSharedContext()
      Gets the shared context.

      Returns:
      the shared context
    • resolveURI

      public String resolveURI(String uri)
      Specified by:
      resolveURI in interface org.xhtmlrenderer.extend.UserAgentCallback
      Overrides:
      resolveURI in class org.xhtmlrenderer.swing.NaiveUserAgent
      See Also:
      • NaiveUserAgent.resolveURI(java.lang.String)
    • setSharedContext

      public void setSharedContext(org.xhtmlrenderer.layout.SharedContext sharedContext)
      Sets the shared context.

      Parameters:
      sharedContext - the shared context