Utilizing internal PDF links in a Microsoft UWP application

In the process of developing a UWP app using javascript, I have created a list of links that are connected to PDF files stored locally in the app. The ultimate goal is to offer a collection of hands-free documentation for the Hololens (Windows AR) device. To open the PDFs within the app, I use the following code:

Windows.System.Launcher.launchFileAsync(file)

Everything functions seamlessly as intended. However, a challenge arises with the hyperlinks contained within the PDF files which reference each other. While I can adjust these hyperlinks during the initial PDF generation, ensuring they still link to one another when opened in the user's default PDF application presents a dilemma. It should be noted that the default PDF application may vary between users, similar to how Adobe Acrobat works on Windows.

Below is the current working code snippet:

window.onload = function () {
    document.getElementById("#id").onclick = function (evt) {
        pdfopen("pdf.pdf")
    }

function pdfopen(pdf) {

var imageFile = "assets\\" + pdf;

// Retrieve the PDF file from the app's directory
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(imageFile).then(
  function (file) {
      // Launch the retrieved file using the default app

      var options = new Windows.System.LauncherOptions();
      Windows.System.Launcher.launchFileAsync(file)
  }
);

Any assistance in solving this hyperlink referencing issue would be greatly appreciated! <3

Answer №1

Is there a way to ensure that hyperlinks still work properly when opened in the user's default PDF app?

By using the `launchFileAsync` method without specifying `LauncherOptions`, it will always open PDF files with the default app.

If you want to specify a particular app to open PDF files, you can utilize the `LauncherOptions.TargetApplicationPackageFamilyName` property to set the package family name of the desired app. Then include these options when calling the `LaunchFileAsync(IStorageFile, LauncherOptions)` method to open the file with the specified app.

For example, to use Microsoft Edge as the default app for opening PDF files:

var options = new Windows.System.LauncherOptions();
options.TargetApplicationPackageFamilyName = "Microsoft.MicrosoftEdge_8wekyb3d8bbwe";
Windows.System.Launcher.launchFileAsync(file, options).then(
  function(success) {
    if (success)
    {
        // File launched successfully
    }
    else
    {
        // Failed to launch file
    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for utilizing JSON.parse

Within my ajax request, I am encountering the following code: 403: function(jqXHR) { var error = jqXHR.responseText; console.log(error); } When this error occurs, a message is displayed in the console: Htt ...

How to Implement Button Disable Feature in jQuery When No Checkboxes Are Selected

I need help troubleshooting an issue with a disabled button when selecting checkboxes. The multicheck functionality works fine, but if I select all items and then deselect one of them, the button disables again. Can someone assist me with this problem? Be ...

Creating a series of image files from CSS and Javascript animations using Selenium in Python

Looking to convert custom CSS3/Javascript animations into PNG files on the server side and then combine them into a single video file? I found an interesting solution using PhantomJS here. As I am not very familiar with Selenium, adapting it for use with S ...

jQuery.ajax Failure Response

When using MVC on the server side and calling a function with jQuery.Ajax that returns JSON, an exception is being thrown. How can I invoke the error handling function of Ajax by sending something back in the return JSON function? MVC Function public Jso ...

Issue: Invalid element type - Error message displayed when attempting to show the Edit button

I am currently learning about React and trying to implement an edit button next to the rows for editing data in the database. However, I keep encountering this specific error message: Error: Element type is invalid: expected a string (for built-in compone ...

Eradicate white space in a JavaScript code

Calling all JS programmers! Here's a challenge for you, check out this demo: https://codepen.io/gschier/pen/jkivt I'm looking to tweak 'The pen is simple.' to be 'The pen issimple.' by removing the extra space after 'is& ...

Learn how to display a tooltip for every individual point on a Highcharts network graph within an Angular

I am currently working on developing network graphs using highcharts and highcharts-angular within my Angular application. I have successfully managed to display the graph with datalabels, but now I need to implement tooltips for each point or node on the ...

After exporting static HTML, the links in Next.JS seem to become unresponsive

Exploring the world of NEXT.JS for the first time and encountering challenges with deploying a static site. In my component Nav.tsx, I have the following structure: const Nav = () => { return ( <nav className='nav p-3 border-bottom&a ...

Incorporate Calendly Script into your NextJs application

I'm currently working on integrating Calendly into my Next.js project. However, I am unsure about the process. My goal is to embed it on a specific page rather than in _app or _document. Here is what I have attempted so far: import Script from &apos ...

Is NodeJS Asynchronous: Has the callback been called twice?

I'm currently working with the Async module in Node.JS to manage my asynchronous calls. However, I've encountered an issue stating "Callback already called." Could someone assist me with resolving this problem? async.each(data['results&apos ...

Searching and selecting columns in React using Material-UI

Currently, I am using Material-UI data tables and have implemented a search functionality similar to this Codesandbox example, which only searches the Name/Food column. This is my existing code snippet: const [filterFn, setFilterFn] = useState({ fn: items ...

Uh-oh! Trouble loading web app dependencies: 404 Error

Currently, I have a functional SailsJS boilerplate application. The next step I am trying to undertake involves integrating Angular-Material as a dependency in order to kickstart some UI development tasks. However... After installing angular-material usin ...

Steps for deactivating AMD on four files and sequentially loading them using webpack

I am facing an issue where I need to disable AMD on 4 files and ensure that video.js is loaded before the other 3 files, as they are dependent on it. My attempt to achieve this in webpack.config.js was unsuccessful: const path = require('path') ...

Why am I encountering a type error in NodeJS when utilizing the ping module?

I'm currently working on creating a simple app for pinging an IP address. The HTML form I've created has one input field for the IP address, which is then sent to NodeJS for processing. I am utilizing the ping module to retrieve the results. Ever ...

Is it possible to use JavaScript for detecting third-party videos?

I'm currently developing an HTML5 video player that also has a fallback to flash. One of the challenges I am facing is that the video content is being provided by various third-party sources. It seems that some of these third parties serve videos bas ...

"Implementing interactive arrow buttons in a horizontal navigation bar using HTML, CSS, and JavaScript

Seeking advice on creating a horizontal navigation bar with arrow buttons at the sides, such as the one shown below. Despite extensive research, I have not found the exact solution I am looking for. This will be implemented in my Vue.js project. |<| P ...

Creating a comparison display using ng-repeat

I have a JSON file that contains revision and history information about a modified entity, including its old and new values. The diff is generated using the jsondiffpatch library and I have parsed it further to create the final JSON format for rendering. ...

Various settings in JQuery UI Slider

Does anyone know how to customize the steps in a jQuery UI slider? I want to set specific values as steps, like 0, 1200, 2000, 2200, and 3000. Any suggestions on how to achieve this? const rangeSliderInit = () => { const valueArray = [0, 400, 1000, 1 ...

The JQxTreeGrid is displaying properly, however, it is not loading the data from the JSON source

Looking for some assistance with loading Json data into a Jquery grid using jqxTreegrid. Currently, the grid is displaying but not the data. Despite no errors in the debugger, I'm unable to figure out the issue. Any help resolving this matter would be ...

Verify if the property in every element of the array is not empty

How can you determine if all employees have a non-null value for the SSN property in the given object? Employees: { id: 0, name: "John", SSN: "1234" } { id: 1, name: "Mark", SSN: "1876" } { id: 2, name: "Sue&q ...