The functionality of generating PDF files using jsPDF is not supported on mobile devices such as Android and

Is it possible to create PDFs using jspdf on mobile phones and tablets? I have a basic android application (without Phonegap or Cordova) and an IOS application. While jspdf functions smoothly on web browsers, I am unable to generate PDFs on both IOS and Android.

doc.output('save', 'Pass.pdf');

This code works well for web browsers. However, when I tried:

doc.save();

and

 var blob = pdf.output();
 window.open(URL.createObjectURL(blob));

and when I attempted :

 var res = doc.output(); 
 var blob = new Blob([res]);
 window.open(URL.createObjectURL(blob));

I received something like this on the android device:

onLoadResource=data:application/pdf;base64,JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovTWVkaWFCb3ggWzAgMCA1OTUuMjggODQxLjg5XQovQ29udGVudHM......

but no actual PDF file was generated.

Now I am wondering if it is actually feasible to create PDFs on mobile devices using jspdf, or if my efforts are futile.

If so, how can it be achieved?

Answer №1

When it comes to IOS: According to Google's advice: If you want to download PDFs on your iPad, iPhone, or iPod Touch, you'll have to install a specific application.

Since doing so directly from jspdf wasn't an option, I decided to stop pursuing that route.

As for Android: I couldn't find a solution for that particular issue, so I had to explore other alternatives.

Consider using images instead of PDF files (for both iOS and Android)

If you need to display information in a PDF format, consider encoding it as base64, sending it to an Android API, converting it to a PNG file, and saving it to the photo gallery.

This workaround might be useful for someone facing similar challenges in the future.

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

Developing an iOS arm64 application integrated with a 32-bit third-party library

On February 1, 2015 Apple required projects to have support for both 64 and 32 bit systems. However, the third party library we use does not have support for arm64 slice. Is there a way to add an exception for the 32 bit library in order to build the proje ...

Extract the email address from the HTML source code obtained through a GET AJAX request

An interesting scenario arises when the following code is executed from www.example.com. It fetches the complete html source code of www.example.com/example.html and displays it in an alert message. function process(){ url = "http://www.example.com/ex ...

What is the best way to integrate Google Analytics into a Next.js application without the need for an _app.js or _document.js file?

I'm encountering some challenges while trying to incorporate Google Analytics into my Next.js application. One issue I'm facing is the absence of an _app.js or _document.js file in the project structure. Additionally, I notice that when I include ...

Change the height and width of the UIView in the storyboard

I have been working on developing a reusable component for my app. The main purpose behind this is for educational reasons. Despite my attempts to set constraints programmatically, the Interface Builder keeps adding automatic constraints: <NSIBPrototy ...

Launching a fresh tab or window using POST [PHP]

This is the scenario: In my project, I have two essential files - reportCaller.php and report.php. The user's interaction starts from reportCaller.php where they will click a button with an "onclick" method to trigger a function that deals with ajax/p ...

JavaScript: The power of nested array manipulation

I'm having trouble extracting data from a parsed JSON array obtained from a shipping company. Specifically, I am attempting to retrieve the short_name of Cleveland, OH, but all my attempts to access this information have been unsuccessful. When I use: ...

redux form has encountered an error: the element type provided is not valid, a string is expected for built-in components

While working on my stepper code, I attempted to add a radio button. However, this addition resulted in the following error. I referenced this example before implementing it. Despite that, I am still encountering errors. Could you please advise me on how ...

Tips for ensuring your webpage stays current with regular updates through JavaScript

This webpage acts as a dynamic newsboard, constantly updated with the latest data from my Database through an API, all without requiring a page refresh. While the timer solution seemed simple, I am seeking a more resource-efficient approach. I have resear ...

Requesting a resource using the HTTP GET method returned no data

Looking to process the response from an http-request using JavaScript? Check out this straightforward example below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html x ...

Troubleshooting: Configuring dynamic minimum time for <input type='time'> in AngularJS not functioning as expected

Can someone help me with setting the minimum time dynamically to the current time? For some reason, it's not working and I'm not getting any error messages. Where did I make a mistake? $scope.mintime = new Date(); <label class="item item-in ...

Ascending to the Peak within a div

<script type="text/javascript"> $(document).ready(function(){ updateContent(); }); function updateContent(){ $('#mainDiv').load('home.php', function(){ scrollToTop(); }); } ...

Looking for the time trigger feature in jQuery using typeahead search?

Is there a way to trigger an event every 3 seconds in Laravel Vue.js? I am currently using jQuery in my script. The issue is that when I type something in the search input field, the event is triggered after each character I type. What I want is for the ev ...

iPhone allocation (currently no profiles meet the criteria) Insanity

As a novice iOS developer, I have been working on developing apps for about a year now. Recently, my yearly certificate expired which led me to delete all provision profiles from Xcode and certificates and keys from the keychain on my MacBook. After follow ...

After removing an item from my shopping cart and adding a new one, the cleared item reappears in my cart

I encountered an issue with my shopping cart code. Whenever I click the clear button and then add a new item, the previously cleared item reappears. Despite attempting to adjust the saveCart function's placement, the problem persists without any reso ...

Embed the Three.js CSS3DRenderer scene within a designated div element

I am interested in using the Three.js CSS3DRenderer to create a three-dimensional composition. Here is the code I have: "use strict"; var OrbitControls = THREE.OrbitControls, CSS3DRenderer = THREE.CSS3DRenderer, CSS3DObject = THREE.CSS3DObject, S ...

Use the button to trigger the opening of the datepicker in React material UI

Currently, I am incorporating a Datepicker in my project using React Material UI. <TextField id="datetime-local" label="Next appointment" type="datetime-local" defaultValue="2017-05-24T ...

Drop Down Automation with Selenium IDE

Currently in the process of automating a User Acceptance Testing (UAT) for a software project at my company. I've completed all the typical tasks like recording actions and clicking on buttons, but ran into an issue with a drop-down menu. The problem ...

Trigger refetchQueries post-execution of a mutation operation

In the past, I executed a mutation in a similar manner as shown below: export const useEditLocationName = () => { const [editFavoriteLocationName] = useEditFavoriteLocationNameMutation({ refetchQueries: [{ query: GetMyFavouritePlacesDocument}], ...

The Jquery append() method seems to be having issues specifically in the Internet Explorer

I am a jQuery 1.10.2 version with the task of inserting an XML node at a specific location within an existing XML structure. To achieve this, I am utilizing the jQuery `append()` function successfully in Chrome, Firefox, and IE Edge; however, it is encount ...

Is it possible to run a test application on an Android phone using the command line

I'm experiencing slow performance with Android Studio on my laptop, so I'm considering using it solely for building the app structure and switching to Sublime Text 3 for coding. However, I still want to be able to test my app on my phone connecte ...