Class Pdfviewer

java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zkex.zul.Pdfviewer
All Implemented Interfaces:
Serializable, Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl, org.zkoss.zul.ext.Pageable

public class Pdfviewer extends org.zkoss.zul.impl.XulElement implements org.zkoss.zul.ext.Pageable
A PDF file viewer.

Only works for browsers supporting HTML5 (Firefox, Chrome, Opera, IE 11, Edge, Safari...).

Available in ZK PE and ZK EE.

Default getZclass(): z-pdfviewer.

Since:
9.0.0
Author:
rudyhuang
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    A utility class to implement HtmlBasedComponent.getExtraCtrl().

    Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

    org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
  • Field Summary

    Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    _zclass

    Fields inherited from interface org.zkoss.zk.ui.Component

    APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE

    Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

    AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component insertBefore)
     
    boolean
    Go to the first page.
    int
     
    org.zkoss.util.media.Media
    Returns the content set by setContent(org.zkoss.util.media.Media).
     
    int
     
    int
    Returns the number of items per page.
    org.zkoss.zk.ui.sys.PropertyAccess<?>
     
    int
    Returns the rotation angle.
    Returns the source URI of the PDF file.
     
    double
    Returns the zoom level.
    boolean
    Go to the last page.
    boolean
    Go to the next page.
    void
    onChildAdded(org.zkoss.zk.ui.Component child)
     
    void
    onChildRemoved(org.zkoss.zk.ui.Component child)
     
    boolean
    Go to the previous page.
    protected void
    renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
     
    void
    Rotates 90 degrees clockwise.
    void
    Rotates 90 degrees counterclockwise.
    void
    service(org.zkoss.zk.au.AuRequest request, boolean everError)
     
    void
    setActivePage(int page)
     
    void
    setContent(org.zkoss.util.media.Media content)
    Sets the content.
    void
    setPageSize(int size)
    Sets the number of items per page.
    void
    setRotation(int rotation)
    Sets the rotation angle.
    void
    Sets the source URI of the PDF file.
    void
    setZoom(double zoom)
    Sets the zoom level.
    void
    Sets the zoom level.
    boolean
    Zoom in by 10%.
    boolean
    Zoom out by 10%.

    Methods inherited from class org.zkoss.zul.impl.XulElement

    clone, getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes

    Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly

    Methods inherited from class org.zkoss.zk.ui.AbstractComponent

    addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pdfviewer

      public Pdfviewer()
  • Method Details

    • getSrc

      public String getSrc()
      Returns the source URI of the PDF file.

      Default: null.

    • setSrc

      public void setSrc(String src)
      Sets the source URI of the PDF file.

      Calling this method implies setContent(null). In other words, the last invocation of setSrc overrides the previous setContent(org.zkoss.util.media.Media), if any.

    • getContent

      public org.zkoss.util.media.Media getContent()
      Returns the content set by setContent(org.zkoss.util.media.Media).

      Default: null.

      Note: it won't fetch what is set thru by setSrc(java.lang.String). It simply returns what is passed to setContent(org.zkoss.util.media.Media).

    • setContent

      public void setContent(org.zkoss.util.media.Media content)
      Sets the content.

      Calling this method implies setSrc(null). In other words, the last invocation of setContent overrides the previous setSrc(java.lang.String), if any.

    • getActivePage

      public int getActivePage()
      Specified by:
      getActivePage in interface org.zkoss.zul.ext.Pageable
    • setActivePage

      public void setActivePage(int page) throws org.zkoss.zk.ui.WrongValueException
      Specified by:
      setActivePage in interface org.zkoss.zul.ext.Pageable
      Throws:
      org.zkoss.zk.ui.WrongValueException
    • getZoom

      public double getZoom()
      Returns the zoom level.

      Default: 1.0.

    • setZoom

      public void setZoom(double zoom)
      Sets the zoom level.
    • setZoom

      public void setZoom(String zoom)
      Sets the zoom level.
      Parameters:
      zoom - fit-page-width or fit-page-height
      Since:
      9.6.0
    • getRotation

      public int getRotation()
      Returns the rotation angle.

      Default: 0.

    • setRotation

      public void setRotation(int rotation)
      Sets the rotation angle.
      Parameters:
      rotation - rotation angle. Only 0, 90, 180 and 270 are accepted.
    • renderProperties

      protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws IOException
      Overrides:
      renderProperties in class org.zkoss.zul.impl.XulElement
      Throws:
      IOException
    • getPageSize

      public int getPageSize()
      Returns the number of items per page.

      Default: 1.

      Specified by:
      getPageSize in interface org.zkoss.zul.ext.Pageable
    • setPageSize

      public void setPageSize(int size) throws org.zkoss.zk.ui.WrongValueException
      Sets the number of items per page.

      It is readonly in pdfviewer.

      Specified by:
      setPageSize in interface org.zkoss.zul.ext.Pageable
      Throws:
      org.zkoss.zk.ui.WrongValueException
    • getPageCount

      public int getPageCount()
      Specified by:
      getPageCount in interface org.zkoss.zul.ext.Pageable
    • firstPage

      public boolean firstPage()
      Go to the first page.
      Returns:
      true if the action was successful.
    • previousPage

      public boolean previousPage()
      Go to the previous page.
      Returns:
      true if the action was successful.
    • nextPage

      public boolean nextPage()
      Go to the next page.
      Returns:
      true if the action was successful.
    • lastPage

      public boolean lastPage()
      Go to the last page.
      Returns:
      true if the action was successful.
    • zoomIn

      public boolean zoomIn()
      Zoom in by 10%.
      Returns:
      true if the action was successful.
    • zoomOut

      public boolean zoomOut()
      Zoom out by 10%.
      Returns:
      true if the action was successful.
    • rotateClockwise

      public void rotateClockwise()
      Rotates 90 degrees clockwise.
    • rotateCounterclockwise

      public void rotateCounterclockwise()
      Rotates 90 degrees counterclockwise.
    • service

      public void service(org.zkoss.zk.au.AuRequest request, boolean everError)
      Specified by:
      service in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      service in class org.zkoss.zk.ui.HtmlBasedComponent
    • beforeChildAdded

      public void beforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component insertBefore)
      Specified by:
      beforeChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      beforeChildAdded in class org.zkoss.zk.ui.AbstractComponent
    • onChildAdded

      public void onChildAdded(org.zkoss.zk.ui.Component child)
      Specified by:
      onChildAdded in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onChildAdded in class org.zkoss.zk.ui.AbstractComponent
    • onChildRemoved

      public void onChildRemoved(org.zkoss.zk.ui.Component child)
      Specified by:
      onChildRemoved in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onChildRemoved in class org.zkoss.zk.ui.AbstractComponent
    • getZclass

      public String getZclass()
      Overrides:
      getZclass in class org.zkoss.zk.ui.HtmlBasedComponent
    • getExtraCtrl

      public Object getExtraCtrl()
      Specified by:
      getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      getExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent
    • getPropertyAccess

      public org.zkoss.zk.ui.sys.PropertyAccess<?> getPropertyAccess(String prop)
      Specified by:
      getPropertyAccess in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      getPropertyAccess in class org.zkoss.zul.impl.XulElement