### Open ChatGPT with Documentation Context Source: https://www.nutrient.io/guides/android/migration-guides/2024-9-migration-guide Opens ChatGPT in a new tab, pre-filled with a prompt that includes the current page's URL and a request for assistance with the documentation. Useful for quickly getting AI help. ```javascript function v(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://chatgpt.com/?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Share Documentation with Claude AI Source: https://www.nutrient.io/guides/android/compare-documents Opens a new browser tab with Claude AI's new chat interface, pre-filled with a contextually relevant query about the current Nutrient documentation page. The prompt encourages Claude to assist with understanding, examples, and debugging. ```javascript function x(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://claude.ai/new?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Add Nutrient Instant Dependencies to build.gradle Source: https://www.nutrient.io/guides/android/pspdfkit-instant/getting-started This snippet shows how to add the necessary OkHttp dependency for integrating Nutrient's Instant feature into your Android project's build.gradle file. Ensure you replace '' with the actual version number. ```gradle dependencies { implementation 'com.squareup.okhttp3:okhttp:' } ``` -------------------------------- ### Share Documentation with ChatGPT Source: https://www.nutrient.io/guides/android/compare-documents Opens a new browser tab with ChatGPT, pre-filled with a query related to the current Nutrient documentation page. The query prompts ChatGPT to help understand the documentation, provide explanations, examples, or debug issues. ```javascript function v(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://chatgpt.com/?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Share Documentation with Grok AI Source: https://www.nutrient.io/guides/android/compare-documents Opens a new browser tab with Grok AI, pre-populated with a query based on the current Nutrient documentation page. The query asks Grok to provide assistance with understanding the documentation, offering examples, or debugging. ```javascript function C(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://grok.com/c?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Android Kotlin: Launch Example for Runtime Configuration Source: https://www.nutrient.io/guides/android/samples/runtime-configuration-fragment-kotlin Launches an example demonstrating runtime PDF configuration changes. It extracts a welcome document and starts a custom activity to display it, passing the document's URI as an extra. This is designed for Android using Kotlin. ```kotlin class CustomFragmentRuntimeConfigurationExample(context: Context) : SdkExample(context, R.string.runtimeConfigurationFragmentExampleTitle, R.string.runtimeConfigurationFragmentExampleDescription) { override fun launchExample(context: Context, configuration: PdfActivityConfiguration.Builder) { ExtractAssetTask.extract(WELCOME_DOC, title, context) { documentFile: File? -> val intent = Intent(context, CustomFragmentRuntimeConfigurationActivity::class.java) intent.putExtra(CustomFragmentRuntimeConfigurationActivity.EXTRA_URI, Uri.fromFile(documentFile)) context.startActivity(intent) } } } ``` -------------------------------- ### Open ChatGPT with Documentation Prompt Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-9-migration-guide Opens a new tab with ChatGPT, pre-filled with a prompt that includes the current documentation URL and a request for assistance. This allows users to quickly ask questions about the documentation. Dependencies: `window.open`, `encodeURIComponent`, `window.location`. ```javascript function v(i){const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`,s=`https://chatgpt.com/?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Open Claude AI with Documentation Prompt Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-9-migration-guide Opens a new tab with Claude AI, pre-filled with a prompt that includes the current documentation URL and a request for assistance. This facilitates asking context-aware questions to Claude. Dependencies: `window.open`, `encodeURIComponent`, `window.location`. ```javascript function x(i){const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`,s=`https://claude.ai/new?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Android: Launch Document Download Example Source: https://www.nutrient.io/guides/android/samples/custom-download-progress-dialog Launches an example document download using the LLMS SDK. It constructs a DownloadRequest with a URI, output file, and overwrite option, then starts the download job. It also sets up a ProgressListener to handle download completion or errors, navigating to a PDF viewer upon success or showing an error dialog. ```java @Override public void launchExample( @NonNull final Context context, @NonNull final PdfActivityConfiguration.Builder configuration) { // Build a download request based on various input parameters. final DownloadRequest request = new DownloadRequest.Builder(context) .uri("https://nutrient.io/downloads/case-study-box.pdf") .outputFile(new File(context.getDir("documents", Context.MODE_PRIVATE), "case-study-box.pdf")) .overwriteExisting(true) .build(); // This will initiate the download. final DownloadJob job = DownloadJob.startDownload(request); final DownloadProgressFragment fragment = new CustomDownloadProgressFragment(); fragment.show(((FragmentActivity) context).getSupportFragmentManager(), "download-fragment"); fragment.setJob(job); job.setProgressListener(new DownloadJob.ProgressListenerAdapter() { @Override public void onComplete(@NonNull File output) { final Intent intent = PdfActivityIntentBuilder.fromUri(context, Uri.fromFile(output)) .configuration(configuration.build()) .build(); context.startActivity(intent); } @Override public void onError(@NonNull Throwable exception) { new AlertDialog.Builder(context) .setMessage( "There was an error downloading the example PDF file. For further information see Logcat.") .show(); } }); } ``` -------------------------------- ### Java Example: Get Page Text Source: https://www.nutrient.io/guides/android/extraction/parse-content Example demonstrating how to get all the text found on a single PDF page using the `getPageText()` method in Java. ```APIDOC ## JAVA EXAMPLE ### Description Demonstrates retrieving text from a PDF page using `PdfDocument.getPageText()` in Java. ### Method ```java PdfDocument document = ...; String pageText = document.getPageText(0); ``` ### Endpoint N/A (Client-side code) ### Parameters N/A ### Request Example ```java PdfDocument document = ...; // Assume PdfDocument is initialized int pageNumber = 0; String pageText = document.getPageText(pageNumber); System.out.println(pageText); // Prints the text content of the specified page ``` ### Response #### Success Response (200) - **pageText** (string) - The text content extracted from the specified page. #### Response Example ```java // If the first page contains "Hello, world!" String pageText = "Hello, world!"; ``` ``` -------------------------------- ### Open Grok AI with Documentation Prompt Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-9-migration-guide Opens a new tab with Grok AI, pre-filled with a prompt that includes the current documentation URL and a request for assistance. This allows users to interact with Grok AI regarding the documentation content. Dependencies: `window.open`, `encodeURIComponent`, `window.location`. ```javascript function C(i){const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`,s=`https://grok.com/c?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Kotlin Example: Get Page Text Source: https://www.nutrient.io/guides/android/extraction/parse-content Example demonstrating how to get all the text found on a single PDF page using the `getPageText()` method in Kotlin. ```APIDOC ## KOTLIN EXAMPLE ### Description Demonstrates retrieving text from a PDF page using `PdfDocument.getPageText()` in Kotlin. ### Method ```kotlin val document: PdfDocument = ... val pageText = document.getPageText(0) ``` ### Endpoint N/A (Client-side code) ### Parameters N/A ### Request Example ```kotlin val document: PdfDocument = ... // Assume PdfDocument is initialized val pageNumber = 0 val pageText = document.getPageText(pageNumber) println(pageText) // Prints the text content of the specified page ``` ### Response #### Success Response (200) - **pageText** (string) - The text content extracted from the specified page. #### Response Example ```kotlin // If the first page contains "Hello, world!" val pageText = "Hello, world!" ``` ``` -------------------------------- ### Open ChatGPT with Context Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-2-migration-guide Opens ChatGPT in a new tab, pre-populated with a query related to the current Nutrient documentation page. The query asks for help understanding and using the documentation, indicating readiness to explain concepts, give examples, or debug. The base URL for ChatGPT is included, with the query string properly encoded. ```javascript function v(i){ const t = "https://www.nutrient.io", o = window.location.pathname, r = `I'm looking at this Nutrient documentation: ${`${t}${o}`}\nHelp me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`; const s = `https://chatgpt.com/?q=${encodeURIComponent(r)}`; window.open(s, "_blank"); } ``` -------------------------------- ### Java Example Source: https://www.nutrient.io/guides/android/annotations/position-and-size Example of accessing and logging an annotation's bounding box details in Java. ```APIDOC ## Java Code Snippet ### Description This code demonstrates how to retrieve an annotation's bounding box and log its coordinates and dimensions in PDF points using Java. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) N/A (Code Example) #### Response Example ```java final RectF boundingBox = annotation.getBoundingBox(); Log.d(TAG, String.format("The annotation sits at coordinates [%f, %f].", boundingBox.left, boundingBox.bottom)); Log.d(TAG, String.format("The annotation is %f x %f PDF points large.", boundingBox.width(), boundingBox.height())); ``` ``` -------------------------------- ### Kotlin Example Source: https://www.nutrient.io/guides/android/annotations/position-and-size Example of accessing and logging an annotation's bounding box details in Kotlin. ```APIDOC ## Kotlin Code Snippet ### Description This code demonstrates how to retrieve an annotation's bounding box and log its coordinates and dimensions in PDF points using Kotlin. ### Method N/A (Code Example) ### Endpoint N/A (Code Example) ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) N/A (Code Example) #### Response Example ```kotlin Log.d(TAG, "The annotation sits at coordinates [${annotation.boundingBox.left}, " + "${annotation.boundingBox.bottom}.") Log.d(TAG, "The annotation is " + "${annotation.boundingBox.width()} x ${annotation.boundingBox.height()} PDF points large.") ``` ``` -------------------------------- ### VWO Script Loading and Initialization (JavaScript) Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-7-migration-guide This snippet demonstrates the core VWO initialization logic. It includes functions to load scripts via `XMLHttpRequest` or dynamically, retrieve and manage settings from `localStorage`, and handle the initial setup. The `init` function orchestrates the loading of VWO configurations based on URL parameters and applies settings. ```javascript var _vwo_code = (function() { var cK = 'vwo_settings'; var stT = localStorage; var d = document; var w = window; var account_id = 123456; var version = '1.0.0'; var code = { settings_tolerance: function() { var e = stT.getItem(cK); if (!e) return 10000; try { e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return 10000; } return e.s; } catch (e) { return 10000; } }, addScript: function(t) { var e = d.createElement('script'); e.async = true; if (t.src) { e.src = t.src; } if (t.text) { e.text = t.text; } d.body.appendChild(e); }, load: function(e, t) { t = t || {}; if (w.location.search.indexOf('__vwo_xhr__') !== -1) { var o = new XMLHttpRequest(); o.open('GET', e, true); o.withCredentials = !t.dSC; o.responseType = t.responseType || 'text'; o.onload = function() { if (t.onloadCb) { return t.onloadCb(o, e); } if (o.status === 200 || o.status === 304) { _vwo_code.addScript({ text: o.responseText }); } else { _vwo_code.finish('&e=loading_failure:' + e); } }; o.onerror = function() { if (t.onerrorCb) { return t.onerrorCb(e); } _vwo_code.finish('&e=loading_failure:' + e); }; o.send(); } else { var script = d.createElement('script'); script.src = e; script.async = true; d.body.appendChild(script); } }, getSettings: function() { try { var e = stT.getItem(cK); if (!e) { return; } e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return; } return e.s; } catch (e) { return; } }, init: function() { if (d.URL.indexOf('__vwo_disable__') > -1) return; var e = this.settings_tolerance(); w._vwo_settings_timer = setTimeout(function() { _vwo_code.finish(); stT.removeItem(cK); }, e); var o = w.location.search.indexOf('_vwo_xhr') !== -1 ? w._vis_opt_url || d.URL : d.URL; var s = 'https://dev.visualwebsiteoptimizer.com/j.php?a=' + account_id + '&u=' + encodeURIComponent(o) + '&vn=' + version; if (w.location.search.indexOf('_vwo_xhr') !== -1) { this.addScript({ src: s }); } else { this.load(s + '&x=true'); } } }; w._vwo_code = code; if (d.readyState === 'loading') { d.addEventListener('DOMContentLoaded', function() { code.init(); }); } else { if ('requestIdleCallback' in w) { requestIdleCallback(function() { code.init(); }, { timeout: 1000 }); } else { setTimeout(function() { code.init(); }, 0); } } return code; })(); _vwo_code.finish = function(query) { console.log('VWO finished with:', query); }; ``` -------------------------------- ### VWO Initialization and Script Loading (JavaScript) Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-9-migration-guide This snippet demonstrates how to initialize VWO, load its settings from local storage, and dynamically add the VWO script to the page. It handles both XHR and direct script loading, with error callbacks and settings expiration. ```javascript var _vwo_code = (function() { var cK = "_vwo_data_"; var stT = localStorage; var d = document; var w = window; var account_id = 12345; // Replace with actual account ID var version = "1.0.0"; // Replace with actual version var code = { settings_tolerance: function() { var e = stT.getItem(cK); if (!e) { return 10000; } try { e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return 10000; } return e.s; } catch (e) { return 10000; } }, addScript: function(t) { var e = d.createElement('script'); e.src = t.src; e.async = true; d.body.appendChild(e); }, load: function(e, t) { t = t || {}; if (w.location.search.indexOf('__vwo_xhr__') !== -1) { var o = new XMLHttpRequest(); o.open('GET', e, true); o.withCredentials = !t.dSC; o.responseType = t.responseType || 'text'; o.onload = function() { if (t.onloadCb) { return t.onloadCb(o, e) } if (o.status === 200 || o.status === 304) { _vwo_code.addScript({ text: o.responseText }); } else { _vwo_code.finish('&e=loading_failure:' + e); } }; o.onerror = function() { if (t.onerrorCb) { return t.onerrorCb(e) } _vwo_code.finish('&e=loading_failure:' + e); }; o.send(); } else { this.addScript({ src: e }); } }, getSettings: function() { try { var e = stT.getItem(cK); if (!e) { return } e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return } return e.s; } catch (e) { return } }, init: function() { if (d.URL.indexOf('__vwo_disable__') > -1) return; var e = this.settings_tolerance(); w._vwo_settings_timer = setTimeout(function() { _vwo_code.finish(); stT.removeItem(cK); }, e); var o = w.location.search.indexOf('_vwo_xhr') !== -1 ? w._vis_opt_url || d.URL : d.URL; var s = 'https://dev.visualwebsiteoptimizer.com/j.php?a=' + account_id + '&u=' + encodeURIComponent(o) + '&vn=' + version; if (w.location.search.indexOf('_vwo_xhr') !== -1) { this.addScript({ src: s }); } else { this.load(s + '&x=true'); } } }; return code; })(); // Defer initialization to prevent render blocking if (d.readyState === 'loading') { d.addEventListener('DOMContentLoaded', function() { _vwo_code.init(); }); } else { // If DOM is already loaded, use requestIdleCallback or setTimeout if ('requestIdleCallback' in w) { requestIdleCallback(function() { _vwo_code.init(); }, { timeout: 1000 }); } else { setTimeout(function() { _vwo_code.init(); }, 0); } } // Assuming _vwo_code is assigned globally and then used // Example usage of finish (hypothetical) // _vwo_code.finish = function(reason) { console.log('VWO finished with reason:', reason); }; // Example of potentially adding a script with text (if responseType was text) // _vwo_code.addScript({ text: "console.log('VWO script loaded via text');" }); ``` -------------------------------- ### Change PDF Page Programmatically (Kotlin) Source: https://www.nutrient.io/guides/android/basics/document-interactions Demonstrates how to change the current page of a PDF document using the PdfFragment in Kotlin. It includes examples for setting a specific page index, navigating to the last page with animation, and returning to the starting page. This functionality is crucial for custom PDF navigation flows. ```kotlin val startPage = fragment.getPageIndex() // Change to page 13 (zero-based page numbers). fragment.pageIndex = 12 // Go to the last page using a transitioning animation. val lastPage = document.pageCount - 1 fragment.setPageIndex(lastPage, true) // Go back to the page where you started off. fragment.setPageIndex(startPage) ``` -------------------------------- ### Open AI Chat with Documentation Context (Grok) Source: https://www.nutrient.io/guides/android/annotations/position-and-size Opens a new browser tab with Grok AI, pre-populated with a query specific to the current Nutrient documentation page. The query aims to get help understanding and using the documentation, with the AI expected to provide explanations, examples, or debugging assistance. ```javascript function C(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`}\nHelp me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://grok.com/c?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### VWO Initialization and Script Execution Logic Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-5-migration-guide This section details the initialization process for VWO. It includes fetching settings, setting a timer for VWO initialization, constructing the VWO JavaScript URL based on the current page, and dynamically loading the script. Initialization is deferred using `requestIdleCallback` or `setTimeout` to prevent render blocking. ```javascript init:function(){if(d.URL.indexOf('__vwo_disable__')>-1)return;var e=this.settings_tolerance();w._vwo_settings_timer=setTimeout(function(){_vwo_code.finish();stT.removeItem(cK)},e);var o=window._vis_opt_url||d.URL,s='https://dev.visualwebsiteoptimizer.com/j.php?a='+account_id+'&u='+encodeURIComponent(o)+'&vn='+version;if(w.location.search.indexOf('_vwo_xhr')!==-1){this.addScript({src:s})}else{this.load(s+'&x=true')}};w._vwo_code=code;(function(){if(d.readyState==='loading'){d.addEventListener('DOMContentLoaded',function(){code.init()})}else{if('requestIdleCallback'in w){requestIdleCallback(function(){code.init()},{timeout:1000})}else{setTimeout(function(){code.init()},0)}}})() ``` -------------------------------- ### VWO (Visual Website Optimizer) Configuration and Initialization (JavaScript) Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-5-migration-guide This script configures and initializes the VWO (Visual Website Optimizer) for A/B testing and website optimization. It sets account ID, version, and tolerance settings, and includes logic to load VWO settings from local or session storage. It also defines functions for adding scripts and handling the VWO loading process. The script is conditionally executed to prevent multiple initializations. ```javascript window._vwo_code || (function() { var account_id=892495, version=2.1, settings_tolerance=2000, hide_element='', hide_element_style = ''; // DO NOT EDIT BELOW THIS LINE f=false, w=window, d=document, v=d.querySelector('#vwoCode'), cK='_vwo_'+account_id+'_settings', cc={}; try { var c=JSON.parse(localStorage.getItem('_vwo_'+account_id+'_config')); cc=c&&typeof c==='object'?c:{} } catch(e) {} var stT=cc.stT==='session'?w.sessionStorage:w.localStorage; code = { nonce: v&&v.nonce, library_tolerance: function() { return typeof library_tolerance !== 'undefined' ? library_tolerance : undefined; }, settings_tolerance: function() { return cc.sT || settings_tolerance; }, hide_element_style: function() { return '{'+(cc.hES || hide_element_style)+'}' }, hide_element: function() { // Always return empty to prevent hiding return ''; }, getVersion: function() { return version; }, finish: function(e) { if (!f) { f=true; var t=d.getElementById('_vis_opt_path_hides'); if(t)t.parentNode.removeChild(t); if(e)(new Image).src='https://dev.visualwebsiteoptimizer.com/ee.gif?a='+account_id+e; } }, finished: function() { return f; }, addScript: function(e) { var t=d.createElement('script'); t.type='text/javascript'; if(e.src){ t.src=e.src; t.async=true; // Make async }else{ t.text=e.text; } v&&t.setAttribute('nonce',v.nonce); d.getElementsByTagName('head')[0].appendChild(t); }, load: function(e, t) { var n=this.getSettings(), i=d.createElement('script'), r=this; t=t||{}; if(n){ i.textContent=n; d.getElementsByTagName('head')[0].appendChild(i); if(!w.VWO||VWO.caE){ stT.removeI ``` -------------------------------- ### Set Active Navigation Item for SDK (JavaScript) Source: https://www.nutrient.io/guides/android/annotations/introduction-to-annotations This JavaScript code snippet sets the 'is-active' class on the navigation item corresponding to the 'sdk' lobType when the DOM is fully loaded. It specifically targets an element with an ID starting with 'tnb-' and appends '.is-active' to its class list, including a nested element with the class 'nav-card-bottom'. ```javascript (function(){ const lobType = "sdk"; /* global lobType */ const lob = lobType; document.addEventListener("DOMContentLoaded", () => { const activeNavItem = document.getElementById(`tnb-${lob}`); if (activeNavItem) { activeNavItem.classList.add("is-active"); const navCardBottom = activeNavItem.querySelector(".nav-card-bottom"); navCardBottom?.classList.add("is-active"); } }); })(); ``` -------------------------------- ### Initialize Main Functionality Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-2-migration-guide This is the main entry point for initializing the script's functionality. It calls `E()` to set up event listeners for UI interactions like copying and viewing markdown. It also adds another `DOMContentLoaded` listener that calls `I()` and `A()`, which appear to be related to managing markdown action containers and dropdowns, though their implementations are truncated in the provided code. ```javascript document.addEventListener("DOMContentLoaded", () => { I(); A(); }); function I(){ document.querySelectorAll('\\[id^="markdown-actions-container-"\\]').forEach(t => { const o = t.getAttribute("aria-controls"); if (!o) return; const e = document.getElementById(o), r = t.querySelector(".arrow-dropdown-icon"); if (!e) return; t.addEventListener("click", function(n) { n.stopPropagation(); t.getAttribute("aria-expanded") === "true" ? s() : a(); }); t.addEventListener("keydown", function(n) { if (n.key === "Enter" || n.key === " ") { n.preventDefault(); t.getAttribute("aria-expanded") === "true" ? s() : a(); } else if (n.key === "ArrowDown") { n.preventDefault(); a(); const c = e.querySelector(".markdown-actions-option"); c && c.focus(); } }); e.addEventListener("click", function(n) { if (n.target.closest(".markdown-actions-option")) { n.preventD } }); }); } // Function A is not fully provided in the snippet. function A() { // Placeholder for function A } ``` -------------------------------- ### PdfProcessor - New Page Example (Kotlin) Source: https://www.nutrient.io/guides/android/pdf-generation/from-template This example demonstrates how to create a new PDF page using the PdfProcessor and PdfProcessorTask.newPage() method in Kotlin. ```APIDOC ## POST /api/pdf/process ### Description Creates a new PDF document or modifies an existing one by processing a `PdfProcessorTask`. This specific example shows how to add a new page to a PDF. ### Method POST ### Endpoint `/api/pdf/process` ### Parameters #### Request Body - **task** (PdfProcessorTask) - Required - The task to perform (e.g., creating a new page). - **outputFile** (File) - Required - The file where the processed PDF will be saved. ### Request Example ```json { "task": { "type": "newPage", "content": "..." }, "outputFile": "path/to/output.pdf" } ``` ### Response #### Success Response (200) - **progress** (Observable) - An observable that emits progress updates during the processing. #### Response Example ```json { "progress": "..." } ``` ### Error Handling - **400 Bad Request**: Invalid task or output file. - **500 Internal Server Error**: PDF processing failed. ``` -------------------------------- ### Add Custom Actions to ActionBar (Kotlin) Source: https://www.nutrient.io/guides/android/samples Learn how to modify ActionBar icons in your Android app with this example. This guide offers more on customizing PDF metadata and interfaces. ```Kotlin // Code example for modifying ActionBar icons in your Android app. // Visit the guide for more on customizing PDF metadata and interfaces. ``` -------------------------------- ### Generate Grok AI Link - JavaScript Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-1-migration-guide Generates a URL to open Grok AI with a pre-filled prompt related to the current documentation page. The prompt includes the current page's URL and a request for assistance understanding the documentation. Uses `window.open` to redirect the user. ```javascript function C(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://grok.com/c?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Java - DocumentComparisonDialog.show() Source: https://www.nutrient.io/guides/android/compare-documents Example of how to use the show() method in Java. ```APIDOC ## Java Example ### Description This example demonstrates calling the `show()` method of `DocumentComparisonDialog` in Java. ### Method Java method call ### Code ```java PdfActivityConfiguration configurations = /** PdfActivity configuration to provide theme. */ ComparisonDocument oldDocument = /* The old version of a document. */ ComparisonDocument newDocument = /* The new version of a document. */ ComparisonDialogListener listener = /* The implementation for the document comparison alignment callback. */ File outputFile = /* Output file for the comparison document. */ DocumentComparisonDialog.show(activity, configuration, oldDocument, newDocument, outputFile, listener) ``` ``` -------------------------------- ### Open Claude AI with Documentation Context Source: https://www.nutrient.io/guides/android/migration-guides/2024-9-migration-guide Opens Claude AI in a new tab, pre-filled with a prompt that includes the current page's URL and a request for assistance with the documentation. Facilitates quick AI-driven support. ```javascript function x(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://claude.ai/new?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Kotlin - DocumentComparisonDialog.show() Source: https://www.nutrient.io/guides/android/compare-documents Example of how to use the show() method in Kotlin. ```APIDOC ## Kotlin Example ### Description This example demonstrates calling the `show()` method of `DocumentComparisonDialog` in Kotlin. ### Method Java/Kotlin method call ### Code ```kotlin val configurations: PdfActivityConfiguration = /** PdfActivity configuration to provide theme. */ val oldDocument: ComparisonDocument = /* The old version of a document. */ val newDocument: ComparisonDocument = /* The new version of a document. */ val outputFile: File = /* Output file for the comparison document. */ val listener: ComparisonDialogListener = /* The implementation for the comparison document callback. */ DocumentComparisonDialog.show(activity, configuration, oldDocument, newDocument, outputFile, listener) ``` ``` -------------------------------- ### Initialize VWO with Dynamic Script Loading (JavaScript) Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-8-6-migration-guide This snippet demonstrates the core VWO initialization process. It defines functions to fetch settings, load scripts either via XMLHttpRequest or by dynamically creating script tags, and initiates the VWO code execution. It includes error handling for network requests and a fallback for browsers not supporting `requestIdleCallback`. ```javascript var _vwo_code = (function() { var d = document; var w = window; var cK = "_vwo_c_settings"; var stT = w.localStorage; var account_id = 12345; // Example Account ID var version = "2.0.0"; // Example Version var code = { settings_tolerance: function() { var e = stT.getItem(cK); if (!e) { return 1000 * 60 * 5; // 5 minutes default tolerance } e = JSON.parse(e); return e.t || 1000 * 60 * 5; }, addScript: function(t) { var e = d.createElement('script'); e.async = true; if (t.src) { e.src = t.src; } if (t.text) { e.text = t.text; } e.onload = t.onload; e.onerror = t.onerror; d.body.appendChild(e); }, load: function(e, t) { t = t || {}; var r = this; if (stT.getItem(cK)) { var n = stT.getItem(cK); n = JSON.parse(n); if (Date.now() < n.e) { if (t.onloadCb) return t.onloadCb(n.s, e); _vwo_code.addScript({text: n.s}); return; } } var o = new XMLHttpRequest; o.open('GET', e, true); o.withCredentials = !t.dSC; o.responseType = t.responseType || 'text'; o.onload = function() { if (t.onloadCb) { return t.onloadCb(o, e); } if (o.status === 200 || o.status === 304) { _vwo_code.addScript({text: o.responseText}); } else { _vwo_code.finish('&e=loading_failure:' + e); } }; o.onerror = function() { if (t.onerrorCb) { return t.onerrorCb(e); } _vwo_code.finish('&e=loading_failure:' + e); }; o.send(); }, getSettings: function() { try { var e = stT.getItem(cK); if (!e) { return; } e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return; } return e.s; } catch (e) { return; } }, init: function() { if (d.URL.indexOf('__vwo_disable__') > -1) return; var e = this.settings_tolerance(); w._vwo_settings_timer = setTimeout(function() { _vwo_code.finish(); stT.removeItem(cK); }, e); var o = w.location.search.indexOf('_vwo_xhr') !== -1 ? w._vis_opt_url || d.URL : d.URL; var s = 'https://dev.visualwebsiteoptimizer.com/j.php?a=' + account_id + '&u=' + encodeURIComponent(o) + '&vn=' + version; if (w.location.search.indexOf('_vwo_xhr') !== -1) { this.addScript({src: s}); } else { this.load(s + '&x=true'); } } }; w._vwo_code = code; if (d.readyState === 'loading') { d.addEventListener('DOMContentLoaded', function() { code.init(); }); } else { if ('requestIdleCallback' in w) { requestIdleCallback(function() { code.init(); }, {timeout: 1000}); } else { setTimeout(function() { code.init(); }, 0); } } })(); ``` -------------------------------- ### Implement Custom Annotation Inspector (Java) Source: https://www.nutrient.io/guides/android/samples Learn to implement a custom annotation inspector in Android for enhanced annotation features. This guide offers practical insights and example code. ```Java // Code example for implementing a custom annotation inspector in Android. // Access the guide and example code for enhancing your annotation features effectively. ``` -------------------------------- ### Customize Ink Annotation Note Hints (Kotlin) Source: https://www.nutrient.io/guides/android/samples Discover how to customize ink annotation note hints in Android. Access this guide and example code to optimize your PDF rendering experience. ```Kotlin // Code example for customizing ink annotation note hints in Android. // Access the guide and example code to optimize your PDF rendering experience. ``` -------------------------------- ### Open Grok AI with Documentation Context Source: https://www.nutrient.io/guides/android/migration-guides/2024-9-migration-guide Opens Grok AI in a new tab, pre-filled with a prompt that includes the current page's URL and a request for assistance with the documentation. Enables immediate AI interaction for document clarification. ```javascript function C(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://grok.com/c?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Generate ChatGPT Link - JavaScript Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-5-1-migration-guide Generates a URL to open ChatGPT with a pre-filled prompt related to the current documentation page. The prompt includes the current page's URL and a request for assistance understanding the documentation. Uses `window.open` to redirect the user. ```javascript function v(i){ const t="https://www.nutrient.io", o=window.location.pathname, r=`I'm looking at this Nutrient documentation: ${`${t}${o}`} Help me understand how to use it. Be ready to explain concepts, give examples, or help debug based on it.`, s=`https://chatgpt.com/?q=${encodeURIComponent(r)}`; window.open(s,"_blank") } ``` -------------------------------- ### Customize PDF View Layout (Kotlin) Source: https://www.nutrient.io/guides/android/samples Learn how to customize the PDF viewer layout in Android using a step-by-step guide and example code. Enhance your app's interface with these customization options. ```Kotlin // Code example for customizing the PDF viewer layout in Android. // Learn how to customize the PDF viewer layout in Android with our step-by-step guide and example code. Enhance your app's interface today! ``` -------------------------------- ### Create Custom Annotation in PDF Toolbar (Java) Source: https://www.nutrient.io/guides/android/samples Adds custom items to the annotation toolbar in Android PDF viewers. This guide provides detailed instructions and example code for extending annotation capabilities. ```Java // Code example for adding custom items to the annotation toolbar in Android. // Visit the guide for detailed instructions and example code. ``` -------------------------------- ### Initialize Visual Website Optimizer (JavaScript) Source: https://www.nutrient.io/guides/android/migration-guides/pspdfkit-6-2-migration-guide This snippet demonstrates the core logic for initializing VWO. It includes fetching settings, constructing the VWO script URL, and dynamically loading the script either via XHR or a script tag. Initialization is deferred using `DOMContentLoaded`, `requestIdleCallback`, or `setTimeout` to ensure non-blocking behavior. ```javascript var _vwo_code = (function() { var cK = "_vwo_settings_"; var stT = localStorage; var d = document; var w = window; var account_id = 12345; // Replace with actual account ID var version = "1.0"; // Replace with actual version var code = { settings_tolerance: function() { var e = stT.getItem(cK); if (!e) { return 5000; } try { e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return 5000; } return e.s; } catch (t) { return 5000; } }, addScript: function(t) { var e = d.createElement('script'); e.type = 'text/javascript'; e.async = true; if (t.src) { e.src = t.src; } else { e.text = t.text; } (d.body || d.head).appendChild(e); }, load: function(e, t) { t = t || {}; if (w.XMLHttpRequest) { var r = new XMLHttpRequest(); r.open('GET', e, true); r.withCredentials = !t.dSC; r.responseType = t.responseType || 'text'; r.onload = function() { if (t.onloadCb) { return t.onloadCb(r, e); } if (r.status === 200 || r.status === 304) { _vwo_code.addScript({ text: r.responseText }); } else { _vwo_code.finish('&e=loading_failure:' + e); } }; r.onerror = function() { if (t.onerrorCb) { return t.onerrorCb(e); } _vwo_code.finish('&e=loading_failure:' + e); }; r.send(); } else { var o = new XMLHttpRequest(); o.open('GET', e, true); o.withCredentials = !t.dSC; o.responseType = t.responseType || 'text'; o.onload = function() { if (t.onloadCb) { return t.onloadCb(o, e); } if (o.status === 200 || o.status === 304) { _vwo_code.addScript({ text: o.responseText }); } else { _vwo_code.finish('&e=loading_failure:' + e); } }; o.onerror = function() { if (t.onerrorCb) { return t.onerrorCb(e); } _vwo_code.finish('&e=loading_failure:' + e); }; o.send(); } }, getSettings: function() { try { var e = stT.getItem(cK); if (!e) { return; } e = JSON.parse(e); if (Date.now() > e.e) { stT.removeItem(cK); return; } return e.s; } catch (e) { return; } }, init: function() { if (d.URL.indexOf('__vwo_disable__') > -1) return; var e = this.settings_tolerance(); w._vwo_settings_timer = setTimeout(function() { _vwo_code.finish(); stT.removeItem(cK); }, e); var o = window._vis_opt_url || d.URL, s = 'https://dev.visualwebsiteoptimizer.com/j.php?a=' + account_id + '&u=' + encodeURIComponent(o) + '&vn=' + version; if (w.location.search.indexOf('_vwo_xhr') !== -1) { this.addScript({ src: s }); } else { this.load(s + '&x=true'); } } }; w._vwo_code = code; if (d.readyState === 'loading') { d.addEventListener('DOMContentLoaded', function() { code.init(); }); } else { if ('requestIdleCallback' in w) { requestIdleCallback(function() { code.init(); }, { timeout: 1000 }); } else { setTimeout(function() { code.init(); }, 0); } } })(); ``` -------------------------------- ### Launch Custom Page Template Example with PSPDFKit SDK Source: https://www.nutrient.io/guides/android/samples/custom-new-pdf-page-template This Java code demonstrates how to launch an example of custom page templates within an Android application using the PSPDFKit SDK. It includes extracting a document from assets and starting a specific activity for the example. Ensure PSPDFKit SDK is integrated into your project. ```java package com.pspdfkit.catalog.examples.java; import static com.pspdfkit.catalog.tasks.ExtractAssetTask.extract; import android.content.Context; import android.content.Intent; import android.net.Uri; import androidx.annotation.NonNull; import com.pspdfkit.catalog.R; import com.pspdfkit.catalog.SdkExample; import com.pspdfkit.catalog.examples.java.activities.CustomPageTemplateActivity; import com.pspdfkit.configuration.activity.PdfActivityConfiguration; import com.pspdfkit.ui.PdfActivityIntentBuilder; public class CustomPageTemplatesExample extends SdkExample { public CustomPageTemplatesExample(Context context) { super( context.getString(R.string.customPageTemplateExampleTitle), context.getString(R.string.customPageTemplateExampleDescription)); } @Override public void launchExample( @NonNull final Context context, @NonNull final PdfActivityConfiguration.Builder configuration) { // Extract the document from the assets. extract(ANNOTATIONS_EXAMPLE, getTitle(), context, documentFile -> { // To start the example create a launch intent using the builder. final Intent intent = PdfActivityIntentBuilder.fromUri(context, Uri.fromFile(documentFile)) .configuration(configuration.build()) .activityClass(CustomPageTemplateActivity.class) .build(); context.startActivity(intent); }); } } ```