### Inspect Binaries for Dependencies Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Uses otool to verify that the final frameworks do not contain dynamic libpdfium.dylib dependencies. ```bash otool -L shared/build/bin/iosArm64/debugFramework/Shared.framework/Shared otool -L \ shared/build/bin/iosSimulatorArm64/debugFramework/Shared.framework/Shared ``` -------------------------------- ### Configure local proxy for Chromium downloads Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Environment variables to route build downloads through a local proxy. ```bash export https_proxy=http://127.0.0.1:7890 export http_proxy=http://127.0.0.1:7890 export all_proxy=socks5://127.0.0.1:7891 ``` -------------------------------- ### Configure GN build arguments for static PDFium Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Required GN arguments for creating a complete static archive compatible with Apple system libc++. ```text is_debug = false pdf_is_complete_lib = true pdf_enable_v8 = false pdf_enable_xfa = false symbol_level = 0 use_custom_libcxx = false ios_deployment_target = "14.0" ``` -------------------------------- ### Open and display a PDF document Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Manage the PdfDocument lifecycle using Compose state and DisposableEffect to ensure proper resource cleanup. ```kotlin import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import io.github.limuyang2.pdf.core.PdfDocument import io.github.limuyang2.pdf.core.PdfSource import io.github.limuyang2.pdf.core.PdfViewer import io.github.limuyang2.pdf.viewer.PdfView import io.github.limuyang2.pdf.viewer.rememberPdfViewState import kotlinx.coroutines.CancellationException @Composable fun PdfScreen( pdfBytes: ByteArray, modifier: Modifier = Modifier, ) { var document by remember(pdfBytes) { mutableStateOf(null) } var failure by remember(pdfBytes) { mutableStateOf(null) } val viewState = rememberPdfViewState() LaunchedEffect(pdfBytes) { try { document = PdfViewer.open(PdfSource.Bytes(pdfBytes)) } catch (cancellation: CancellationException) { throw cancellation } catch (error: Throwable) { failure = error } } val currentDocument = document DisposableEffect(currentDocument) { onDispose { currentDocument?.close() } } when { currentDocument != null -> PdfView( document = currentDocument, state = viewState, modifier = modifier.fillMaxSize(), ) failure != null -> Text(checkNotNull(failure).message ?: "Could not open PDF") else -> Box( modifier = modifier.fillMaxSize(), contentAlignment = Alignment.Center, ) { CircularProgressIndicator() } } } ``` -------------------------------- ### Verify PDFium symbols and platform Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Commands to inspect static archives and verify symbols for device and simulator builds. ```bash xcrun nm -gU /iosArm64/libpdfium.a \ | grep FPDFAction_GetDest xcrun nm -gU /iosSimulatorArm64/libpdfium.a \ | grep FPDFBitmap_CreateEx ``` -------------------------------- ### Configure PdfView component Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Initializes the PdfView with custom layout, zoom, and rendering parameters. ```kotlin PdfView( document = document, state = state, modifier = Modifier.fillMaxSize(), pageSpacing = 12.dp, pagePadding = 8.dp, pageColor = Color.White, maxRenderDimension = 4096, maxZoom = 5f, gestureZoomEnabled = true, ) ``` -------------------------------- ### Runtime Manifest File Paths Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Locations of the manifest files containing version, flavor, and checksum information. ```text pdf-core/src/jvmMain/resources/pdfium/manifest.properties pdf-core/src/webMain/resources/pdfium/manifest.properties ``` -------------------------------- ### Add PDF Viewer dependencies Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/README.md Configure the project repositories and add the required dependencies to the commonMain source set. ```kotlin repositories { mavenCentral() } kotlin { sourceSets { commonMain.dependencies { // PDF APIs only: implementation("io.github.limuyang2:pdf-core:0.2.2") // Or the Compose viewer. pdf-core is included transitively: implementation("io.github.limuyang2:pdf-viewer:0.2.2") } } } ``` -------------------------------- ### Define staging path for static library Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md The standard output location for the generated static archive. ```text staging/lib/libpdfium.a ``` -------------------------------- ### JVM Native Access Configuration Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/README.md Required JVM argument for some runtimes to enable native library access. ```bash --enable-native-access=ALL-UNNAMED ``` -------------------------------- ### Configure Search Highlight Styles Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Define visual decorations for normal and selected search matches. ```kotlin PdfView( document = document, state = state, searchHighlightStyle = PdfSearchHighlightStyle( match = PdfSearchHighlightDecoration( fillColor = Color.Yellow.copy(alpha = 0.3f), cornerRadius = 2.dp, padding = 1.dp, ), selectedMatch = PdfSearchHighlightDecoration( fillColor = Color(0x6681D4FA), strokeColor = Color(0xFF0277BD), strokeWidth = 2.dp, cornerRadius = 2.dp, ), ), ) ``` -------------------------------- ### Configure Web Assets Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md List of required PDFium assets that must be served by the web backend. ```text pdfium/manifest.properties pdfium/pdfium-adapter.js pdfium/pdfium.js pdfium/pdfium.wasm ``` -------------------------------- ### Define final static library directory structure Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Required file arrangement for device and simulator static archives. ```text /iosArm64/libpdfium.a /iosSimulatorArm64/libpdfium.a ``` -------------------------------- ### Render PDF pages with PDF Core Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/README.md Use the core API to open a PDF document and render a specific page to a bitmap without UI components. ```kotlin import io.github.limuyang2.pdf.core.PdfPixelSize import io.github.limuyang2.pdf.core.PdfRenderRequest import io.github.limuyang2.pdf.core.PdfSource import io.github.limuyang2.pdf.core.PdfViewer suspend fun renderFirstPage(pdfBytes: ByteArray): ByteArray { val document = PdfViewer.open(PdfSource.Bytes(pdfBytes)) try { require(document.pageCount > 0) val bitmap = document[0].render( PdfRenderRequest( outputSize = PdfPixelSize(1200, 1600), ), ) try { return bitmap.copyPixels() } finally { bitmap.close() } } finally { document.close() } } ``` -------------------------------- ### Initialize PDF View State Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Create a state object to manage the initial page and zoom level of the PDF viewer. ```kotlin val state = rememberPdfViewState( initialPage = 0, initialZoom = 1f, ) ``` -------------------------------- ### Build upstream PDFium targets Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Commands to build device and simulator archives for iOS using the upstream build script. ```bash ./build.sh -b chromium/7961 -s ios arm64 device ./build.sh -b chromium/7961 -s ios arm64 simulator ``` -------------------------------- ### Inspect Page Properties Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Retrieve page-specific information such as size, rotation, and bounding box using PDF points. ```kotlin val page = document[0] val information = page.information() println(information.size) // PDF points println(information.rotation) // Intrinsic page rotation println(information.boundingBox) ``` -------------------------------- ### Link Apple Frameworks Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Links the debug frameworks for iOS ARM64 and iOS Simulator ARM64 on a macOS host. ```bash ./gradlew \ :shared:linkDebugFrameworkIosArm64 \ :shared:linkDebugFrameworkIosSimulatorArm64 ``` -------------------------------- ### Add PDF Viewer dependency Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Include the library in your commonMain source set dependencies. ```kotlin kotlin { sourceSets { commonMain.dependencies { implementation("io.github.limuyang2:pdf-viewer:0.2.2") } } } ``` -------------------------------- ### Retrieve Document Information Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Access document metadata, page labels, and individual pages using zero-based indexing. ```kotlin val information = document.information() val metadata = document.metadata() val label = document.pageLabel(pageIndex = 0) val firstPage = document[0] ``` -------------------------------- ### Check PDF Viewer Capabilities Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Use the capabilities property to verify supported features before invoking optional functionality. ```kotlin val capabilities = PdfViewer.capabilities println("text=${capabilities.text}") println("search=${capabilities.search}") println("links=${capabilities.links}") ``` -------------------------------- ### Open and Inspect a PDF Document Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Open a document using PdfSource.Bytes and access its metadata. Ensure the document is closed in a finally block to release resources. ```kotlin import io.github.limuyang2.pdf.core.PdfSource import io.github.limuyang2.pdf.core.PdfViewer suspend fun inspectDocument(bytes: ByteArray) { val document = PdfViewer.open(PdfSource.Bytes(bytes)) try { println("Pages: ${document.pageCount}") println("PDF version: ${document.information().version}") println("Title: ${document.metadata().title}") } finally { document.close() } } ``` -------------------------------- ### Navigate Search Results Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Programmatically select and scroll to the next or previous search result. ```kotlin scope.launch { state.selectNextSearchResult()?.let { result -> state.animateScrollToSearchResult(result) } } scope.launch { state.selectPreviousSearchResult()?.let { result -> state.animateScrollToSearchResult(result) } } ``` -------------------------------- ### Open Password-Protected PDF Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Provide a password string when opening a document to handle encrypted files. ```kotlin val document = PdfViewer.open( source = PdfSource.Bytes(bytes), password = "secret", ) ``` -------------------------------- ### Perform Document Search Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Initiate a search operation and bind the results to a PdfView component. ```kotlin val state = rememberPdfViewState() LaunchedEffect(document, query, matchCase, matchWholeWord) { state.search( document = document, query = query, options = PdfSearchOptions( matchCase = matchCase, matchWholeWord = matchWholeWord, ), ) } PdfView( document = document, state = state, ) ``` -------------------------------- ### Compile Non-iOS Targets Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Builds the project for Android, JVM, and Wasm platforms using Gradle. ```bash ./gradlew :pdf-core:compileAndroidMain ./gradlew :pdf-core:compileKotlinJvm ./gradlew :pdf-core:compileKotlinJs ./gradlew :pdf-core:compileKotlinWasmJs ``` -------------------------------- ### Define iOS cinterop static libraries Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Configuration for the cinterop definition to include necessary static archives. ```text staticLibraries = libpdfviewer_core.a libpdfium.a ``` -------------------------------- ### CMake Build Configuration for pdfviewer_core Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/pdf-core-native/CMakeLists.txt Defines the project, library targets, include directories, and compiler settings for the native core. ```cmake cmake_minimum_required(VERSION 3.22.1) project(pdfviewer_core LANGUAGES CXX) set(PDFVIEWER_PDFIUM_INCLUDE_DIR "" CACHE PATH "PDFium public header directory") set(PDFVIEWER_PDFIUM_LIBRARY "" CACHE FILEPATH "PDFium library") add_library(pdfviewer_core STATIC src/pdfviewer_core.cpp) target_include_directories( pdfviewer_core PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include" PRIVATE "${PDFVIEWER_PDFIUM_INCLUDE_DIR}" ) target_compile_features(pdfviewer_core PRIVATE cxx_std_17) target_compile_options(pdfviewer_core PRIVATE -Wall -Wextra -Werror) if(PDFVIEWER_PDFIUM_LIBRARY) add_library(pdfium SHARED IMPORTED) set_target_properties( pdfium PROPERTIES IMPORTED_LOCATION "${PDFVIEWER_PDFIUM_LIBRARY}" ) target_link_libraries(pdfviewer_core PUBLIC pdfium) endif() option(PDFVIEWER_BUILD_TESTS "Build native core tests" OFF) if(PDFVIEWER_BUILD_TESTS) enable_testing() add_executable(pdfviewer_core_test tests/pdfviewer_core_test.cpp) target_link_libraries(pdfviewer_core_test PRIVATE pdfviewer_core) add_test( NAME pdfviewer_core_test COMMAND pdfviewer_core_test "${PDFVIEWER_TEST_PDF}" ) get_filename_component( PDFVIEWER_PDFIUM_LIBRARY_DIR "${PDFVIEWER_PDFIUM_LIBRARY}" DIRECTORY ) set_tests_properties( pdfviewer_core_test PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${PDFVIEWER_PDFIUM_LIBRARY_DIR}" ) endif() ``` -------------------------------- ### PDFium Release Download URL Template Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md The base URL pattern for downloading upstream PDFium release archives. ```text https://github.com/bblanchon/pdfium-binaries/releases/download// ``` -------------------------------- ### Render Page to Bitmap Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Render a PDF page into a bitmap with specific dimensions and settings, ensuring the bitmap is closed after use. ```kotlin import io.github.limuyang2.pdf.core.PdfColor import io.github.limuyang2.pdf.core.PdfPixelSize import io.github.limuyang2.pdf.core.PdfRenderRequest import io.github.limuyang2.pdf.core.PdfRotation val bitmap = document[0].render( PdfRenderRequest( outputSize = PdfPixelSize(width = 1200, height = 1600), rotation = PdfRotation.Degrees0, backgroundColor = PdfColor.White, renderAnnotations = true, grayscale = false, optimizeTextForLcd = false, ), ) try { val pixels = bitmap.copyPixels() println("${bitmap.width} × ${bitmap.height}") println("stride=${bitmap.stride}, format=${bitmap.format}") } finally { bitmap.close() } ``` -------------------------------- ### Verify Update Integrity Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Executes layout and checksum verification to ensure the PDFium update was successful and consistent. ```bash sh scripts/tests/update-pdfium-layout-test.sh ``` -------------------------------- ### Add PDF Core Dependency Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Include the library in your Kotlin Multiplatform project's commonMain source set. ```kotlin kotlin { sourceSets { commonMain.dependencies { implementation("io.github.limuyang2:pdf-core:0.2.2") } } } ``` -------------------------------- ### Display PDF documents with Compose Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/README.md Implement a vertically scrolling PDF viewer using the PdfView component in Jetpack Compose. ```kotlin import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import io.github.limuyang2.pdf.core.PdfDocument import io.github.limuyang2.pdf.viewer.PdfView import io.github.limuyang2.pdf.viewer.rememberPdfViewState @Composable fun DocumentPreview(document: PdfDocument) { val state = rememberPdfViewState() PdfView( document = document, state = state, modifier = Modifier.fillMaxSize(), maxZoom = 4f, gestureZoomEnabled = true, ) } ``` -------------------------------- ### Access Search Status and Results Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Retrieve current search progress, result list, and selection state from the viewer state. ```kotlin val status = state.searchStatus val results = state.searchResults val selectedIndex = state.selectedSearchResultIndex val selectedResult = state.selectedSearchResult ``` -------------------------------- ### PdfView(document, state, modifier, pageSpacing, pagePadding, pageColor, maxRenderDimension, maxZoom, gestureZoomEnabled) Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md The PdfView composable is the primary entry point for rendering a PDF document. It supports various configuration parameters for layout, zoom behavior, and rendering performance. ```APIDOC ## PdfView ### Description A composable function to display a PDF document with customizable viewing parameters. ### Parameters - **document** (Document) - Required - The PDF document to render. - **state** (PdfViewState) - Optional - Manages scroll position, zoom, current page, and render cache. Defaults to `rememberPdfViewState()`. - **modifier** (Modifier) - Optional - Modifier to be applied to the layout. - **pageSpacing** (Dp) - Optional - Vertical space between pages. Defaults to `12.dp`. - **pagePadding** (Dp) - Optional - Padding around the page list. Defaults to `0.dp`. - **pageColor** (Color) - Optional - Background color behind a rendered page. Defaults to `Color.White`. - **pageBorder** (Dp?) - Optional - Border width for pages. Defaults to 1 dp translucent border. - **maxZoom** (Float) - Optional - Maximum visual zoom multiplier. Must be finite and at least 1f. Defaults to `4f`. - **gestureZoomEnabled** (Boolean) - Optional - Enables or disables multi-touch zoom. Defaults to `true`. - **maxRenderDimension** (Int) - Optional - Maximum width or height, in pixels, of each rendered bitmap. Defaults to `4096`. - **searchHighlightStyle** (Style) - Optional - Styling for search results and selected result. Defaults to yellow matches and orange selection. ``` -------------------------------- ### Animate Scroll to Page Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Execute page navigation within a coroutine scope, typically triggered by UI events. ```kotlin val scope = rememberCoroutineScope() Button( onClick = { scope.launch { state.animateScrollToPage(10) } }, ) { Text("Page 11") } ``` -------------------------------- ### Read PDF links with Kotlin Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Iterates through page links and handles different target types including internal pages, URIs, and remote documents. ```kotlin import io.github.limuyang2.pdf.core.PdfLinkTarget document[0].links().forEach { link -> when (val target = link.target) { is PdfLinkTarget.Internal -> println("Page ${target.destination.pageIndex}") is PdfLinkTarget.Uri -> println(target.uri) is PdfLinkTarget.RemoteDocument -> println(target.filePath) is PdfLinkTarget.Unsupported -> println("Native action ${target.nativeActionType}") } } ``` -------------------------------- ### CMake Build Configuration for PDF Viewer Bridge Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/pdf-core-android-native/src/main/cpp/CMakeLists.txt Defines the project, imports the PDFium shared library, and configures the build settings for the native bridge library. ```cmake cmake_minimum_required(VERSION 3.22.1) project(pdfviewer_bridge LANGUAGES CXX) add_library(pdfium SHARED IMPORTED) set_target_properties( pdfium PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/../jniLibs/${ANDROID_ABI}/libpdfium.so" ) add_library( pdfviewer_bridge SHARED pdfviewer_bridge.cpp "${CMAKE_CURRENT_LIST_DIR}/../../../../pdf-core-native/src/pdfviewer_core.cpp" ) target_include_directories( pdfviewer_bridge PRIVATE "${CMAKE_CURRENT_LIST_DIR}/../../../../pdf-core/src/nativeInterop/cinterop/include" "${CMAKE_CURRENT_LIST_DIR}/../../../../pdf-core-native/include" ) target_compile_features(pdfviewer_bridge PRIVATE cxx_std_17) target_compile_options( pdfviewer_bridge PRIVATE -Wall -Wextra -Werror ) target_link_libraries(pdfviewer_bridge PRIVATE pdfium) ``` -------------------------------- ### Handle PDF Link Interactions Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Intercept link clicks using onLinkClick, which runs before default behavior. Return true to consume the link, or use onUriLinkClick to handle URI links specifically. ```kotlin PdfView( document = document, onLinkClick = { link -> println("PDF link: $link") false }, onUriLinkClick = { uri -> println("Open URI with the application: $uri") }, onLinkError = { pageIndex, link, error -> println("Link on page $pageIndex failed: $link, $error") }, ) ``` -------------------------------- ### Control Viewer State Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Use these methods to manipulate zoom, scroll to specific pages, or clear the render cache. ```kotlin state.updateZoom(2f) state.zoomBy(1.25f) state.scrollToPage(pageIndex = 4) state.animateScrollToPage(pageIndex = 4) state.clearRenderCache() ``` -------------------------------- ### Search PDF text with Kotlin Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Performs a text search on a document page using PdfSearchOptions. Verify search capability via PdfViewer.capabilities.search before execution. ```kotlin import io.github.limuyang2.pdf.core.PdfSearchOptions if (PdfViewer.capabilities.search) { val matches = document[0].search( query = "Compose", options = PdfSearchOptions( matchCase = false, matchWholeWord = true, ), ) matches.forEach { match -> println("${match.range}: ${match.bounds}") } } ``` -------------------------------- ### Customize Page Loading and Error UI Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Use pageLoadingContent and pageErrorContent to define custom composables for loading states and error messages. The onPageError callback is used for logging or reporting failures. ```kotlin PdfView( document = document, pageLoadingContent = { pageIndex -> CircularProgressIndicator() }, pageErrorContent = { pageIndex, error -> Text("Page ${pageIndex + 1}: ${error.message}") }, onPageError = { pageIndex, error -> println("PDF page $pageIndex failed: $error") }, ) ``` -------------------------------- ### Update PDFium Version Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md Commands to update the PDFium version, either preserving existing iOS archives or providing a new static root path. ```bash ./scripts/update-pdfium.sh chromium/7961 ``` ```bash PDFIUM_IOS_STATIC_ROOT=/absolute/path/to/static-root \ ./scripts/update-pdfium.sh chromium/ ``` -------------------------------- ### PDFium C Header Location Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md The directory where PDFium C headers are extracted. ```text pdf-core/src/nativeInterop/cinterop/include ``` -------------------------------- ### Set PDFium Base URL for Web Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Set the base URL before the first call to PdfViewer.open() to use a custom directory for assets. ```javascript globalThis.__pdfViewerPdfiumBaseUrl = "/assets/pdfium/"; ``` -------------------------------- ### Customize Search Result Alignment Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-viewer.md Adjust the scroll alignment of a search result using fractional coordinates. ```kotlin state.animateScrollToSearchResult( result = result, alignment = PdfSearchScrollAlignment( verticalFraction = 0.5f, horizontalFraction = 0.5f, ), ) ``` -------------------------------- ### Pinned PDFium Release Version Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/BUILD.md The current version of PDFium used by the project. ```text chromium/7961 ``` -------------------------------- ### Extract PDF text with Kotlin Source: https://github.com/limuyang2/pdf-viewer-kmp/blob/main/docs/using-pdf-core.md Extracts text from a page, optionally using PdfTextRange to specify character indexes. Note that indexes are based on PDFium rather than Kotlin string indexes. ```kotlin import io.github.limuyang2.pdf.core.PdfTextRange val page = document[0] val allText = page.extractText() val firstCharacters = page.extractText( PdfTextRange( startCharacterIndex = 0, characterCount = 20, ), ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.