PDF Viewer - Embedded
A PDF viewer embedded in another control.
Z2UI5_CL_SMPC_APP_288
Controls
sap.m
UI5 1.71
The facts
- Repository
- abap2UI5/samples-controls
- Class
Z2UI5_CL_SMPC_APP_288- Source file
z2ui5_cl_smpc_app_288.clas.abap↗- Library
- sap.m
- UI5 entity
sap.m.PDFViewer- Demo kit sample
sap.m.sample.PDFViewerEmbedded- SAP's own sample
- running at sdk.openui5.org ↗
- Minimum UI5
- 1.71 — the floor abap2UI5 holds its samples to
- In the playground
- runs in the browser, with no system and nothing installed
Keywords: pdfviewer, sap.m, pdfviewerembedded, scrollcontainer, flexbox, button, flexitemdata
Controls it builds
Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.
Libraries
Run it here
The sample running, in this page — the app on its own, with no editor over it.
Switch to Playground with this code
Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.
The ABAP
z2ui5_cl_smpc_app_288.clas.abap — 117 lines
Click a number to link to a line — shift-click for a range.
Read it on GitHub ↗
" @keywords pdfviewer sap.m pdfviewerembedded scrollcontainer flexbox button flexitemdata
" @summary A PDF viewer embedded in another control.
CLASS z2ui5_cl_smpc_app_288 DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
DATA source TYPE string.
DATA title TYPE string.
DATA height TYPE string.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
" the two paths onInit resolves with sap.ui.require.toUrl( ), pinned to the
" OpenUI5 host per the runtime asset-URL rule; only the bound source is
" PUBLIC, the constants are not model data
CONSTANTS c_valid TYPE string VALUE `https://sdk.openui5.org/test-resources/sap/m/demokit/sample/PDFViewerEmbedded/sample.pdf`.
CONSTANTS c_invalid TYPE string VALUE `https://sdk.openui5.org/test-resources/sap/m/demokit/sample/PDFViewerEmbedded/sample_nonexisting.pdf`.
METHODS view_display.
METHODS on_event.
METHODS model_init.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_smpc_app_288 IMPLEMENTATION.
METHOD z2ui5_if_app~main.
me->client = client.
IF client->check_on_init( ).
model_init( ).
view_display( ).
ELSEIF client->check_on_navigated( ).
view_display( ).
ELSEIF client->check_on_event( ).
on_event( ).
ENDIF.
ENDMETHOD.
METHOD view_display.
DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).
view->ele( n = `View` ns = `mvc`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns` v = `sap.m`
)->a( n = `height` v = `100%`
)->ele( `ScrollContainer`
)->a( n = `height` v = `100%`
)->a( n = `width` v = `100%`
)->a( n = `horizontal` v = `true`
)->a( n = `vertical` v = `true`
)->ele( `FlexBox`
)->a( n = `direction` v = `Column`
)->a( n = `renderType` v = `Div`
)->a( n = `class` v = `sapUiSmallMargin`
)->ele( `FlexBox`
)->tag( `Button`
)->a( n = `text` v = `Correctly Displayed`
)->a( n = `press` v = client->_event( `PATH_CORRECT` )
)->tag( `Button`
)->a( n = `text` v = `Loading Error`
)->a( n = `press` v = client->_event( `PATH_INCORRECT` )
)->end(
)->ele( `PDFViewer`
)->a( n = `source` v = client->_bind( source )
)->a( n = `isTrustedSource` v = `true`
)->a( n = `title` v = client->_bind( title )
)->a( n = `height` v = client->_bind( height )
)->ele( `layoutData`
)->tag( `FlexItemData`
)->a( n = `growFactor` v = `1` ).
client->view_display( view->stringify( ) ).
ENDMETHOD.
METHOD on_event.
CASE client->get_event( ).
WHEN `PATH_CORRECT`.
" onCorrectPathClick: setProperty( '/Source', validPath )
source = c_valid.
WHEN `PATH_INCORRECT`.
" onIncorrectPathClick: setProperty( '/Source', invalidPath )
source = c_invalid.
ENDCASE.
ENDMETHOD.
METHOD model_init.
source = c_valid.
title = `My Custom Title`.
height = `600px`.
ENDMETHOD.
ENDCLASS.
More in sap.m
- TextArea - Value Update — Since 1.30 the value property of sap.m.TextArea is not updated on every keystroke, but fi…
- MultiComboBox - showSelectAll functionality — MultiComboBox with enabled Select All feature inside suggestions.
- Message View inside Dialog — A sample with Message View placed inside a Dialog.
- Popover in Custom Within Area — Within area of sap.ui.core.Popup determines where all popups (including popovers) are pos…
- Breadcrumbs sample with current page link — Breadcrumbs sample with current page set as aggregation, resulting in a link
- Icon Tab Bar - Badges — This sample illustrates the possibility to add badges to the icon tab filters.
- Dynamic Message Strip Generator — Generates MessageStrips with random properties.
- MultiInput with Value Help — MultiInput that includes a SelectDialog as a value help dialog
- Notification List Group with data bindings — A control suitable for grouping notifications. The sample uses JSON data bindings.
- Panel - Background Design — Panels support different background designs for better visual distinction inside containe…
- Message View with Grouping — A sample with Message View and inside a Dialog and grouping of items
- View Settings Dialog - Custom Filters — You can have custom filters in your View Settings Dialog, as shown in this example here.
On this page