### Simple PDF Viewer Setup (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Include the PdfViewer in your XML layout to display PDF files. ```xml ``` -------------------------------- ### Kotlin Code for Manual PDF Viewer Setup Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Initializes and configures the PDF viewer, toolbar, and scroll bar when not using the PdfViewerContainer. It demonstrates loading a PDF from assets and setting up toolbar and scroll bar interactions. ```kotlin val pdfViewer = findViewById(R.id.pdf_viewer) val source = "asset://sample.pdf" val pdfScrollBar = findViewById(R.id.pdf_scroll_bar) val pdfToolBar = findViewById(R.id.pdf_tool_bar) pdfToolBar.setupWith(pdfViewer) pdfScrollBar.setupWith(pdfViewer, pdfToolBar) pdfViewer.onReady { load(source) toolbar.setFileName(fileName) // or toolbar.setTitle(title) } ``` -------------------------------- ### XML PDF Viewer (Core) Dependency (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Use the minimal setup for rendering PDFs with XML layouts. This includes only the core rendering functionality. ```kotlin implementation("com.github.bhuvaneshw.pdfviewer:core:1.0.0") ``` -------------------------------- ### Compose PDF Viewer with UI Components Dependency (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Enhanced Compose viewer setup including PdfViewerContainer, PdfToolBar, and PdfScrollBar. Use this for a more complete UI experience. ```kotlin implementation("com.github.bhuvaneshw.pdfviewer:compose:1.0.0") implementation("com.github.bhuvaneshw.pdfviewer:compose-ui:1.0.0") ``` -------------------------------- ### Compose PDF Viewer (Core) Dependency (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Minimal setup for rendering PDFs using Jetpack Compose. Use this if you only need the core rendering functionality. ```kotlin implementation("com.github.bhuvaneshw.pdfviewer:compose:1.0.0") ``` -------------------------------- ### Customize Colors with PdfViewer Components (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Configure colors for PdfToolBar, PdfViewer, and PdfScrollBar within a PdfViewerContainer. This example shows how to set content and background colors. ```xml ``` -------------------------------- ### Update Import Statements Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/MIGRATION.md Replace old import statements starting with `com.acutecoder.` with the new `com.bhuvaneshw.` equivalents. ```java import com.acutecoder.pdf.* import com.acutecoder.pdf.ui.* import com.acutecoder.pdfviewer.compose.* import com.acutecoder.pdfviewer.compose.ui.* ``` ```java import com.bhuvaneshw.pdf.* import com.bhuvaneshw.pdf.ui.* import com.bhuvaneshw.pdf.compose.* import com.bhuvaneshw.pdf.compose.ui.* ``` -------------------------------- ### PdfViewer within PdfViewerContainer (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Embed the PdfViewer within a PdfViewerContainer in your XML layout. This setup is useful for managing PDF viewing components. ```xml ``` -------------------------------- ### PdfViewer Initialization and Loading Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Demonstrates how to include the PdfViewer in XML layout and load a PDF document using Kotlin and Java. ```APIDOC ## XML PdfViewer Include PdfViewer in your xml ```xml ``` Then call load function ```kotlin // Kotlin pdfViewer.onReady { load("source") } ``` ```java // Java PdfUtil.onReady(pdfViewer, () -> { pdfViewer.load("source"); }); ``` > [!WARNING] > You should not access below members before the PdfViewer is initialized! > 1. PdfViewer.load() > 2. PdfViewer.loadFromAsset() > 3. PdfViewer.loadFromFileUri() > 4. PdfViewer.loadFromUrl() > 5. PdfViewer.ui > 6. PdfViewer.findController > 7. PdfViewer.pageScrollMode > 8. PdfViewer.pageSpreadMode > 9. PdfViewer.cursorToolMode > 10. PdfViewer.pageRotation > 11. PdfViewer.doubleClickThreshold > 12. PdfViewer.longClickThreshold > 13. PdfViewer.snapPage > 14. PdfViewer.pageAlignMode > 15. PdfViewer.singlePageArrangement > 16. PdfViewer.scrollSpeedLimit > 17. PdfEditor.undo() > 18. PdfEditor.redo() > 19. All setters in PdfEditor ``` -------------------------------- ### onReady Callback for Loading PDF (Kotlin) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Demonstrates how to use the onReady callback in Kotlin to load a PDF source into the PdfViewer. ```kotlin pdfViewer.onReady { load(source) } ``` -------------------------------- ### Configure PDFViewer with onCreateViewer Callback Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Uses the 'onCreateViewer' callback to add listeners or perform configurations on the PdfViewer instance after it's created. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.bhuvaneshw.pdfviewer.compose.PdfListener import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun PdfViewerOnCreateViewerCallback() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier, onCreateViewer = { // this: PdfViewer // You can add listener with extension like addListener(onPageLoadFailed = { }) // or addListener(object: PdfListener { // implement required methods }) } ) } ``` -------------------------------- ### Simple Pdf Viewer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Renders a PDF from an asset file using the basic PdfViewer composable. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun SimplePdfViewer() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier ) } ``` -------------------------------- ### Load PDF in Java Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Load a PDF document using the `load` function in Java. The `onReady` method ensures the viewer is initialized before attempting to load. ```java // Java PdfUtil.onReady(pdfViewer, () -> { pdfViewer.load("source"); }); ``` -------------------------------- ### Create PDFViewer Instance with Factory Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Utilizes the 'factory' parameter to create a custom PdfViewer instance within the PdfViewer composable. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun PdfViewerFactoryCallback() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier, factory = { context -> PdfViewer(context) // return PdfViewer instance. } ) } ``` -------------------------------- ### Extend PdfToolBar with Custom Menus Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Demonstrates how to extend the default PdfToolBar by adding custom menu items and retaining default menus. ```kotlin import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import com.bhuvaneshw.pdfviewer.compose.PdfScrollBar import com.bhuvaneshw.pdfviewer.compose.PdfToolBar import com.bhuvaneshw.pdfviewer.compose.PdfToolBarMenuItem import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun ExtendedToolBar() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier ) }, pdfToolBar = { PdfToolBar( title = "Title", dropDownMenu = { onDismiss, defaultMenus -> ExtendedTooBarMenus( onDismiss = onDismiss, defaultMenus = defaultMenus ) } ) }, pdfScrollBar = { PdfScrollBar(parentSize = it) }, ) } @Composable private fun ExtendedTooBarMenus( onDismiss: () -> Unit, defaultMenus: @Composable (filtered: List) -> Unit ) { DropdownMenuItem( text = { Text(text = "Extended Menu") }, onClick = { // Do something onDismiss() } ) defaultMenus(PdfToolBarMenuItem.entries) // or defaultMenus(PdfToolBarMenuItem.entries.filter { it != PdfToolBarMenuItem.CUSTOM_PAGE_ARRANGEMENT }) } ``` -------------------------------- ### Listening for FindBar State in PdfViewer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Manages the find bar's visibility state and handles back navigation when the find bar is open. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier import androidx.activity.compose.BackHandler import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import io.github.bhuvaneshw.pdfviewer.compose.PdfToolBar import io.github.bhuvaneshw.pdfviewer.compose.PdfScrollBar import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState import io.github.bhuvaneshw.pdfviewer.compose.rememberToolBarState @Composable fun ListeningForFindBarState() { val pdfState = rememberPdfState("asset://sample.pdf") val toolBarState = rememberToolBarState() LaunchedEffect(toolBarState.isFindBarOpen) { // Do something } BackHandler { if (toolBarState.isFindBarOpen) toolBarState.isFindBarOpen = false } PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier ) }, pdfToolBar = { PdfToolBar( title = "Title", toolBarState = toolBarState, ) }, pdfScrollBar = { parentSize -> PdfScrollBar( parentSize = parentSize ) }, ) } ``` -------------------------------- ### XML PDF Viewer with UI Components Dependency (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Includes PdfViewerContainer, PdfToolBar, and PdfScrollBar for a complete viewing experience in XML layouts. ```kotlin implementation("com.github.bhuvaneshw.pdfviewer:core:1.0.0") implementation("com.github.bhuvaneshw.pdfviewer:ui:1.0.0") ``` -------------------------------- ### Customize PDF Viewer Colors Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Shows how to customize the container, toolbar, and scroll bar colors of the PDF viewer. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import com.bhuvaneshw.pdfviewer.compose.PdfScrollBar import com.bhuvaneshw.pdfviewer.compose.PdfToolBar import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun Colors() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier, containerColor = Color.Red ) }, pdfToolBar = { PdfToolBar( title = "Title", contentColor = Color.Blue, ) }, pdfScrollBar = { PdfScrollBar( parentSize = it, contentColor = Color.Blue, handleColor = Color.Green ) }, ) } ``` -------------------------------- ### Add JitPack Repository (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Add the JitPack repository to your root build.gradle.kts or settings.gradle.kts. This is required before adding the library dependency. ```kotlin dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() maven("https://jitpack.io") } } ``` -------------------------------- ### Update Event Listener Usage Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/MIGRATION.md Replace the old `pdfviewer.addListener(PdfOnPageLoadStart { })` syntax with the new `pdfviewer.addListener(onPageLoadStart = { })` for adding event listeners. ```java pdfviewer.addListener(PdfOnPageLoadStart { }) ``` ```java pdfviewer.addListener(onPageLoadStart = { }) ``` -------------------------------- ### Default onReady Callback for PdfViewer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Utilizes the default onReady callback, which is invoked after the source has been loaded. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState import io.github.bhuvaneshw.pdfviewer.compose.DefaultOnReadyCallback @Composable fun PdfViewerDefaultOnReadyCallback() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier, onReady = DefaultOnReadyCallback { // this: PdfViewer // loadSource is called before this callback } ) } ``` -------------------------------- ### Load PDF in Kotlin Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Load a PDF document using the `load` function after the PdfViewer is ready. This is the recommended way to load content programmatically. ```kotlin // Kotlin pdfViewer.onReady { load("source") } ``` -------------------------------- ### Custom onReady Callback for PdfViewer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Implements a custom onReady callback that requires explicitly calling loadSource(). ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState import io.github.bhuvaneshw.pdfviewer.compose.CustomOnReadyCallback @Composable fun PdfViewerCustomOnReadyCallback() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier, onReady = CustomOnReadyCallback { loadSource -> // this: PdfViewer loadSource() // Mandatory to call } ) } ``` -------------------------------- ### Load PDF from Asset (Kotlin) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Load a PDF file from the application's assets using the PdfViewer in Kotlin. The PDF is loaded once the viewer is ready. ```kotlin val pdfViewer = findViewById(R.id.pdf_viewer) val source = "asset://sample.pdf" // Kotlin pdfViewer.onReady { load(source) } ``` -------------------------------- ### Custom Loading Indicator for PDF Viewer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Replaces the default loading indicator with a custom UI element, including a progress indicator and text. ```kotlin import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun LoadingIndicator() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier, ) }, loadingIndicator = { Column( Modifier .fillMaxSize() .background(MaterialTheme.colorScheme.background), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally, ) { CircularProgressIndicator() Text(text = "Loading...") } }, ) } ``` -------------------------------- ### Load PDF from Asset (Java) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Load a PDF file from the application's assets using the PdfViewer in Java. The PDF is loaded once the viewer is ready. ```java // Java PdfUtil.onReady(pdfViewer, () -> { pdfViewer.load(source); }); ``` -------------------------------- ### Add JitPack Repository (Groovy DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Add the JitPack repository to your root build.gradle or settings.gradle. This is required before adding the library dependency. ```groovy dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { mavenCentral() maven { url 'https://jitpack.io' } } } ``` -------------------------------- ### Kotlin for Implementing PdfListener Interface Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Adds a listener by implementing the PdfListener interface. This approach allows for handling multiple PDF-related events by overriding the required methods. ```kotlin pdfViewer.addListener(object: PdfListener { // implement required methods }) ``` -------------------------------- ### PdfViewer with Toolbar and ScrollBar Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Combines PdfViewer with PdfToolBar and PdfScrollBar within a PdfViewerContainer for a complete viewing experience. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import io.github.bhuvaneshw.pdfviewer.compose.PdfToolBar import io.github.bhuvaneshw.pdfviewer.compose.PdfScrollBar import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun PdfViewerWithToolBarAndScrollBar() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier ) }, pdfToolBar = { PdfToolBar( title = "Title", ) }, pdfScrollBar = { parentSize -> PdfScrollBar( parentSize = parentSize ) }, ) } ``` -------------------------------- ### Add Dependency (Kotlin DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Add the PdfViewer library dependency to your app's build.gradle.kts file. Replace $module and $version with appropriate values. ```kotlin dependencies { implementation("com.github.bhuvaneshw.pdfviewer:$module:$version") } ``` -------------------------------- ### Add Dependency (Groovy DSL) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Add the PdfViewer library dependency to your app's build.gradle file. Replace $module and $version with appropriate values. ```groovy dependencies { implementation 'com.github.bhuvaneshw.pdfviewer:$module:$version' } ``` -------------------------------- ### PdfToolBar Back Icon Functionality Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Configures the back icon in PdfToolBar and defines its click behavior. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import io.github.bhuvaneshw.pdfviewer.compose.PdfToolBar import io.github.bhuvaneshw.pdfviewer.compose.PdfScrollBar import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun ToolBarBack() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier ) }, pdfToolBar = { PdfToolBar( title = "Title", onBack = { // called when back is clicked }, // backIcon = { // this: PdfToolBarScope // // or create your own back icon // } ) }, pdfScrollBar = { parentSize -> PdfScrollBar( parentSize = parentSize ) }, ) } ``` -------------------------------- ### Kotlin Code to Set Loading Indicator Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Programmatically links a LinearLayout as the loading indicator for the PdfViewerContainer. Ensure the IDs in the XML layout match those used in the code. ```kotlin val pdfContainer = findViewById(R.id.pdf_viewer_container) val loadingIndicator = findViewById(R.id.loading_indicator) pdfContainer.setAsLoadingIndicator(loadingIndicator) ``` -------------------------------- ### PdfViewer with Toolbar and ScrollBar (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Integrate PdfViewer with PdfToolBar and PdfScrollBar within a PdfViewerContainer for a complete PDF viewing experience. Ensure the PdfViewer has a mandatory ID. ```xml ``` -------------------------------- ### Kotlin Extension for Page Load Failed Listener Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Adds a specific listener for page load failures using an extension function. This is a concise way to handle errors during PDF page loading. ```kotlin pdfViewer.addListener(onPageLoadFailed = { // Specific listener (Extension functions) }) ``` -------------------------------- ### XML Layout with Loading Indicator Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Defines the layout for the PDF Viewer component, including a loading indicator that can be managed programmatically. The loading indicator is initially hidden and can be linked to the PdfViewerContainer. ```xml ``` -------------------------------- ### Jetpack Compose PdfViewer Usage Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Use the PdfViewer composable in your Jetpack Compose UI. The 'source' parameter accepts various URI formats for PDF files. ```kotlin val pdfState = rememberPdfState(source = "source") PdfViewer( pdfState = pdfState, modifier = Modifier, containerColor = Color.Transparent, onReady = { // Optional work } ) ``` -------------------------------- ### XML Layout without PdfViewerContainer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Defines a manual layout for PDF viewer components including toolbar, viewer, and scroll bar using a RelativeLayout. This approach requires explicit positioning of each element. ```xml ``` -------------------------------- ### PdfViewer within PdfViewerContainer Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Integrates PdfViewer inside a PdfViewerContainer, allowing for layout management. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun PdfViewerWithContainer() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = {// this: PdfContainerBoxScope PdfViewer( // pdfState is passed by PdfContainerBoxScope modifier = Modifier, ) } ) } ``` -------------------------------- ### Change Container Background Color (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Customize the background color of the PdfViewer's container using XML attributes. ```xml ``` -------------------------------- ### PdfViewer Public Members Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Lists and describes the public members available for the PdfViewer component, including properties and methods for controlling its behavior and state. ```APIDOC ## Public Members `isInitialized: Boolean` Indicates whether the PDF viewer has been initialized. `currentUrl: String?` The current URL of the loaded PDF document. `currentPage: Int` The current page number of the PDF document. `pagesCount: Int` The total number of pages in the currently loaded PDF document. `currentPageScale: Float` The scale factor of the current page (zoom level). `currentPageScaleValue: String` The current scale value of the PDF page (e.g., `page-fit`, `auto`). `properties: PdfDocumentProperties?` The properties of the currently loaded PDF document, such as title, author, etc. `ui: UiSettings` Returns the `UiSettings` for the PDF viewer. Provides settings related to the UI provided by Mozilla's PDF.js. `findController: FindController` Returns the `FindController` for the PDF viewer. Provides functionality for finding text in the PDF. `pageScrollMode: PageScrollMode` Defines the page scroll mode (e.g., vertical, horizontal, wrapped). `pageSpreadMode: PageSpreadMode` Defines the page spread mode (e.g., none, odd, even). `cursorToolMode: CursorToolMode` Defines the cursor tool mode (e.g., text select, hand tool). `load(url: String, originalUrl: String = url)` Loads a PDF file from the specified `url`. The `originalUrl` parameter is optional and defaults to the `url`. `onReady(onReady: PdfOnReadyListener)` Registers a listener that gets called when the PDF viewer is initialized and ready. `addListener(listener: PdfListener)` Adds a listener to be notified of PDF events (e.g., page load). `removeListener(listener: PdfListener)` and `removeListener(listener: PdfOnReadyListener)` Removes a previously added listener. `goToPage(pageNumber: Int)` Navigates to the specified page number in the PDF. `scrollToRatio(ratio: Float)` Scrolls the viewer to a specific ratio (0f - 1f) (calculated to offset). `scrollTo(offset: Int)` Scrolls the viewer to the specified offset. `goToNextPage()` Navigates to the next page in the PDF. `goToPreviousPage()` Navigates to the previous page in the PDF. `goToFirstPage()` Navigates to the first page in the PDF. `goToLastPage()` Navigates to the last page in the PDF. `scalePageTo(scale: Float)` Zooms the current page to the specified scale factor. `zoomIn()` Zooms in on the current page. `zoomOut()` Zooms out on the current page. `zoomTo(zoom: Zoom)` Zooms to a specified zoom mode (e.g., `PAGE_FIT`, `PAGE_WIDTH`). `downloadFile()` Initiates the download of the currently viewed PDF file. `printFile()` - unstable Prints the currently viewed PDF file. `startPresentationMode()` - unstable Starts presentation mode, which is typically used for viewing PDFs in full-screen mode. `rotateClockWise()` Rotates the PDF clockwise by 90 degrees. `rotateCounterClockWise()` Rotates the PDF counter-clockwise by 90 degrees. `showDocumentProperties()` Displays the properties of the current PDF document (e.g., title, author). `reInitialize()` Re-initializes the PDF viewer, reloading the webview. `setContainerBackgroundColor(color: Int)` Sets the background color of the PDF viewer container. ``` -------------------------------- ### Set Toolbar Back Icon (Kotlin) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Customize the back button icon for the PdfToolBar in Kotlin. This allows you to set a specific drawable resource for the back arrow. ```kotlin val pdfToolBar = findViewById(R.id.pdf_tool_bar) pdfToolBar.back.setImageResource(com.bhuvaneshw.pdf.ui.R.drawable.outline_arrow_back_24) ``` -------------------------------- ### Change PdfViewer Container Color Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Customizes the background color of the PdfViewer's container. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import io.github.bhuvaneshw.pdfviewer.compose.PdfViewer import io.github.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun PdfViewerContainerColor() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewer( pdfState = pdfState, modifier = Modifier, containerColor = Color.Transparent ) } ``` -------------------------------- ### Include PdfViewer in XML Layout Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/README.md Add the PdfViewer component to your Android XML layout file. Ensure you have the necessary attributes for width, height, and background. ```xml ``` -------------------------------- ### Customize ScrollBar Appearance and Behavior (XML) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Configure the PdfScrollBar in XML to use vertical scrollbar for horizontal mode and set its colors. ```xml ``` -------------------------------- ### Customize PDF Scroll Bar Behavior Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_COMPOSE.md Configures the scroll bar to use vertical scroll bar for horizontal mode and enables interactive scrolling. ```kotlin import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import com.bhuvaneshw.pdfviewer.compose.PdfViewer import com.bhuvaneshw.pdfviewer.compose.PdfViewerContainer import com.bhuvaneshw.pdfviewer.compose.PdfScrollBar import com.bhuvaneshw.pdfviewer.compose.PdfToolBar import com.bhuvaneshw.pdfviewer.compose.rememberPdfState @Composable fun CustomizeScrollBar() { val pdfState = rememberPdfState("asset://sample.pdf") PdfViewerContainer( pdfState = pdfState, pdfViewer = { PdfViewer( modifier = Modifier, ) }, pdfToolBar = { PdfToolBar( title = "Title", ) }, pdfScrollBar = { PdfScrollBar( parentSize = it, useVerticalScrollBarForHorizontalMode = true, interactiveScrolling = true, ) }, ) } ``` -------------------------------- ### Disable Interactive Scrolling for ScrollBar (Kotlin) Source: https://github.com/bhuvaneshw/pdfviewer/blob/main/docs/README_XML.md Control the interactive scrolling behavior of the PdfScrollBar programmatically in Kotlin. Set 'interactiveScrolling' to false to disable it. ```kotlin val pdfScrollBar = findViewById(R.id.pdf_scroll_bar) pdfScrollBar.interactiveScrolling = false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.