Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could I download pdf with arx? #81

Closed
Freakwill opened this issue Jan 8, 2021 · 2 comments
Closed

Could I download pdf with arx? #81

Freakwill opened this issue Jan 8, 2021 · 2 comments
Labels
feature Propose a new feature or request

Comments

@Freakwill
Copy link

Freakwill commented Jan 8, 2021

Could I download pdf with arx? Is there a user-friendly API to do it?

@Freakwill Freakwill added the feature Propose a new feature or request label Jan 8, 2021
@eonu
Copy link
Owner

eonu commented Jan 15, 2021

Hi!

There isn't really an inbuilt feature like this, but you can do it quite easily by:

  1. checking if the paper has a PDF field with .pdf?,
  2. using open-uri to download the paper from its .pdf_url.
require 'open-uri'
require 'arx'

paper = Arx('1809.09415')

if paper.pdf?
  File.open('paper.pdf', 'wb') do |f|
    f.write URI.open(paper.pdf_url).read
  end
end

I'll look into adding this feature directly into the API at some point though, thanks for the suggestion!

@eonu
Copy link
Owner

eonu commented Jan 26, 2021

Implemented in #90, you can now use Arx::Paper#save(path) to save the PDF for a paper object.

@eonu eonu closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Propose a new feature or request
Projects
None yet
Development

No branches or pull requests

2 participants