Class PdfViewer
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasOrderedComponents,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddThumbnailClickedListener(com.vaadin.flow.component.ComponentEventListener<ThumbnailClickedEvent> listener) Adds a listener forThumbnailClickedEventto the component.voidCloses thumbnails view.Returns the tooltip text defined for the download button.Returns the tooltip text defined for the next page button.Returns the tooltip text defined for the previous page button.Returns the tooltip text defined for the print button.Returns the tooltip text defined for the rotate clockwise button.Returns the tooltip text defined for the rotate counterclockwise button.Returns the tooltip text defined for the sidebar toggle button.getSrc()getZoom()voidhideZoom(boolean hideZoom) Sets the flag to indicate if zoom options dropdown should be visible or not.booleanReturns whether download button is added to the toolbar or not.booleanReturns whether print button is added to the toolbar or not.booleanReturns whether Rotate Clockwise button is added to the toolbar or not.booleanReturns whether Rotate Counterclockwise button is added to the toolbar or not.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidOpens thumbnails view.voidsetAddDownloadButton(boolean addDownloadButton) Sets the flag to indicate if download button should be added or not.voidsetAddPrintButton(boolean addPrintButton) Sets the flag to indicate if print button should be added to toolbar or not.voidsetAddRotateClockwiseButton(boolean addRotateClockwiseButton) Sets the flag to indicate if Rotate Clockwise button should be added to toolbar or not.voidsetAddRotateCounterClockwiseButton(boolean addRotateCounterClockwiseButton) Sets the flag to indicate if Rotate Counterclockwise button should be added to toolbar or not.voidsetAutoZoomOptionLabel(String autoZoomOptionLabel) Sets the auto zoom option label.voidsetCustomTitle(String customTitle) Sets a custom title for the viewer.voidsetDownloadButtonTooltipText(String downloadButtonTooltipText) Sets tooltip text for the download button in toolbar.voidsetNextPageTooltipText(String nextPageTooltipText) Sets tooltip text for the next page button in toolbar.voidSets the current page of the rendered pdf file.voidsetPageFitZoomOptionLabel(String fitZoomOptionLabel) Sets the page fit zoom option label.voidsetPreviousPageTooltipText(String previousPageTooltipText) Sets a tooltip text for the previous page button in toolbar.voidsetPrintButtonTooltipText(String printButtonTooltipText) Sets tooltip text for the print button in toolbar.voidsetRenderInteractiveForms(boolean renderInteractiveForms) Sets the flag to indicate how to render interactive forms.voidsetRotateClockwiseButtonTooltipText(String rotateClockwiseButtonTooltipText) Sets tooltip text for the rotate clockwise button in toolbar.voidsetRotateCounterClockwiseButtonTooltipText(String rotateCounterClockwiseButtonTooltipText) Sets tooltip text for the rotate counterclockwise button in toolbar.voidsetSidebarToggleTooltipText(String sidebarToggleTooltipText) Sets tooltip text for the sidebar toogle button in toolbar.voidsetSrc(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.voidsetSrc(com.vaadin.flow.server.streams.DownloadHandler downloadHandler) Sets a pdf file to render as a DownloadHandler.voidSets a pdf file to render.voidSets the level of zoom on the rendered pdf file.voidshowFilenameOnly(boolean filenameOnly) Indicates if toolbar should only show filename as title or default title.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOf, replaceMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
PdfViewer
public PdfViewer()
-
-
Method Details
-
getSrc
- Returns:
- url to source file
-
setSrc
Sets a pdf file to render.- Parameters:
src- url to file
-
setSrc
@Deprecated(since="5.0.0", forRemoval=true) public void setSrc(com.vaadin.flow.server.AbstractStreamResource src) Deprecated, for removal: This API element is subject to removal in a future version.usesetSrc(DownloadHandler)insteadSets a pdf file to render as a StreamResource.Example:
StreamResource resource = new StreamResource("mypdf.pdf", () -> getPdfInputStream("mypdf.pdf");- Parameters:
src- stream to file
-
setSrc
public void setSrc(com.vaadin.flow.server.streams.DownloadHandler downloadHandler) Sets a pdf file to render as a DownloadHandler.Example:
DownloadHandler.forClassResource(getClass(), "mypdf.pdf")- Since:
- 5.0.0
-
getZoom
- Returns:
- current zoom level
-
setZoom
Sets the level of zoom on the rendered pdf file.Allowed values are - Number: for zoom percentage (e.g. 1.5 means 150% zoom). - 'auto': default value. - 'page-fit': fit a full page into component.
- Parameters:
zoom- zoom level
-
addThumbnailClickedListener
public void addThumbnailClickedListener(com.vaadin.flow.component.ComponentEventListener<ThumbnailClickedEvent> listener) Adds a listener forThumbnailClickedEventto the component.- Parameters:
listener- the listener to be added
-
openThumbnailsView
public void openThumbnailsView()Opens thumbnails view. -
closeThumbnailsView
public void closeThumbnailsView()Closes thumbnails view. -
getCurrentPage
- Returns:
- current page on viewer
-
setPage
Sets the current page of the rendered pdf file.- Parameters:
currentPage- current page number
-
showFilenameOnly
public void showFilenameOnly(boolean filenameOnly) Indicates if toolbar should only show filename as title or default title. By default is set to false, so default title will be display if not specified otherwise.Conditions:
- Pdf file should have a filename.
- This flag should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
filenameOnly- if true, toolbar only shows filename as title
-
setAutoZoomOptionLabel
Sets the auto zoom option label.
This property should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
autoZoomOptionLabel- auto zoom option label
-
setPageFitZoomOptionLabel
Sets the page fit zoom option label.
This property should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
fitZoomOptionLabel- page fit zoom option label
-
isAddDownloadButton
public boolean isAddDownloadButton()Returns whether download button is added to the toolbar or not.- Returns:
- true if download button is added
-
setAddDownloadButton
public void setAddDownloadButton(boolean addDownloadButton) Sets the flag to indicate if download button should be added or not. By default the flag is set to true, so download button is always added to the toolbar.
This flag should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
addDownloadButton- true if download button should be added
-
getCustomTitle
- Returns:
- custom title
-
setCustomTitle
Sets a custom title for the viewer. If this value is set, it will ignore the filename and the metadata title of the pdf file.
This value should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
customTitle-
-
isAddPrintButton
public boolean isAddPrintButton()Returns whether print button is added to the toolbar or not.- Returns:
- true if print button is added to toolbar
-
setAddPrintButton
public void setAddPrintButton(boolean addPrintButton) Sets the flag to indicate if print button should be added to toolbar or not. By default the flag is set to false, so, by default print button is not added to the toolbar.
This flag should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
addPrintButton- true if print button should be added to toolbar
-
setRenderInteractiveForms
public void setRenderInteractiveForms(boolean renderInteractiveForms) Sets the flag to indicate how to render interactive forms. Renders interactive form elements in the annotation layer (html) if true, renders values of form elements directly onto the canvas if false. By default the flag is set to true.
This flag should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
renderInteractiveForms-
-
hideZoom
public void hideZoom(boolean hideZoom) Sets the flag to indicate if zoom options dropdown should be visible or not. By default the flag is set to false, so, the dropdown is always shown.
This flag should be set on pdf viewer initialization time. It cannot be updated dynamically.
- Parameters:
hideZoom- true to hide the zoom dropdown
-
setPreviousPageTooltipText
Sets a tooltip text for the previous page button in toolbar.- Parameters:
previousPageTooltipText- text to show in tooltip
-
getPreviousPageTooltipText
Returns the tooltip text defined for the previous page button.- Returns:
- the previous page button tooltip text
-
setNextPageTooltipText
Sets tooltip text for the next page button in toolbar.- Parameters:
nextPageTooltipText- text to show in tooltip
-
getNextPageTooltipText
Returns the tooltip text defined for the next page button.- Returns:
- the next page button tooltip text
-
setSidebarToggleTooltipText
Sets tooltip text for the sidebar toogle button in toolbar.- Parameters:
sidebarToggleTooltipText- text to show in tooltip
-
getSidebarToggleTooltipText
Returns the tooltip text defined for the sidebar toggle button.- Returns:
- the sidebar toggle button tooltip text
-
setPrintButtonTooltipText
Sets tooltip text for the print button in toolbar.- Parameters:
printButtonTooltipText- the printButtonTooltipText to set
-
getPrintButtonTooltipText
Returns the tooltip text defined for the print button.- Returns:
- the print button tooltip text
-
setDownloadButtonTooltipText
Sets tooltip text for the download button in toolbar.- Parameters:
downloadButtonTooltipText- the downloadButtonTooltipText to set
-
getDownloadButtonTooltipText
Returns the tooltip text defined for the download button.- Returns:
- the download button tooltip text
-
isAddRotateClockwiseButton
public boolean isAddRotateClockwiseButton()Returns whether Rotate Clockwise button is added to the toolbar or not.- Returns:
- true if the button is added to toolbar
-
setAddRotateClockwiseButton
public void setAddRotateClockwiseButton(boolean addRotateClockwiseButton) Sets the flag to indicate if Rotate Clockwise button should be added to toolbar or not. By default the flag is set to false, so, by default the button is not added to the toolbar.
This flag should be set on pdf viewer initialization time.
- Parameters:
addRotateClockwiseButton- true if rotate clockwise button should be added to toolbar
-
isAddRotateCounterClockwiseButton
public boolean isAddRotateCounterClockwiseButton()Returns whether Rotate Counterclockwise button is added to the toolbar or not.- Returns:
- true if the button is added to toolbar
-
setAddRotateCounterClockwiseButton
public void setAddRotateCounterClockwiseButton(boolean addRotateCounterClockwiseButton) Sets the flag to indicate if Rotate Counterclockwise button should be added to toolbar or not. By default the flag is set to false, so, by default the button is not added to the toolbar.
This flag should be set on pdf viewer initialization time.
- Parameters:
addRotateCounterClockwiseButton- true if rotate counterclockwise button should be added to toolbar
-
setRotateClockwiseButtonTooltipText
Sets tooltip text for the rotate clockwise button in toolbar.- Parameters:
rotateClockwiseButtonTooltipText- the rotateClockwiseButtonTooltipText to set
-
getRotateClockwiseButtonTooltipText
Returns the tooltip text defined for the rotate clockwise button.- Returns:
- the rotate clockwise button tooltip text
-
setRotateCounterClockwiseButtonTooltipText
public void setRotateCounterClockwiseButtonTooltipText(String rotateCounterClockwiseButtonTooltipText) Sets tooltip text for the rotate counterclockwise button in toolbar.- Parameters:
rotateCounterClockwiseButtonTooltipText- the rotateCounterClockwiseButtonTooltipText to set
-
getRotateCounterClockwiseButtonTooltipText
Returns the tooltip text defined for the rotate counterclockwise button.- Returns:
- the rotate counterclockwise button tooltip text
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
setSrc(DownloadHandler)instead