question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate PDF button on a local json file does nothing

See original GitHub issue

When I click the Generate PDF button:

Screenshot from 2020-04-01 16-27-42

nothing happens. My issue is not the same as described in https://github.com/mrin9/RapiPdf/issues/5, in that issue the user describes a tab opening for a second and then closing, in my case nothing happens. Also the demo website https://mrin9.github.io/RapiPdf/ works great with the Swagger pet store example link https://mrin9.github.io/RapiPdf/specs/petstore.json.

Here is what I have done so far:

Clone RapiPdf to my home directory:

cd ~
git clone https://github.com/mrin9/RapiPdf.git

Based on the bottom of the readme I’m doing to build steps:

cd ~/RapiPdf
yarn install
yarn build
yarn serve

In the root directory of RapiPdf there is already a file named index.html, so I made a file index2.html:

cd ~/RapiPdf
touch index2.html

Then I copy/pasted in this text from the RapiPdf website:

<!doctype html>
  <html>
  <head>
    <script src="https://unpkg.com/rapipdf/dist/rapipdf-min.js"></script>
  </head>
  <body>
    <rapi-pdf
      style = "width:700px; height:40px; font-size:18px;" 
      spec-url = "https://mrin9.github.io/RapiPdf/examples/specs/petstore.json"
      button-bg = "#b44646" 
    > </rapi-pdf>
  </body> 
  </html>

Then I copied a file named MyApi.json into the ~/RapiPdf directory. This file contains the Swagger 2.0 pet store example so I’m 100% sure it’s valid.

Next I edited the spec-url = "https://mrin9.github.io/RapiPdf/examples/specs/petstore.json" line in index2.html to be: spec-url = "../MyApi.json"

Please note that MyApi.json and index2.html are both located in the ~/RapiPdf/ directory. Next I double-clicked index2.html to open it in Chrome, see the screenshot at the beginning of this post. If I press the Generate PDF button nothing happens. No error message, no pop-up blocker warning, no momentary tab opening and then closing.

I’ve tried it with and without the yarn serve command above running. In the text box I’ve tried:

../MyApi.json
/home/cdahms/RapiPdf/MyApi.json
file://home/cdahms/RapiPdf/MyApi.json
file:///home/cdahms/RapiPdf/MyApi.json

In Chrome I went to: Chrome -> dot dot dot button -> Settings -> Privacy and security -> Pop-ups and redirects and added file:///home/cdahms/RapiPdf/index2.html

I also tried opening index2.html in FireFox, same result.

Suggestions ??

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrin9commented, Apr 5, 2020

I can see there are about 12 errors in the screenshot, but not sure what are they. However I think its because we are trying to load a local file instead of loading from a http server. (There are some know issues when we try to load the spec file from a local system instead of an http server)

can you try to expose the folder ~/temp that you created through a web-server For a quick test I normally use http-server

in the command line, from the ~/temp folder run the below command

npx http-server 

and navigate to localhost:8080 in your browser

let me know if it worked

PS: Can you also tell me which OS are you using ?

1reaction
mrin9commented, Apr 2, 2020

yes they both have. However there is a bug though, the JSON cannot contain $refs in it

RapiPDF: generatePdf(spec) https://mrin9.github.io/RapiPdf/api.html#methods RapiDoc : loadSpec https://mrin9.github.io/RapiDoc/api.html#methods

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript/JS not working on button click to generate pdf file
I have used jspdf plugin to save the div named #main to pdf, have watched a youtube video of this code working for...
Read more >
How to create a button that submits a form and downloads a ...
Firstly, create the form with attribute onsubmit set to 'return: false;', which actually prevents the form from submitting on clicking the ...
Read more >
pdf2json - npm
PDF file parser that converts PDF binaries to text based JSON, powered by porting a fork of PDF.JS to Node.js. Latest version: 3.0.2, ......
Read more >
A beginner's guide to JSON, the data format for the internet
Currently, you can get equivalent functionality by exporting a JavaScript Object the same as your desired JSON from a JavaScript file. export ......
Read more >
PowerApps Download file button? - Power Platform Community
Solved: Is it possible to have a download button in the powerapps? ... Download returns the location where the file was stored locally...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found