├── .generator-revision ├── .openapi-generator ├── VERSION └── FILES ├── .generator-language-identifier ├── .rspec ├── script ├── clean ├── console ├── swagger ├── inside_container │ ├── README.md │ └── test ├── release ├── post_generate_language ├── fix_gemspec.rb ├── setup ├── update_from_upstream ├── docker ├── test └── generate_language ├── .docker_env.list ├── Gemfile ├── Rakefile ├── .docker_mounts.list ├── .travis.yml ├── lib ├── docraptor │ ├── version.rb │ ├── api_error.rb │ ├── models │ │ ├── async_doc.rb │ │ ├── doc_status.rb │ │ └── doc.rb │ ├── configuration.rb │ └── api_client.rb └── docraptor.rb ├── .review ├── generated_files │ ├── docs │ │ ├── AsyncDoc.md │ │ ├── DocStatus.md │ │ ├── Doc.md │ │ ├── PrinceOptions.md │ │ └── DocApi.md │ ├── .gitignore │ ├── spec │ │ ├── models │ │ │ ├── async_doc_spec.rb │ │ │ ├── doc_status_spec.rb │ │ │ ├── doc_spec.rb │ │ │ └── prince_options_spec.rb │ │ ├── configuration_spec.rb │ │ ├── api │ │ │ └── doc_api_spec.rb │ │ ├── spec_helper.rb │ │ └── api_client_spec.rb │ └── README.md └── README.md ├── test ├── invalid_sync.rb ├── invalid_async.rb ├── sync.rb ├── hosted_sync.rb ├── async.rb ├── xlsx.rb ├── hosted_async.rb ├── iframes_false.rb ├── iframes_true.rb ├── iframes_default.rb ├── expire_hosted.rb └── prince_options.rb ├── .github └── pull_request_template.txt ├── .runtime-environments ├── .gitlab-ci.yml ├── generator-config.json ├── LICENSE ├── docraptor.gemspec ├── .gitignore ├── examples ├── sync.rb ├── async.rb ├── hosted_sync.rb └── hosted_async.rb ├── .openapi-generator-ignore ├── gemfiles ├── Gemfile.2.5.lock ├── Gemfile.2.6.lock ├── Gemfile.2.7.lock ├── Gemfile.3.0.lock ├── Gemfile.3.1.lock ├── Gemfile.3.2.lock └── Gemfile.3.3.lock ├── CHANGELOG.md ├── README.md ├── .rubocop.yml └── docraptor.yaml /.generator-revision: -------------------------------------------------------------------------------- 1 | v6.6.0 2 | -------------------------------------------------------------------------------- /.openapi-generator/VERSION: -------------------------------------------------------------------------------- 1 | 6.6.0 -------------------------------------------------------------------------------- /.generator-language-identifier: -------------------------------------------------------------------------------- 1 | ruby 2 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --require spec_helper 3 | -------------------------------------------------------------------------------- /script/clean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$0")/.." 4 | 5 | rm -rf lib/ 6 | -------------------------------------------------------------------------------- /script/console: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$0")/.." 4 | 5 | script/docker "$@" /bin/bash 6 | -------------------------------------------------------------------------------- /.docker_env.list: -------------------------------------------------------------------------------- 1 | TRACE 2 | TEST_OUTPUT_DIR=/app/tmp/test_output 3 | BUNDLE_PATH=/app/tmp/cache/bundle 4 | INSIDE_DOCKER=true 5 | SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :development, :test do 6 | gem 'rake', '~> 13.0.1' 7 | gem 'pry-byebug' 8 | gem 'rubocop', '~> 0.66.0' 9 | end 10 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | begin 4 | require 'rspec/core/rake_task' 5 | 6 | RSpec::Core::RakeTask.new(:spec) 7 | task default: :spec 8 | rescue LoadError 9 | # no rspec available 10 | end 11 | -------------------------------------------------------------------------------- /.docker_mounts.list: -------------------------------------------------------------------------------- 1 | # Specify mounts in `docker run --volume` format (source:target). Bash 2 | # expressions will be evaluated. 3 | $(pwd)/tmp/cache_${image//:/_}:/app/tmp/cache 4 | /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | cache: bundler 3 | rvm: 4 | - 2.7 5 | - 3.0 6 | - 3.1 7 | script: 8 | - bundle install --path vendor/bundle 9 | - bundle exec rspec 10 | - gem build docraptor.gemspec 11 | - gem install ./docraptor-3.1.0.gem 12 | -------------------------------------------------------------------------------- /lib/docraptor/version.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | module DocRaptor 14 | VERSION = '3.1.0' 15 | end 16 | -------------------------------------------------------------------------------- /script/swagger: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$0")/.." 4 | 5 | set -x 6 | 7 | GENERATOR_REVISION=$(cat .generator-revision 2> /dev/null || true) 8 | if [ "$GENERATOR_REVISION" = "" ]; then 9 | echo "Set a revision of openapi-generator to use in .generator-revision" 10 | exit 1 11 | fi 12 | 13 | docker run -it -w "/local" --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:"${GENERATOR_REVISION}" "$@" 14 | -------------------------------------------------------------------------------- /script/inside_container/README.md: -------------------------------------------------------------------------------- 1 | This folder contains scripts that are only intended to be run inside 2 | of a relevant docker container. For example, `script/test` may run 3 | `script/inside_container/test` inside a container with particular 4 | versions of libraries to make it easy to test the agent in multiple 5 | settings. It's possible these scripts will work outside of any 6 | particular container, but that may or may not mean anything. 7 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | [[ "$TRACE" == "true" ]] && set -x 4 | cd "$(dirname "$0")/.." 5 | 6 | 7 | if [[ "$INSIDE_DOCKER" != "true" ]]; then 8 | git config --local user.email "$(git config --get user.email)" 9 | exec script/docker "/app/script/$(basename "$0")" 10 | fi 11 | 12 | public_remote="$(git remote -v | grep -i 'git@github.com:DocRaptor/docraptor-ruby.git' | head -n 1 | cut -f1)" 13 | rake "release[${public_remote}]" 14 | -------------------------------------------------------------------------------- /.review/generated_files/docs/AsyncDoc.md: -------------------------------------------------------------------------------- 1 | # DocRaptor::AsyncDoc 2 | 3 | ## Properties 4 | 5 | | Name | Type | Description | Notes | 6 | | ---- | ---- | ----------- | ----- | 7 | | **status_id** | **String** | The identifier used to get the status of the document using the status API. | [optional] | 8 | 9 | ## Example 10 | 11 | ```ruby 12 | require 'docraptor' 13 | 14 | instance = DocRaptor::AsyncDoc.new( 15 | status_id: null 16 | ) 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /script/post_generate_language: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | [[ "$TRACE" == "true" ]] && set -x 4 | cd "$(dirname "$0")/.." 5 | 6 | echo "Removing trailing whitespace..." 7 | find lib -name "*.rb" -type f -exec sed -E -i '' 's/[[:space:]]+$//g' {} + 8 | 9 | echo "Fixing gemspec to work around swagger..." 10 | ruby script/fix_gemspec.rb 11 | 12 | if compgen -G "patches/*.patch" > /dev/null; then 13 | echo "Apply patches to generated code" 14 | git apply --verbose patches/*.patch 15 | fi 16 | -------------------------------------------------------------------------------- /test/invalid_sync.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | begin 12 | $docraptor.create_doc( 13 | test: true, 14 | name: "s" * 201, # limit is 200 characters 15 | document_type: "pdf", 16 | ) 17 | rescue DocRaptor::ApiError 18 | exit 19 | end 20 | 21 | abort "Exception expected, but not raised" 22 | -------------------------------------------------------------------------------- /.github/pull_request_template.txt: -------------------------------------------------------------------------------- 1 | Why is this change needed? 2 | -------------------------- 3 | 4 | How does it address the issue? 5 | ------------------------------ 6 | 7 | Any links to any relevant tickets, articles, or other resources? 8 | --------------------------------------------------------------- 9 | 10 | Any screenshots? 11 | ---------------- 12 | 13 | Did you complete all of the following? 14 | -------------------------------------- 15 | - Run test suite? 16 | - Add new tests? 17 | - Consider security implications and practices? 18 | -------------------------------------------------------------------------------- /.runtime-environments: -------------------------------------------------------------------------------- 1 | # Versions without patch numbers will test the latest patch version. We include 2 | # specific patch versions to provide consistency. We include version numbers 3 | # without the patch version in order to automatically test the latest patch 4 | # version of each minor version. 5 | # DR gem itself requires >= 2.4, so 2.3 is out 6 | # 2.4: /app/lib/docraptor/models/async_doc.rb:111:in `build_from_hash': undefined method `transform_keys' 7 | ruby:2.5 8 | ruby:2.6 9 | ruby:2.7 10 | ruby:3.0 11 | ruby:3.1 12 | ruby:3.2 13 | ruby:3.3-rc 14 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | .ruby: &ruby 2 | variables: 3 | LANG: "C.UTF-8" 4 | before_script: 5 | - ruby -v 6 | - bundle config set --local deployment true 7 | - bundle install -j $(nproc) 8 | parallel: 9 | matrix: 10 | - RUBY_VERSION: ['2.7', '3.0', '3.1'] 11 | image: "ruby:$RUBY_VERSION" 12 | cache: 13 | paths: 14 | - vendor/ruby 15 | key: 'ruby-$RUBY_VERSION' 16 | 17 | gem: 18 | extends: .ruby 19 | script: 20 | - bundle exec rspec 21 | - bundle exec rake build 22 | - bundle exec rake install 23 | artifacts: 24 | paths: 25 | - pkg/*.gem 26 | 27 | -------------------------------------------------------------------------------- /generator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "gemName": "docraptor", 3 | "moduleName": "DocRaptor", 4 | "gemVersion": "3.1.0", 5 | "gemAuthor": "Expected Behavior", 6 | "gemAuthorEmail": "support@docraptor.com", 7 | "gemHomepage": "https://github.com/docraptor/docraptor-ruby", 8 | "gemSummary": "A wrapper for the DocRaptor HTML to PDF/XLS service.", 9 | "gemDescription": "A native client library for the DocRaptor HTML to PDF/XLS service.", 10 | "gemLicense": "MIT", 11 | "hideGenerationTimestamp": true, 12 | "httpUserAgent": "ruby-swagger-#{VERSION}", 13 | "gemRequiredRubyVersion": ">= 2.5" 14 | } 15 | -------------------------------------------------------------------------------- /test/invalid_async.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | create_response = $docraptor.create_async_doc( 12 | test: true, 13 | document_content: "
Hello from Ruby", 14 | name: "s" * 201, # limit is 200 characters 15 | document_type: "pdf", 16 | ) 17 | 18 | status_response = nil 19 | 30.times do 20 | status_response = $docraptor.get_async_doc_status(create_response.status_id) 21 | exit if status_response.status == "failed" 22 | sleep 1 23 | end 24 | 25 | abort "Did not receive failed validation within 30 seconds." 26 | -------------------------------------------------------------------------------- /.review/README.md: -------------------------------------------------------------------------------- 1 | # Review newly generated files 2 | 3 | This directory helps with review of generated files where we lagely want 4 | the content to be custom. 5 | 6 | The project `README.md` is a good example. We heavily custimize 7 | `README.md` based on our particular use case. There are also important 8 | changes to the generated `README.md` that should be reviewed when it is 9 | updated. These include things like new minimum language versions, or 10 | client API changes. 11 | 12 | If you add the `README.md` to the `.openapi-generator-ignore` list then 13 | you never see the updates, making it easy to miss things. If you don't 14 | add it to the `.openapi-generator-ignore` list then any uncommitted 15 | updates to the `README.md` are lost when running 16 | `script/generate_language`. 17 | -------------------------------------------------------------------------------- /test/sync.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 12 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 13 | 14 | output_payload = $docraptor.create_doc( 15 | test: true, 16 | document_content: "Hello from Ruby", 17 | name: output_file, 18 | document_type: "pdf", 19 | ) 20 | 21 | File.write(output_file, output_payload) 22 | output_type = `file -b #{output_file}` 23 | 24 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 25 | -------------------------------------------------------------------------------- /.openapi-generator/FILES: -------------------------------------------------------------------------------- 1 | .gitignore 2 | .gitlab-ci.yml 3 | .rspec 4 | .rubocop.yml 5 | .travis.yml 6 | Gemfile 7 | README.md 8 | Rakefile 9 | docraptor.gemspec 10 | docs/AsyncDoc.md 11 | docs/Doc.md 12 | docs/DocApi.md 13 | docs/DocStatus.md 14 | docs/PrinceOptions.md 15 | lib/docraptor.rb 16 | lib/docraptor/api/doc_api.rb 17 | lib/docraptor/api_client.rb 18 | lib/docraptor/api_error.rb 19 | lib/docraptor/configuration.rb 20 | lib/docraptor/models/async_doc.rb 21 | lib/docraptor/models/doc.rb 22 | lib/docraptor/models/doc_status.rb 23 | lib/docraptor/models/prince_options.rb 24 | lib/docraptor/version.rb 25 | spec/api/doc_api_spec.rb 26 | spec/api_client_spec.rb 27 | spec/configuration_spec.rb 28 | spec/models/async_doc_spec.rb 29 | spec/models/doc_spec.rb 30 | spec/models/doc_status_spec.rb 31 | spec/models/prince_options_spec.rb 32 | spec/spec_helper.rb 33 | -------------------------------------------------------------------------------- /.review/generated_files/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by: https://openapi-generator.tech 2 | # 3 | 4 | *.gem 5 | *.rbc 6 | /.config 7 | /coverage/ 8 | /InstalledFiles 9 | /pkg/ 10 | /spec/reports/ 11 | /spec/examples.txt 12 | /test/tmp/ 13 | /test/version_tmp/ 14 | /tmp/ 15 | 16 | ## Specific to RubyMotion: 17 | .dat* 18 | .repl_history 19 | build/ 20 | 21 | ## Documentation cache and generated files: 22 | /.yardoc/ 23 | /_yardoc/ 24 | /doc/ 25 | /rdoc/ 26 | 27 | ## Environment normalization: 28 | /.bundle/ 29 | /vendor/bundle 30 | /lib/bundler/man/ 31 | 32 | # for a library or gem, you might want to ignore these files since the code is 33 | # intended to run in multiple environments; otherwise, check them in: 34 | # Gemfile.lock 35 | # .ruby-version 36 | # .ruby-gemset 37 | 38 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 39 | .rvmrc 40 | -------------------------------------------------------------------------------- /test/hosted_sync.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | require "open-uri" 4 | 5 | DocRaptor.configure do |dr| 6 | dr.username = "YOUR_API_KEY_HERE" 7 | # dr.debugging = true 8 | end 9 | 10 | $docraptor = DocRaptor::DocApi.new 11 | 12 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 13 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 14 | 15 | output_payload = $docraptor.create_hosted_doc( 16 | test: true, 17 | document_content: "Hello from Ruby", 18 | name: output_file, 19 | document_type: "pdf", 20 | hosted_expires_at: (Time.now + 86400).strftime('%FT%T%:z'), # 1 day from now 21 | ) 22 | 23 | actual_document = URI.parse(output_payload.download_url).open 24 | IO.copy_stream(actual_document, output_file) 25 | 26 | output_type = `file -b #{output_file}` 27 | 28 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 29 | -------------------------------------------------------------------------------- /.review/generated_files/spec/models/async_doc_spec.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | require 'spec_helper' 14 | require 'json' 15 | require 'date' 16 | 17 | # Unit tests for DocRaptor::AsyncDoc 18 | # Automatically generated by openapi-generator (https://openapi-generator.tech) 19 | # Please update as you see appropriate 20 | describe DocRaptor::AsyncDoc do 21 | let(:instance) { DocRaptor::AsyncDoc.new } 22 | 23 | describe 'test an instance of AsyncDoc' do 24 | it 'should create an instance of AsyncDoc' do 25 | expect(instance).to be_instance_of(DocRaptor::AsyncDoc) 26 | end 27 | end 28 | describe 'test attribute "status_id"' do 29 | it 'should work' do 30 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 31 | end 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2010-2017 Expected Behavior 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /.review/generated_files/docs/DocStatus.md: -------------------------------------------------------------------------------- 1 | # DocRaptor::DocStatus 2 | 3 | ## Properties 4 | 5 | | Name | Type | Description | Notes | 6 | | ---- | ---- | ----------- | ----- | 7 | | **status** | **String** | The present status of the document. Can be queued, working, completed, and failed. | [optional] | 8 | | **download_url** | **String** | The URL where the document can be retrieved. This URL may only be used a few times. | [optional] | 9 | | **download_id** | **String** | The identifier for downloading the document with the download API. | [optional] | 10 | | **message** | **String** | Additional information. | [optional] | 11 | | **number_of_pages** | **Integer** | Number of PDF pages in document. | [optional] | 12 | | **validation_errors** | **String** | Error information. | [optional] | 13 | 14 | ## Example 15 | 16 | ```ruby 17 | require 'docraptor' 18 | 19 | instance = DocRaptor::DocStatus.new( 20 | status: null, 21 | download_url: null, 22 | download_id: null, 23 | message: null, 24 | number_of_pages: null, 25 | validation_errors: null 26 | ) 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /test/async.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 12 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 13 | 14 | create_response = $docraptor.create_async_doc( 15 | test: true, 16 | document_content: "Hello from Ruby", 17 | name: output_file, 18 | document_type: "pdf", 19 | ) 20 | 21 | status_response = nil 22 | 30.times do 23 | status_response = $docraptor.get_async_doc_status(create_response.status_id) 24 | break if status_response.status == "completed" 25 | sleep 1 26 | end 27 | 28 | output_payload = $docraptor.get_async_doc(status_response.download_id) 29 | 30 | File.write(output_file, output_payload) 31 | output_type = `file -b #{output_file}` 32 | 33 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 34 | 35 | -------------------------------------------------------------------------------- /script/fix_gemspec.rb: -------------------------------------------------------------------------------- 1 | # These, at least the first two, significantly increase speed of a test run by 2 | # limiting the filesystem interaction that occurs with bundler installing and 3 | # requiring files. 4 | bad_files = %q{s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }} 5 | good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select { |f| !f.empty? }} 6 | bad_test_files = %q{s.test_files = `find spec/*`.split("\n")} 7 | good_test_files = %q{s.test_files = `git ls-files spec test`.split("\n")} 8 | 9 | filename = "docraptor.gemspec" 10 | content = File.read(filename) 11 | [ 12 | bad_files, 13 | bad_test_files, 14 | ].each do |bad_content_to_check| 15 | unless content.include?(bad_content_to_check) 16 | raise "Couldn't find content in docraptor.gemspec. Check matchers in there for: “#{bad_content_to_check}”" 17 | end 18 | end 19 | updated_content = content.dup 20 | updated_content.sub!(bad_files, good_files) 21 | updated_content.sub!(bad_test_files, good_test_files) 22 | 23 | File.open(filename, "w") do |file| 24 | file.write(updated_content) 25 | end 26 | -------------------------------------------------------------------------------- /script/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$0")/.." 4 | 5 | setup_echo() { 6 | echo "[script/setup] $1" 7 | } 8 | 9 | setup_error() { 10 | echo "[script/setup][ERROR] $1" 11 | } 12 | 13 | brew_install() { 14 | setup_echo "Installing $1..." 15 | brew list --formula "$1" > /dev/null || brew install --formula "$1" 16 | } 17 | 18 | brew_cask_install() { 19 | setup_echo "Installing cask $1..." 20 | brew list --cask "$1" &> /dev/null || brew install --cask "$1" 21 | } 22 | 23 | brew_cask_install docker 24 | brew_install docker 25 | 26 | # Avoid a warning message (vs. --overwrite) 27 | brew unlink docker && brew link docker 28 | 29 | tput bold # bold text 30 | tput setaf 2 # green text 31 | setup_echo "****************************************************************" 32 | setup_echo "* *" 33 | setup_echo "* Good to go! *" 34 | setup_echo "* *" 35 | setup_echo "****************************************************************" 36 | tput sgr0 # reset to default text 37 | -------------------------------------------------------------------------------- /lib/docraptor.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | # Common files 14 | require 'docraptor/api_client' 15 | require 'docraptor/api_error' 16 | require 'docraptor/version' 17 | require 'docraptor/configuration' 18 | 19 | # Models 20 | require 'docraptor/models/async_doc' 21 | require 'docraptor/models/doc' 22 | require 'docraptor/models/doc_status' 23 | require 'docraptor/models/prince_options' 24 | 25 | # APIs 26 | require 'docraptor/api/doc_api' 27 | 28 | module DocRaptor 29 | class << self 30 | # Customize default settings for the SDK using block. 31 | # DocRaptor.configure do |config| 32 | # config.username = "xxx" 33 | # config.password = "xxx" 34 | # end 35 | # If no block given, return the default Configuration object. 36 | def configure 37 | if block_given? 38 | yield(Configuration.default) 39 | else 40 | Configuration.default 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /test/xlsx.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 12 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.xlsx") 13 | 14 | output_payload = $docraptor.create_doc( 15 | test: true, 16 | document_content: "| Hello from Ruby |
Baseline text
25 | 26 | 27 | HTML 28 | name: output_file, 29 | document_type: "pdf", 30 | pipeline: "10", 31 | prince_options: { iframes: false }, 32 | ) 33 | 34 | File.write(output_file, output_payload) 35 | output_type = `file -b #{output_file}` 36 | 37 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 38 | 39 | text = `pdftotext #{output_file} -` 40 | raise "Output shouldn't load iframe" if text =~ /Test/ 41 | -------------------------------------------------------------------------------- /test/iframes_true.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = ENV["DOCRAPTOR_KEY"] || "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | # TODO: Remove once pipeline 10 is public. At that point the try it out user 10 | # will be able to use the iframes option, so this test will pass. 11 | unless ENV["DOCRAPTOR_KEY"] 12 | puts "Skipping #{$0} because DOCRAPTOR_KEY is not set." 13 | exit(0) 14 | end 15 | 16 | $docraptor = DocRaptor::DocApi.new 17 | 18 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 19 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 20 | output_payload = $docraptor.create_doc( 21 | test: true, 22 | document_content: <<~HTML, 23 | 24 |Baseline text
25 | 26 | 27 | HTML 28 | name: output_file, 29 | document_type: "pdf", 30 | pipeline: "10", 31 | prince_options: { iframes: true }, 32 | ) 33 | 34 | File.write(output_file, output_payload) 35 | output_type = `file -b #{output_file}` 36 | 37 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 38 | 39 | text = `pdftotext #{output_file} -` 40 | raise "Output shouldn't load iframe" if text !~ /Test/ 41 | -------------------------------------------------------------------------------- /test/iframes_default.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = ENV["DOCRAPTOR_KEY"] || "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | # TODO: Remove once pipeline 10 is public. At that point the try it out user 10 | # will be able to use the iframes option, so this test will pass. 11 | unless ENV["DOCRAPTOR_KEY"] 12 | puts "Skipping #{$0} because DOCRAPTOR_KEY is not set." 13 | exit(0) 14 | end 15 | 16 | $docraptor = DocRaptor::DocApi.new 17 | 18 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 19 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 20 | output_payload = $docraptor.create_doc( 21 | test: true, 22 | document_content: <<~HTML, 23 | 24 |Baseline text
25 | 26 | 27 | HTML 28 | name: output_file, 29 | document_type: "pdf", 30 | pipeline: "10", 31 | # prince_options: { iframes: true }, 32 | ) 33 | 34 | File.write(output_file, output_payload) 35 | output_type = `file -b #{output_file}` 36 | 37 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 38 | 39 | text = `pdftotext #{output_file} -` 40 | raise "Output shouldn't load iframe" if text !~ /Test/ 41 | -------------------------------------------------------------------------------- /test/expire_hosted.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | require 'open-uri' 4 | 5 | DocRaptor.configure do |dr| 6 | dr.username = "YOUR_API_KEY_HERE" 7 | # dr.debugging = true 8 | end 9 | 10 | $docraptor = DocRaptor::DocApi.new 11 | 12 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 13 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 14 | 15 | output_payload = $docraptor.create_hosted_async_doc( 16 | test: true, 17 | document_content: "Hello from Ruby", 18 | name: output_file, 19 | document_type: "pdf", 20 | hosted_expires_at: (Time.now + 86400).strftime('%FT%T%:z'), # 1 day from now 21 | ) 22 | 23 | status_response = nil 24 | 30.times do 25 | status_response = $docraptor.get_async_doc_status(output_payload.status_id) 26 | break if status_response.status == "completed" 27 | sleep 1 28 | end 29 | 30 | actual_document = URI.parse(status_response.download_url).open 31 | IO.copy_stream(actual_document, output_file) 32 | 33 | output_type = `file -b #{output_file}` 34 | 35 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 36 | 37 | $docraptor.expire(status_response.download_id) 38 | 39 | begin 40 | actual_document = URI.parse(status_response.download_url).open 41 | rescue OpenURI::HTTPError => http_error 42 | exit 0 43 | end 44 | 45 | exit 1 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by: https://openapi-generator.tech 2 | # 3 | 4 | *.gem 5 | *.rbc 6 | /.config 7 | /coverage/ 8 | /InstalledFiles 9 | /pkg/ 10 | /spec/reports/ 11 | /spec/examples.txt 12 | /test/tmp/ 13 | /test/version_tmp/ 14 | /tmp/ 15 | 16 | ## Specific to RubyMotion: 17 | .dat* 18 | .repl_history 19 | build/ 20 | 21 | ## Documentation cache and generated files: 22 | /.yardoc/ 23 | /_yardoc/ 24 | /doc/ 25 | /rdoc/ 26 | 27 | ## Environment normalization: 28 | /.bundle/ 29 | /vendor/bundle 30 | /lib/bundler/man/ 31 | 32 | # for a library or gem, you might want to ignore these files since the code is 33 | # intended to run in multiple environments; otherwise, check them in: 34 | # Gemfile.lock 35 | # .ruby-version 36 | # .ruby-gemset 37 | 38 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 39 | .rvmrc 40 | 41 | 42 | # EB Customizations 43 | 44 | # Ignore this so we don't see a git modified status on each test run. Currently 45 | # the tests copy a different file into place for each ruby version, because the 46 | # same lock file won't work with every ruby version. We want those lock files 47 | # committed because it helps ensure the tests pass on this repo by ensuring a 48 | # static set of dependencies is used for each ruby version. A future improvement 49 | # could be to use docker to mount the correct lock file over top of the top 50 | # level lock file on each docker run, but that's a future exercise. 51 | Gemfile.lock 52 | -------------------------------------------------------------------------------- /test/prince_options.rb: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | Bundler.require 3 | 4 | DocRaptor.configure do |dr| 5 | dr.username = "YOUR_API_KEY_HERE" 6 | # dr.debugging = true 7 | end 8 | 9 | $docraptor = DocRaptor::DocApi.new 10 | 11 | test_output_dir = File.join(File.dirname(File.expand_path(__FILE__)), "..", "tmp", "test_output") 12 | output_file = File.join(test_output_dir, "#{File.basename(__FILE__, ".rb")}_ruby_#{RUBY_VERSION}.pdf") 13 | 14 | # Verify the test works as expected by confirming that this url will fail 15 | # without prince_options[insecure]=true. 16 | begin 17 | $docraptor.create_doc( 18 | test: true, 19 | document_url: "https://expired.badssl.com/", 20 | name: output_file, 21 | document_type: "pdf", 22 | ) 23 | rescue DocRaptor::ApiError => ex 24 | expected_message = "SSL Error downloading document content from supplied url."; 25 | if ex.message !~ /#{expected_message}/ 26 | raise "Wrong exception, expected: #{expected_message}, got: #{ex.message}" 27 | end 28 | end 29 | 30 | # Verify prince_options works by testing a url that will fail without 31 | # prince_options[insecure]=true. 32 | output_payload = $docraptor.create_doc( 33 | test: true, 34 | document_url: "https://expired.badssl.com/", 35 | name: output_file, 36 | document_type: "pdf", 37 | prince_options: { 38 | insecure: true, 39 | } 40 | ) 41 | 42 | File.write(output_file, output_payload) 43 | output_type = `file -b #{output_file}` 44 | 45 | raise "Output was not a PDF" unless output_type.start_with?("PDF") 46 | -------------------------------------------------------------------------------- /lib/docraptor/api_error.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | module DocRaptor 14 | class ApiError < StandardError 15 | attr_reader :code, :response_headers, :response_body 16 | 17 | # Usage examples: 18 | # ApiError.new 19 | # ApiError.new("message") 20 | # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") 21 | # ApiError.new(:code => 404, :message => "Not Found") 22 | def initialize(arg = nil) 23 | if arg.is_a? Hash 24 | if arg.key?(:message) || arg.key?('message') 25 | super(arg[:message] || arg['message']) 26 | else 27 | super arg 28 | end 29 | 30 | arg.each do |k, v| 31 | instance_variable_set "@#{k}", v 32 | end 33 | else 34 | super arg 35 | @message = arg 36 | end 37 | end 38 | 39 | # Override to_s to display a friendly error message 40 | def to_s 41 | message 42 | end 43 | 44 | def message 45 | if @message.nil? 46 | msg = "Error message: the server returns an error" 47 | else 48 | msg = @message 49 | end 50 | 51 | msg += "\nHTTP status code: #{code}" if code 52 | msg += "\nResponse headers: #{response_headers}" if response_headers 53 | msg += "\nResponse body: #{response_body}" if response_body 54 | 55 | msg 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /script/docker: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | [[ "$TRACE" == "true" ]] && set -x 4 | cd "$(dirname "$0")/.." 5 | 6 | OPTIND=1 7 | 8 | image="" 9 | 10 | while getopts "h?i:" opt; do 11 | case "$opt" in 12 | h|\?) 13 | show_help 14 | exit 0 15 | ;; 16 | i) image="$OPTARG" 17 | ;; 18 | esac 19 | done 20 | 21 | shift $((OPTIND-1)) 22 | 23 | if [[ "$image" == "" ]]; then 24 | image="$(cat .runtime-environments | grep -v '^#' | tail -n 1)" 25 | echo "docker image (-i) unset, defaulting to: $image" 26 | fi 27 | 28 | if ! docker pull "$image"; then 29 | echo "Pulling the latest version of ${image} failed, but we'll continue in" 30 | echo "the hopes that there's a previous version of the container available." 31 | echo "This probably isn't an issue unless you really want to verify" 32 | echo "everything works with a :latest container image." 33 | fi 34 | 35 | command="$1" 36 | 37 | mounts=() 38 | while IFS=':' read -r source target; do 39 | # Create the directory if it's not a special/magic path (like for ssh) 40 | mkdir -p -m 700 "$source" &> /dev/null || true 41 | 42 | mounts+=(--volume) 43 | mounts+=("${source}:${target}") 44 | 45 | # Can't pipe to the while loop because that causes a subshell, which means 46 | # the variables set in the loop aren't available outside of it. 47 | done < <(eval echo "\"$(grep -v '^#' .docker_mounts.list)\"") 48 | 49 | set -x 50 | docker run -it --rm \ 51 | --env-file .docker_env.list \ 52 | --env RUNTIME_ENV="${image}" \ 53 | --mount type=bind,source="$(pwd)",target=/app \ 54 | "${mounts[@]}" \ 55 | "$image" \ 56 | "$command" 57 | -------------------------------------------------------------------------------- /examples/sync.rb: -------------------------------------------------------------------------------- 1 | # This example demonstrates creating a PDF using common options and saving it 2 | # to a place on the filesystem. 3 | # 4 | # It is created synchronously, which means DocRaptor will render it for up to 5 | # 60 seconds. It is slightly simpler than making documents using the async 6 | # interface but making many documents in parallel or very large documents with 7 | # lots of assets will require the async api. 8 | # 9 | # DocRaptor supports many CSS and API options for output customization. Visit 10 | # https://docraptor.com/documentation/ for full details. 11 | # 12 | # You can run this example with: ruby sync.rb 13 | 14 | require "docraptor" 15 | 16 | DocRaptor.configure do |config| 17 | config.username = "YOUR_API_KEY_HERE" # this key works in test mode! 18 | end 19 | 20 | docraptor = DocRaptor::DocApi.new 21 | 22 | begin 23 | response = docraptor.create_doc( 24 | test: true, # test documents are free but watermarked 25 | document_type: "pdf", 26 | document_content: "Hello World!", 27 | # document_url: "https://docraptor.com/examples/invoice.html", 28 | # javascript: true, 29 | # prince_options: { 30 | # media: "print", # @media 'screen' or 'print' CSS 31 | # baseurl: "https://yoursite.com", # the base URL for any relative URLs 32 | # } 33 | ) 34 | 35 | # create_doc() returns a binary string 36 | File.write("github-sync.pdf", response, mode: "wb") 37 | puts "Successfully created github-sync.pdf!" 38 | rescue DocRaptor::ApiError => error 39 | puts "#{error.class}: #{error.message}" 40 | puts error.code 41 | puts error.response_body 42 | puts error.backtrace[0..3].join("\n") 43 | end 44 | -------------------------------------------------------------------------------- /.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | 25 | 26 | # This seems to be a script related to developing openapi-generator and making 27 | # new test APIs. 28 | git_push.sh 29 | 30 | # Don't ignore this because we want to review the generated content to see if we 31 | # should update our own readme similarly. The most common example is an update 32 | # to the supported runtime versions, but it could also be an update to the 33 | # recommended usage that we would want to use. 34 | !README.md 35 | 36 | # Don't ignore this because we want to know about new files that the generator 37 | # ignores. 38 | !.gitignore 39 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | [[ "$TRACE" == "true" ]] && set -x 4 | cd "$(dirname "$0")/.." 5 | 6 | echo "Clearing test output directory" 7 | rm -rf tmp/test_output/ 8 | mkdir -p tmp/test_output 9 | 10 | [ -f script/build ] && script/build 11 | 12 | run_tests() { 13 | runtime_env="$1" 14 | if time script/docker -i "$runtime_env" /app/script/inside_container/test; then 15 | tput bold # bold text 16 | tput setaf 2 # green text 17 | echo "======================================" 18 | echo "$runtime_env Passed" 19 | echo "======================================" 20 | tput sgr0 # reset to default text 21 | return 0 22 | else 23 | tput bold # bold text 24 | tput setaf 1 # red text 25 | echo "======================================" 26 | echo "$runtime_env FAILED" 27 | echo "======================================" 28 | tput sgr0 # reset to default text 29 | return 1 30 | fi 31 | } 32 | 33 | success="true" 34 | 35 | for runtime_env in $(cat .runtime-environments | grep -v '^#'); do 36 | echo 37 | echo 38 | echo "Testing runtime env $runtime_env" 39 | run_tests "$runtime_env" || success="false" 40 | done 41 | 42 | if [ $success == "true" ]; then 43 | tput bold # bold text 44 | tput setaf 2 # green text 45 | echo "======================================" 46 | echo "= Full Test Suite Passed =" 47 | echo "======================================" 48 | tput sgr0 # reset to default text 49 | exit 0 50 | else 51 | tput bold # bold text 52 | tput setaf 1 # red text 53 | echo "======================================" 54 | echo "= Full Test Suite FAILED =" 55 | echo "======================================" 56 | tput sgr0 # reset to default text 57 | exit 1 58 | fi 59 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.2.5.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (2.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.16.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.4) 18 | method_source (1.0.0) 19 | parallel (1.22.1) 20 | parser (3.1.2.1) 21 | ast (~> 2.4.1) 22 | pry (0.13.1) 23 | coderay (~> 1.1) 24 | method_source (~> 1.0) 25 | pry-byebug (3.9.0) 26 | byebug (~> 11.0) 27 | pry (~> 0.13.0) 28 | psych (4.0.6) 29 | stringio 30 | rainbow (3.1.1) 31 | rake (13.0.6) 32 | rspec (3.12.0) 33 | rspec-core (~> 3.12.0) 34 | rspec-expectations (~> 3.12.0) 35 | rspec-mocks (~> 3.12.0) 36 | rspec-core (3.12.0) 37 | rspec-support (~> 3.12.0) 38 | rspec-expectations (3.12.0) 39 | diff-lcs (>= 1.2.0, < 2.0) 40 | rspec-support (~> 3.12.0) 41 | rspec-mocks (3.12.0) 42 | diff-lcs (>= 1.2.0, < 2.0) 43 | rspec-support (~> 3.12.0) 44 | rspec-support (3.12.0) 45 | rubocop (0.66.0) 46 | jaro_winkler (~> 1.5.1) 47 | parallel (~> 1.10) 48 | parser (>= 2.5, != 2.5.1.1) 49 | psych (>= 3.1.0) 50 | rainbow (>= 2.2.2, < 4.0) 51 | ruby-progressbar (~> 1.7) 52 | unicode-display_width (>= 1.4.0, < 1.6) 53 | ruby-progressbar (1.11.0) 54 | stringio (3.0.2) 55 | typhoeus (1.4.0) 56 | ethon (>= 0.9.0) 57 | unicode-display_width (1.5.0) 58 | 59 | PLATFORMS 60 | ruby 61 | 62 | DEPENDENCIES 63 | docraptor! 64 | pry-byebug 65 | rake (~> 13.0.1) 66 | rspec (~> 3.6, >= 3.6.0) 67 | rubocop (~> 0.66.0) 68 | 69 | BUNDLED WITH 70 | 1.17.3 71 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.2.6.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (2.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.15.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.4) 18 | method_source (1.0.0) 19 | parallel (1.22.1) 20 | parser (3.1.2.1) 21 | ast (~> 2.4.1) 22 | pry (0.13.1) 23 | coderay (~> 1.1) 24 | method_source (~> 1.0) 25 | pry-byebug (3.9.0) 26 | byebug (~> 11.0) 27 | pry (~> 0.13.0) 28 | psych (4.0.6) 29 | stringio 30 | rainbow (3.1.1) 31 | rake (13.0.6) 32 | rspec (3.11.0) 33 | rspec-core (~> 3.11.0) 34 | rspec-expectations (~> 3.11.0) 35 | rspec-mocks (~> 3.11.0) 36 | rspec-core (3.11.0) 37 | rspec-support (~> 3.11.0) 38 | rspec-expectations (3.11.1) 39 | diff-lcs (>= 1.2.0, < 2.0) 40 | rspec-support (~> 3.11.0) 41 | rspec-mocks (3.11.1) 42 | diff-lcs (>= 1.2.0, < 2.0) 43 | rspec-support (~> 3.11.0) 44 | rspec-support (3.11.1) 45 | rubocop (0.66.0) 46 | jaro_winkler (~> 1.5.1) 47 | parallel (~> 1.10) 48 | parser (>= 2.5, != 2.5.1.1) 49 | psych (>= 3.1.0) 50 | rainbow (>= 2.2.2, < 4.0) 51 | ruby-progressbar (~> 1.7) 52 | unicode-display_width (>= 1.4.0, < 1.6) 53 | ruby-progressbar (1.11.0) 54 | stringio (3.0.2) 55 | typhoeus (1.4.0) 56 | ethon (>= 0.9.0) 57 | unicode-display_width (1.5.0) 58 | 59 | PLATFORMS 60 | ruby 61 | 62 | DEPENDENCIES 63 | docraptor! 64 | pry-byebug 65 | rake (~> 13.0.1) 66 | rspec (~> 3.6, >= 3.6.0) 67 | rubocop (~> 0.66.0) 68 | 69 | BUNDLED WITH 70 | 1.17.2 71 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.2.7.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (2.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.15.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.4) 18 | method_source (1.0.0) 19 | parallel (1.22.1) 20 | parser (3.1.2.1) 21 | ast (~> 2.4.1) 22 | pry (0.14.1) 23 | coderay (~> 1.1) 24 | method_source (~> 1.0) 25 | pry-byebug (3.10.1) 26 | byebug (~> 11.0) 27 | pry (>= 0.13, < 0.15) 28 | psych (4.0.6) 29 | stringio 30 | rainbow (3.1.1) 31 | rake (13.0.6) 32 | rspec (3.11.0) 33 | rspec-core (~> 3.11.0) 34 | rspec-expectations (~> 3.11.0) 35 | rspec-mocks (~> 3.11.0) 36 | rspec-core (3.11.0) 37 | rspec-support (~> 3.11.0) 38 | rspec-expectations (3.11.1) 39 | diff-lcs (>= 1.2.0, < 2.0) 40 | rspec-support (~> 3.11.0) 41 | rspec-mocks (3.11.1) 42 | diff-lcs (>= 1.2.0, < 2.0) 43 | rspec-support (~> 3.11.0) 44 | rspec-support (3.11.1) 45 | rubocop (0.66.0) 46 | jaro_winkler (~> 1.5.1) 47 | parallel (~> 1.10) 48 | parser (>= 2.5, != 2.5.1.1) 49 | psych (>= 3.1.0) 50 | rainbow (>= 2.2.2, < 4.0) 51 | ruby-progressbar (~> 1.7) 52 | unicode-display_width (>= 1.4.0, < 1.6) 53 | ruby-progressbar (1.11.0) 54 | stringio (3.0.2) 55 | typhoeus (1.4.0) 56 | ethon (>= 0.9.0) 57 | unicode-display_width (1.5.0) 58 | 59 | PLATFORMS 60 | ruby 61 | 62 | DEPENDENCIES 63 | docraptor! 64 | pry-byebug 65 | rake (~> 13.0.1) 66 | rspec (~> 3.6, >= 3.6.0) 67 | rubocop (~> 0.66.0) 68 | 69 | BUNDLED WITH 70 | 2.1.4 71 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.3.0.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (2.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.15.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.4) 18 | method_source (1.0.0) 19 | parallel (1.22.1) 20 | parser (3.1.2.1) 21 | ast (~> 2.4.1) 22 | pry (0.14.1) 23 | coderay (~> 1.1) 24 | method_source (~> 1.0) 25 | pry-byebug (3.10.1) 26 | byebug (~> 11.0) 27 | pry (>= 0.13, < 0.15) 28 | psych (4.0.6) 29 | stringio 30 | rainbow (3.1.1) 31 | rake (13.0.6) 32 | rspec (3.11.0) 33 | rspec-core (~> 3.11.0) 34 | rspec-expectations (~> 3.11.0) 35 | rspec-mocks (~> 3.11.0) 36 | rspec-core (3.11.0) 37 | rspec-support (~> 3.11.0) 38 | rspec-expectations (3.11.1) 39 | diff-lcs (>= 1.2.0, < 2.0) 40 | rspec-support (~> 3.11.0) 41 | rspec-mocks (3.11.1) 42 | diff-lcs (>= 1.2.0, < 2.0) 43 | rspec-support (~> 3.11.0) 44 | rspec-support (3.11.1) 45 | rubocop (0.66.0) 46 | jaro_winkler (~> 1.5.1) 47 | parallel (~> 1.10) 48 | parser (>= 2.5, != 2.5.1.1) 49 | psych (>= 3.1.0) 50 | rainbow (>= 2.2.2, < 4.0) 51 | ruby-progressbar (~> 1.7) 52 | unicode-display_width (>= 1.4.0, < 1.6) 53 | ruby-progressbar (1.11.0) 54 | stringio (3.0.2) 55 | typhoeus (1.4.0) 56 | ethon (>= 0.9.0) 57 | unicode-display_width (1.5.0) 58 | 59 | PLATFORMS 60 | aarch64-linux 61 | 62 | DEPENDENCIES 63 | docraptor! 64 | pry-byebug 65 | rake (~> 13.0.1) 66 | rspec (~> 3.6, >= 3.6.0) 67 | rubocop (~> 0.66.0) 68 | 69 | BUNDLED WITH 70 | 2.2.33 71 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.3.1.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (3.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.16.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.6) 18 | method_source (1.0.0) 19 | parallel (1.23.0) 20 | parser (3.2.2.3) 21 | ast (~> 2.4.1) 22 | racc 23 | pry (0.14.2) 24 | coderay (~> 1.1) 25 | method_source (~> 1.0) 26 | pry-byebug (3.10.1) 27 | byebug (~> 11.0) 28 | pry (>= 0.13, < 0.15) 29 | psych (5.1.0) 30 | stringio 31 | racc (1.7.1) 32 | rainbow (3.1.1) 33 | rake (13.0.6) 34 | rspec (3.12.0) 35 | rspec-core (~> 3.12.0) 36 | rspec-expectations (~> 3.12.0) 37 | rspec-mocks (~> 3.12.0) 38 | rspec-core (3.12.2) 39 | rspec-support (~> 3.12.0) 40 | rspec-expectations (3.12.3) 41 | diff-lcs (>= 1.2.0, < 2.0) 42 | rspec-support (~> 3.12.0) 43 | rspec-mocks (3.12.6) 44 | diff-lcs (>= 1.2.0, < 2.0) 45 | rspec-support (~> 3.12.0) 46 | rspec-support (3.12.1) 47 | rubocop (0.66.0) 48 | jaro_winkler (~> 1.5.1) 49 | parallel (~> 1.10) 50 | parser (>= 2.5, != 2.5.1.1) 51 | psych (>= 3.1.0) 52 | rainbow (>= 2.2.2, < 4.0) 53 | ruby-progressbar (~> 1.7) 54 | unicode-display_width (>= 1.4.0, < 1.6) 55 | ruby-progressbar (1.13.0) 56 | stringio (3.0.7) 57 | typhoeus (1.4.0) 58 | ethon (>= 0.9.0) 59 | unicode-display_width (1.5.0) 60 | 61 | PLATFORMS 62 | aarch64-linux 63 | 64 | DEPENDENCIES 65 | docraptor! 66 | pry-byebug 67 | rake (~> 13.0.1) 68 | rspec (~> 3.6, >= 3.6.0) 69 | rubocop (~> 0.66.0) 70 | 71 | BUNDLED WITH 72 | 2.3.26 73 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.3.2.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (3.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.16.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.6) 18 | method_source (1.0.0) 19 | parallel (1.23.0) 20 | parser (3.2.2.3) 21 | ast (~> 2.4.1) 22 | racc 23 | pry (0.14.2) 24 | coderay (~> 1.1) 25 | method_source (~> 1.0) 26 | pry-byebug (3.10.1) 27 | byebug (~> 11.0) 28 | pry (>= 0.13, < 0.15) 29 | psych (5.1.0) 30 | stringio 31 | racc (1.7.1) 32 | rainbow (3.1.1) 33 | rake (13.0.6) 34 | rspec (3.12.0) 35 | rspec-core (~> 3.12.0) 36 | rspec-expectations (~> 3.12.0) 37 | rspec-mocks (~> 3.12.0) 38 | rspec-core (3.12.2) 39 | rspec-support (~> 3.12.0) 40 | rspec-expectations (3.12.3) 41 | diff-lcs (>= 1.2.0, < 2.0) 42 | rspec-support (~> 3.12.0) 43 | rspec-mocks (3.12.6) 44 | diff-lcs (>= 1.2.0, < 2.0) 45 | rspec-support (~> 3.12.0) 46 | rspec-support (3.12.1) 47 | rubocop (0.66.0) 48 | jaro_winkler (~> 1.5.1) 49 | parallel (~> 1.10) 50 | parser (>= 2.5, != 2.5.1.1) 51 | psych (>= 3.1.0) 52 | rainbow (>= 2.2.2, < 4.0) 53 | ruby-progressbar (~> 1.7) 54 | unicode-display_width (>= 1.4.0, < 1.6) 55 | ruby-progressbar (1.13.0) 56 | stringio (3.0.7) 57 | typhoeus (1.4.0) 58 | ethon (>= 0.9.0) 59 | unicode-display_width (1.5.0) 60 | 61 | PLATFORMS 62 | aarch64-linux 63 | 64 | DEPENDENCIES 65 | docraptor! 66 | pry-byebug 67 | rake (~> 13.0.1) 68 | rspec (~> 3.6, >= 3.6.0) 69 | rubocop (~> 0.66.0) 70 | 71 | BUNDLED WITH 72 | 2.4.10 73 | -------------------------------------------------------------------------------- /gemfiles/Gemfile.3.3.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | docraptor (3.0.0) 5 | typhoeus (~> 1.0, >= 1.0.1) 6 | 7 | GEM 8 | remote: https://rubygems.org/ 9 | specs: 10 | ast (2.4.2) 11 | byebug (11.1.3) 12 | coderay (1.1.3) 13 | diff-lcs (1.5.0) 14 | ethon (0.16.0) 15 | ffi (>= 1.15.0) 16 | ffi (1.15.5) 17 | jaro_winkler (1.5.6) 18 | method_source (1.0.0) 19 | parallel (1.23.0) 20 | parser (3.2.2.3) 21 | ast (~> 2.4.1) 22 | racc 23 | pry (0.14.2) 24 | coderay (~> 1.1) 25 | method_source (~> 1.0) 26 | pry-byebug (3.10.1) 27 | byebug (~> 11.0) 28 | pry (>= 0.13, < 0.15) 29 | psych (5.1.0) 30 | stringio 31 | racc (1.7.1) 32 | rainbow (3.1.1) 33 | rake (13.0.6) 34 | rspec (3.12.0) 35 | rspec-core (~> 3.12.0) 36 | rspec-expectations (~> 3.12.0) 37 | rspec-mocks (~> 3.12.0) 38 | rspec-core (3.12.2) 39 | rspec-support (~> 3.12.0) 40 | rspec-expectations (3.12.3) 41 | diff-lcs (>= 1.2.0, < 2.0) 42 | rspec-support (~> 3.12.0) 43 | rspec-mocks (3.12.6) 44 | diff-lcs (>= 1.2.0, < 2.0) 45 | rspec-support (~> 3.12.0) 46 | rspec-support (3.12.1) 47 | rubocop (0.66.0) 48 | jaro_winkler (~> 1.5.1) 49 | parallel (~> 1.10) 50 | parser (>= 2.5, != 2.5.1.1) 51 | psych (>= 3.1.0) 52 | rainbow (>= 2.2.2, < 4.0) 53 | ruby-progressbar (~> 1.7) 54 | unicode-display_width (>= 1.4.0, < 1.6) 55 | ruby-progressbar (1.13.0) 56 | stringio (3.0.7) 57 | typhoeus (1.4.0) 58 | ethon (>= 0.9.0) 59 | unicode-display_width (1.5.0) 60 | 61 | PLATFORMS 62 | aarch64-linux 63 | 64 | DEPENDENCIES 65 | docraptor! 66 | pry-byebug 67 | rake (~> 13.0.1) 68 | rspec (~> 3.6, >= 3.6.0) 69 | rubocop (~> 0.66.0) 70 | 71 | BUNDLED WITH 72 | 2.5.0.dev 73 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 3.1.0 [July 19, 2023] 2 | * Add new Prince API options for pdf_forms, iframes, and page_margin 3 | 4 | ### 3.0.0 [November 15, 2022] 5 | * Switch API host to more secure api.docraptor.com (dropping old TLS) 6 | * Remove support for rubies <2.5 7 | * Switch from swagger v2.4.19 to openapi-generator v6.0.1 (better maintained) 8 | 9 | ### 2.0.0 [June 1, 2021] 10 | * Add support for ruby 3.x (remove `URI.encode`) 11 | * Remove support for rubies <2.3 12 | 13 | ### 1.4.0 [July 31, 2020] 14 | * add support for hosted documents 15 | * upgrade to latest swagger 2.4.14 16 | 17 | ### 1.3.0 [November 21, 2017] 18 | * Added support for `prince_options[pdf_title]` and `ignore_console_messages` options 19 | 20 | ### 1.2.0 [August 22, 2017] 21 | * No changes from beta1 22 | 23 | ### 1.2.0beta1 [August 9, 2017] 24 | * Re-runnning against newer swagger version (v.2.2.3), bumping many gem dependencies to much newer versions. Applications using client *should not* be affected. 25 | 26 | ### 1.1.0 [November 3, 2016] 27 | * Added support for pipeline API parameter 28 | 29 | ### 1.0.0 [October 18, 2016] 30 | * No significant code changes 31 | 32 | ### 0.4.0 [September 26, 2016] 33 | * Added support for prince_options[no_parallel_downloads] 34 | 35 | ### 0.3.0 [March 11, 2016] 36 | * Added support for prince_options[debug] 37 | 38 | ### 0.2.0 [January 29, 2016] 39 | * **BREAKING CHANGE**: Rename ClientApi to DocApi 40 | 41 | ### 0.1.0 [January 27, 2016] 42 | * **BREAKING CHANGE**: create_doc and get_async_doc responses are now binary strings instead of Tempfiles 43 | 44 | ### 0.0.3 [January 15, 2016] 45 | * Use better API command names: create_doc, create_async_doc, get_async_doc_status, get_async_doc 46 | * Fix file encoding issues when used in Rails 47 | 48 | ### 0.0.2 [January 6, 2016] 49 | * Regenerate using swagger-codegen v2.1.5 50 | 51 | ### 0.0.1 [November 1, 2015] 52 | * Initial release 53 | -------------------------------------------------------------------------------- /.review/generated_files/spec/models/doc_status_spec.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | require 'spec_helper' 14 | require 'json' 15 | require 'date' 16 | 17 | # Unit tests for DocRaptor::DocStatus 18 | # Automatically generated by openapi-generator (https://openapi-generator.tech) 19 | # Please update as you see appropriate 20 | describe DocRaptor::DocStatus do 21 | let(:instance) { DocRaptor::DocStatus.new } 22 | 23 | describe 'test an instance of DocStatus' do 24 | it 'should create an instance of DocStatus' do 25 | expect(instance).to be_instance_of(DocRaptor::DocStatus) 26 | end 27 | end 28 | describe 'test attribute "status"' do 29 | it 'should work' do 30 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 31 | end 32 | end 33 | 34 | describe 'test attribute "download_url"' do 35 | it 'should work' do 36 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 37 | end 38 | end 39 | 40 | describe 'test attribute "download_id"' do 41 | it 'should work' do 42 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 43 | end 44 | end 45 | 46 | describe 'test attribute "message"' do 47 | it 'should work' do 48 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 49 | end 50 | end 51 | 52 | describe 'test attribute "number_of_pages"' do 53 | it 'should work' do 54 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 55 | end 56 | end 57 | 58 | describe 'test attribute "validation_errors"' do 59 | it 'should work' do 60 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 61 | end 62 | end 63 | 64 | end 65 | -------------------------------------------------------------------------------- /script/inside_container/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | cd "$(dirname "$0")/../.." 4 | 5 | apt update 6 | apt install poppler-utils -y 7 | 8 | # check dependencies 9 | ruby -v > /dev/null || (echo "ruby must be installed"; exit 1) 10 | 11 | major_minor_version="$(ruby -e 'puts RUBY_VERSION.split(".")[0, 2].join(".")')" 12 | gemfile_lock="gemfiles/Gemfile.${major_minor_version}.lock" 13 | if [ -f "$gemfile_lock" ]; then 14 | cp -v "$gemfile_lock" Gemfile.lock 15 | else 16 | rm -vf Gemfile.lock 17 | fi 18 | 19 | bundle -v > /dev/null || (echo "bundler must be installed"; exit 1) 20 | 21 | # TODO: update to test against updates dependencies as well 22 | bundle install 23 | 24 | if [ ! -f "$gemfile_lock" ]; then 25 | cp -v Gemfile.lock "$gemfile_lock" 26 | fi 27 | 28 | cd test 29 | 30 | 31 | green() { 32 | tput bold # bold text 33 | tput setaf 2 # green text 34 | echo -n "$@" 35 | tput sgr0 # reset to default text 36 | } 37 | red() { 38 | tput bold # bold text 39 | tput setaf 1 # red text 40 | echo -n "$@" 41 | tput sgr0 # reset to default text 42 | } 43 | 44 | 45 | key_relative_path="tmp/.docraptor_key" 46 | key_path="../$key_relative_path" 47 | 48 | # runs a test file with PASS/FAIL message 49 | run_test() { 50 | test_success="true" 51 | test_name="$1 ${2:-(without $key_relative_path)}" 52 | if [[ "$DOCRAPTOR_KEY" == "" ]] && [ -f "$key_path" ]; then 53 | ( 54 | export DOCRAPTOR_KEY="$(cat "$key_path")" 55 | run_test $1 "(with $key_relative_path)" 56 | ) || test_success="false" 57 | fi 58 | 59 | if ruby $1; then 60 | echo "$(green PASS) $test_name" 61 | else 62 | test_success="false" 63 | echo "$(red FAIL) $test_name" 64 | fi 65 | 66 | if [ $test_success == "true" ]; then 67 | return 0 68 | else 69 | return 1 70 | fi 71 | } 72 | 73 | success="true" 74 | 75 | if [ "$1" == "" ]; then 76 | for test in $(ls *.rb); do 77 | run_test $test || success="false" 78 | done 79 | else 80 | run_test $1.rb || success="false" 81 | fi 82 | 83 | if [ $success == "true" ]; then 84 | exit 0 85 | else 86 | exit 1 87 | fi 88 | -------------------------------------------------------------------------------- /examples/async.rb: -------------------------------------------------------------------------------- 1 | # This example demonstrates creating a PDF using common options and saving it 2 | # to a place on the filesystem. 3 | # 4 | # It is created asynchronously, which means DocRaptor will render it for up to 5 | # 10 minutes. This is useful when creating many documents in parallel, or very 6 | # large documents with lots of assets. 7 | # 8 | # DocRaptor supports many CSS and API options for output customization. Visit 9 | # https://docraptor.com/documentation/ for full details. 10 | # 11 | # You can run this example with: ruby async.rb 12 | 13 | require "docraptor" 14 | 15 | DocRaptor.configure do |config| 16 | config.username = "YOUR_API_KEY_HERE" # this key works in test mode! 17 | end 18 | 19 | docraptor = DocRaptor::DocApi.new 20 | 21 | begin 22 | # different method than the synchronous documents 23 | response = docraptor.create_async_doc( 24 | test: true, # test documents are free but watermarked 25 | document_type: "pdf", 26 | document_content: "Hello World!", 27 | # document_url: "https://docraptor.com/examples/invoice.html", 28 | # javascript: true, 29 | # prince_options: { 30 | # media: "print", # @media 'screen' or 'print' CSS 31 | # baseurl: "https://yoursite.com", # the base URL for any relative URLs 32 | # } 33 | ) 34 | 35 | loop do 36 | status_response = docraptor.get_async_doc_status(response.status_id) 37 | puts "status: #{status_response.status}" 38 | case status_response.status 39 | when "completed" 40 | document = docraptor.get_async_doc(status_response.download_id) 41 | # get_async_doc() returns a binary string 42 | File.write("github-async.pdf", document, mode: "wb") 43 | puts "Successfully created github-async.pdf!" 44 | break 45 | when "failed" 46 | puts "FAILED" 47 | puts status_response 48 | break 49 | else 50 | sleep 1 51 | end 52 | end 53 | rescue DocRaptor::ApiError => error 54 | puts "#{error.class}: #{error.message}" 55 | puts error.code 56 | puts error.response_body 57 | puts error.backtrace[0..3].join("\n") 58 | end 59 | -------------------------------------------------------------------------------- /examples/hosted_sync.rb: -------------------------------------------------------------------------------- 1 | # As a paid add-on, DocRaptor can provide long-term, publicly-accessible hosting for your documents. 2 | # This allows you to provide a URL to your end users, third party tools like Zapier and Salesforce, 3 | # or anyone else. We'll host the document on your behalf at a completely unbranded URL for as long 4 | # as you want, or within the limits you specify. 5 | # 6 | # This example demonstrates creating a PDF that DocRaptor will host for you using common options. 7 | # By default, hosted documents do not have limits on downloads or hosting time, though you may 8 | # pass additional parameters to the document generation call to set your own limits. Learn more 9 | # about the specific options in the hosted API documentation. 10 | # https://docraptor.com/documentation/api#api_hosted 11 | # 12 | # It is created synchronously, which means DocRaptor will allow it to generate for up to 60 seconds. 13 | # Since this document will be hosted by DocRaptor the response from this request will return a JSON 14 | # formatted object containing public URL where the document can be downloaded from. 15 | # 16 | # DocRaptor supports many CSS and API options for output customization. Visit 17 | # https://docraptor.com/documentation/ for full details. 18 | # 19 | # You can run this example with: ruby hosted_sync.rb 20 | 21 | require "docraptor" 22 | 23 | DocRaptor.configure do |config| 24 | config.username = "YOUR_API_KEY_HERE" # this key works in test mode! 25 | end 26 | 27 | docraptor = DocRaptor::DocApi.new 28 | 29 | begin 30 | # different method than the non-hosted documents 31 | response = docraptor.create_hosted_doc( 32 | test: true, # test documents are free but watermarked 33 | document_type: "pdf", 34 | document_content: "Hello World!", 35 | # document_url: "https://docraptor.com/examples/invoice.html", 36 | # javascript: true, 37 | # prince_options: { 38 | # media: "print", # @media 'screen' or 'print' CSS 39 | # baseurl: "https://yoursite.com", # the base URL for any relative URLs 40 | # } 41 | ) 42 | 43 | puts "The PDF is hosted at #{response.download_url}" 44 | rescue DocRaptor::ApiError => error 45 | puts "#{error.class}: #{error.message}" 46 | puts error.code 47 | puts error.response_body 48 | puts error.backtrace[0..3].join("\n") 49 | end 50 | -------------------------------------------------------------------------------- /script/generate_language: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | [[ "$TRACE" == "true" ]] && set -x 4 | cd "$(dirname "$0")/.." 5 | 6 | LANGUAGE="$(cat .generator-language-identifier)" 7 | CONFIG_FILE="generator-config.json" 8 | 9 | if [ "$LANGUAGE" = "" ]; then 10 | ./script/swagger # prints languages 11 | exit 1 12 | fi 13 | 14 | if [ ! -f "$CONFIG_FILE" ]; then 15 | echo "Could not find $CONFIG_FILE" 16 | ./script/swagger config-help -l "$LANGUAGE" 17 | exit 1 18 | fi 19 | 20 | ./script/clean 21 | 22 | # See .review/README.md 23 | echo "Facilitating generated content review" 24 | tmp_dir=".review/tmp" 25 | review_root=".review/generated_files" 26 | # Clear the tmp_dir, where we'll temporarily store our files so they aren't 27 | # overwritten by the generated files. 28 | rm -rf "$tmp_dir" 29 | (cd "$review_root" && find . -type f) | while read file_path; do 30 | # Move our file out of the way so it doesn't get overwritten by the generated 31 | # file, but only if the file exists. Some files, like the generated docs and 32 | # tests, aren't useful to users to we generally remove them, but we still 33 | # want to facilitate review of these generated files. 34 | if [ -e "$file_path" ]; then 35 | mkdir -p "$(dirname "${tmp_dir}/$file_path")" 36 | mv -v "$file_path" "${tmp_dir}/$file_path" 37 | fi 38 | done 39 | 40 | ./script/swagger generate \ 41 | -i docraptor.yaml \ 42 | -g "$LANGUAGE" \ 43 | -c "$CONFIG_FILE" 44 | 45 | # call a generator cleanup script 46 | if [ -f "script/post_generate_language" ]; then 47 | ./script/post_generate_language 48 | fi 49 | 50 | # See .review/README.md 51 | echo "Facilitating generated content review" 52 | (cd "$review_root" && find . -type f) | while read file_path; do 53 | # Update $review_root to match the generated files. 54 | if [ -e "$file_path" ]; then 55 | # Move the newly generated file into the review directory so we'll be able to 56 | # see it in the diff. 57 | mv -v "$file_path" "$review_root/$file_path" 58 | else 59 | # If the file doesn't exist, then it was removed by the generator, so we 60 | # should remove it from the review directory as well. 61 | rm -v "$review_root/$file_path" 62 | fi 63 | # If we temporarily stored a file (meaning it existed before the generation) 64 | # then move it back into place. 65 | if [ -e "${tmp_dir}/$file_path" ]; then 66 | mv -v "${tmp_dir}/$file_path" "$file_path" 67 | fi 68 | done 69 | -------------------------------------------------------------------------------- /examples/hosted_async.rb: -------------------------------------------------------------------------------- 1 | # As a paid add-on, DocRaptor can provide long-term, publicly-accessible hosting for your documents. 2 | # This allows you to provide a URL to your end users, third party tools like Zapier and Salesforce, 3 | # or anyone else. We'll host the document on your behalf at a completely unbranded URL for as long 4 | # as you want, or within the limits you specify. 5 | # 6 | # This example demonstrates creating a PDF using common options that DocRaptor will host for you. 7 | # By default, hosted documents do not have limits on downloads or hosting time, though you may 8 | # pass additional parameters to the document generation call to set your own limits. Learn more 9 | # about the specific options in the hosted API documentation. 10 | # https://docraptor.com/documentation/api#api_hosted 11 | # 12 | # The document is created asynchronously, which means DocRaptor will allow it to generate for up to 13 | # 10 minutes. This is useful when creating many documents in parallel, or very large documents with 14 | # lots of assets. 15 | # 16 | # DocRaptor supports many CSS and API options for output customization. Visit 17 | # https://docraptor.com/documentation/ for full details. 18 | # 19 | # You can run this example with: ruby hosted_async.rb 20 | 21 | require "docraptor" 22 | 23 | DocRaptor.configure do |config| 24 | config.username = "YOUR_API_KEY_HERE" # this key works in test mode! 25 | end 26 | 27 | docraptor = DocRaptor::DocApi.new 28 | 29 | begin 30 | # different method than synchronous or non-hosted documents 31 | response = docraptor.create_hosted_async_doc( 32 | test: true, # test documents are free but watermarked 33 | document_type: "pdf", 34 | document_content: "Hello World!", 35 | # document_url: "https://docraptor.com/examples/invoice.html", 36 | # javascript: true, 37 | # prince_options: { 38 | # media: "print", # @media 'screen' or 'print' CSS 39 | # baseurl: "https://yoursite.com", # the base URL for any relative URLs 40 | # } 41 | ) 42 | 43 | loop do 44 | status_response = docraptor.get_async_doc_status(response.status_id) 45 | puts "status: #{status_response.status}" 46 | case status_response.status 47 | when "completed" 48 | puts "The asynchronously-generated PDF is hosted at #{status_response.download_url}" 49 | break 50 | when "failed" 51 | puts "FAILED" 52 | puts status_response 53 | break 54 | else 55 | sleep 1 56 | end 57 | end 58 | rescue DocRaptor::ApiError => error 59 | puts "#{error.class}: #{error.message}" 60 | puts error.code 61 | puts error.response_body 62 | puts error.backtrace[0..3].join("\n") 63 | end 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DocRaptor Ruby Native Client Library 2 | 3 | This is a Ruby gem for using [DocRaptor API](https://docraptor.com/documentation) to convert [HTML to PDF and XLSX](https://docraptor.com). 4 | 5 | 6 | ## Installation 7 | 8 | Add the following to your `Gemfile`. 9 | 10 | ```ruby 11 | gem "docraptor" 12 | ``` 13 | 14 | Then run: 15 | 16 | ```bash 17 | bundle install 18 | ``` 19 | 20 | 21 | ## Basic Usage 22 | 23 | ```ruby 24 | DocRaptor.configure do |config| 25 | config.username = "YOUR_API_KEY_HERE" # this key works for test documents 26 | # config.debugging = true 27 | end 28 | 29 | $docraptor = DocRaptor::DocApi.new 30 | 31 | response = $docraptor.create_doc( 32 | test: true, # test documents are free but watermarked 33 | document_content: "Hello World", # supply content directly 34 | # document_url: "http://docraptor.com/examples/invoice.html", # or use a url 35 | name: "docraptor-ruby.pdf", # help you find a document later 36 | document_type: "pdf", # pdf or xls or xlsx 37 | # javascript: true, # enable JavaScript processing 38 | # prince_options: { 39 | # media: "screen", # use screen styles instead of print styles 40 | # baseurl: "http://hello.com", # pretend URL when using document_content 41 | # }, 42 | ) 43 | ``` 44 | 45 | ## Next Steps 46 | 47 | - Optionally store and get a URL for your converted document with [document hosting](https://docraptor.com/document-hosting) 48 | - View more [code examples](examples) with error handling, asynchronous creation, file saving, and document hosting. 49 | - Perfect your document styling with our [style and formatting reference](https://docraptor.com/documentation/style), and [API reference](https://docraptor.com/documentation/api). Easily add headers and footers, page breaks, page numbers, table of contents, and much more! 50 | 51 | ## More Help 52 | 53 | Stuck? We're experts at turning HTML into PDFs so please [email us](mailto:support@docraptor.com) if you run into trouble. 54 | 55 | 56 | ## Development 57 | 58 | The majority of the code in this repo is generated using openapi-generator on [docraptor.yaml](docraptor.yaml). You can modify this file and regenerate the client using `script/generate_language`. 59 | 60 | 61 | ## Release Process 62 | 63 | 1. Pull latest master 64 | 2. Merge feature branch(es) into master 65 | 3. `script/test` 66 | 4. Increment version: `generator-config.json` 67 | 5. Run `script/generate_language` to update generated version numbers: 68 | - `lib/docraptor/version.rb` 69 | 6. Update [CHANGELOG.md](CHANGELOG.md) 70 | 7. Commit "Release version vX.Y.Z" 71 | 8. `script/release` 72 | 9. Verify package release at https://rubygems.org/gems/docraptor 73 | 10. Refresh documentation on docraptor.com 74 | 75 | 76 | ## Version Policy 77 | 78 | This library follows [Semantic Versioning 2.0.0](http://semver.org). 79 | -------------------------------------------------------------------------------- /.review/generated_files/docs/Doc.md: -------------------------------------------------------------------------------- 1 | # DocRaptor::Doc 2 | 3 | ## Properties 4 | 5 | | Name | Type | Description | Notes | 6 | | ---- | ---- | ----------- | ----- | 7 | | **name** | **String** | A name for identifying your document. | | 8 | | **document_type** | **String** | The type of document being created. | | 9 | | **document_content** | **String** | The HTML data to be transformed into a document. You must supply content using document_content or document_url. | [optional] | 10 | | **document_url** | **String** | The URL to fetch the HTML data to be transformed into a document. You must supply content using document_content or document_url. | [optional] | 11 | | **test** | **Boolean** | Enable test mode for this document. Test documents are not charged for but include a watermark. | [optional][default to true] | 12 | | **pipeline** | **String** | Specify a specific verison of the DocRaptor Pipeline to use. | [optional] | 13 | | **strict** | **String** | Force strict HTML validation. | [optional] | 14 | | **ignore_resource_errors** | **Boolean** | Failed loading of images/javascripts/stylesheets/etc. will not cause the rendering to stop. | [optional][default to true] | 15 | | **ignore_console_messages** | **Boolean** | Prevent console.log from stopping document rendering during JavaScript execution. | [optional][default to false] | 16 | | **tag** | **String** | A field for storing a small amount of metadata with this document. | [optional] | 17 | | **help** | **Boolean** | Request support help with this request if it succeeds. | [optional][default to false] | 18 | | **javascript** | **Boolean** | Enable DocRaptor JavaScript parsing. PrinceXML JavaScript parsing is also available elsewhere. | [optional][default to false] | 19 | | **referrer** | **String** | Set HTTP referrer when generating this document. | [optional] | 20 | | **callback_url** | **String** | A URL that will receive a POST request after successfully completing an asynchronous document. The POST data will include download_url and download_id similar to status API responses. WARNING: this only works on asynchronous documents. | [optional] | 21 | | **hosted_download_limit** | **Integer** | The number of times a hosted document can be downloaded. If no limit is specified, the document will be available for an unlimited number of downloads. | [optional] | 22 | | **hosted_expires_at** | **String** | The date and time at which a hosted document will be removed and no longer available. Must be a properly formatted ISO 8601 datetime, like 1981-01-23T08:02:30-05:00. | [optional] | 23 | | **prince_options** | [**PrinceOptions**](PrinceOptions.md) | | [optional] | 24 | 25 | ## Example 26 | 27 | ```ruby 28 | require 'docraptor' 29 | 30 | instance = DocRaptor::Doc.new( 31 | name: null, 32 | document_type: null, 33 | document_content: null, 34 | document_url: null, 35 | test: null, 36 | pipeline: null, 37 | strict: null, 38 | ignore_resource_errors: null, 39 | ignore_console_messages: null, 40 | tag: null, 41 | help: null, 42 | javascript: null, 43 | referrer: null, 44 | callback_url: null, 45 | hosted_download_limit: null, 46 | hosted_expires_at: null, 47 | prince_options: null 48 | ) 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /.review/generated_files/README.md: -------------------------------------------------------------------------------- 1 | # docraptor 2 | 3 | DocRaptor - the Ruby gem for the DocRaptor 4 | 5 | A native client library for the DocRaptor HTML to PDF/XLS service. 6 | 7 | This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 8 | 9 | - API version: 2.0.0 10 | - Package version: 3.1.0 11 | - Build package: org.openapitools.codegen.languages.RubyClientCodegen 12 | 13 | ## Installation 14 | 15 | ### Build a gem 16 | 17 | To build the Ruby code into a gem: 18 | 19 | ```shell 20 | gem build docraptor.gemspec 21 | ``` 22 | 23 | Then either install the gem locally: 24 | 25 | ```shell 26 | gem install ./docraptor-3.1.0.gem 27 | ``` 28 | 29 | (for development, run `gem install --dev ./docraptor-3.1.0.gem` to install the development dependencies) 30 | 31 | or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). 32 | 33 | Finally add this to the Gemfile: 34 | 35 | gem 'docraptor', '~> 3.1.0' 36 | 37 | ### Install from Git 38 | 39 | If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile: 40 | 41 | gem 'docraptor', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' 42 | 43 | ### Include the Ruby code directly 44 | 45 | Include the Ruby code directly using `-I` as follows: 46 | 47 | ```shell 48 | ruby -Ilib script.rb 49 | ``` 50 | 51 | ## Getting Started 52 | 53 | Please follow the [installation](#installation) procedure and then run the following code: 54 | 55 | ```ruby 56 | # Load the gem 57 | require 'docraptor' 58 | 59 | # Setup authorization 60 | DocRaptor.configure do |config| 61 | # Configure HTTP basic authorization: basicAuth 62 | config.username = 'YOUR_USERNAME' 63 | config.password = 'YOUR_PASSWORD' 64 | end 65 | 66 | api_instance = DocRaptor::DocApi.new 67 | doc = DocRaptor::Doc.new({name: 'name_example', document_type: 'pdf'}) # Doc | 68 | 69 | begin 70 | result = api_instance.create_async_doc(doc) 71 | p result 72 | rescue DocRaptor::ApiError => e 73 | puts "Exception when calling DocApi->create_async_doc: #{e}" 74 | end 75 | 76 | ``` 77 | 78 | ## Documentation for API Endpoints 79 | 80 | All URIs are relative to *https://api.docraptor.com* 81 | 82 | Class | Method | HTTP request | Description 83 | ------------ | ------------- | ------------- | ------------- 84 | *DocRaptor::DocApi* | [**create_async_doc**](docs/DocApi.md#create_async_doc) | **POST** /async_docs | 85 | *DocRaptor::DocApi* | [**create_doc**](docs/DocApi.md#create_doc) | **POST** /docs | 86 | *DocRaptor::DocApi* | [**create_hosted_async_doc**](docs/DocApi.md#create_hosted_async_doc) | **POST** /hosted_async_docs | 87 | *DocRaptor::DocApi* | [**create_hosted_doc**](docs/DocApi.md#create_hosted_doc) | **POST** /hosted_docs | 88 | *DocRaptor::DocApi* | [**expire**](docs/DocApi.md#expire) | **PATCH** /expire/{id} | 89 | *DocRaptor::DocApi* | [**get_async_doc**](docs/DocApi.md#get_async_doc) | **GET** /download/{id} | 90 | *DocRaptor::DocApi* | [**get_async_doc_status**](docs/DocApi.md#get_async_doc_status) | **GET** /status/{id} | 91 | 92 | 93 | ## Documentation for Models 94 | 95 | - [DocRaptor::AsyncDoc](docs/AsyncDoc.md) 96 | - [DocRaptor::Doc](docs/Doc.md) 97 | - [DocRaptor::DocStatus](docs/DocStatus.md) 98 | - [DocRaptor::PrinceOptions](docs/PrinceOptions.md) 99 | 100 | 101 | ## Documentation for Authorization 102 | 103 | 104 | Authentication schemes defined for the API: 105 | ### basicAuth 106 | 107 | - **Type**: HTTP basic authentication 108 | 109 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | # This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) 2 | # Automatically generated by OpenAPI Generator (https://openapi-generator.tech) 3 | AllCops: 4 | TargetRubyVersion: 2.4 5 | # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop 6 | # to ignore them, so only the ones explicitly set in this file are enabled. 7 | DisabledByDefault: true 8 | Exclude: 9 | - '**/templates/**/*' 10 | - '**/vendor/**/*' 11 | - 'actionpack/lib/action_dispatch/journey/parser.rb' 12 | 13 | # Prefer &&/|| over and/or. 14 | Style/AndOr: 15 | Enabled: true 16 | 17 | # Align `when` with `case`. 18 | Layout/CaseIndentation: 19 | Enabled: true 20 | 21 | # Align comments with method definitions. 22 | Layout/CommentIndentation: 23 | Enabled: true 24 | 25 | Layout/ElseAlignment: 26 | Enabled: true 27 | 28 | Layout/EmptyLineAfterMagicComment: 29 | Enabled: true 30 | 31 | # In a regular class definition, no empty lines around the body. 32 | Layout/EmptyLinesAroundClassBody: 33 | Enabled: true 34 | 35 | # In a regular method definition, no empty lines around the body. 36 | Layout/EmptyLinesAroundMethodBody: 37 | Enabled: true 38 | 39 | # In a regular module definition, no empty lines around the body. 40 | Layout/EmptyLinesAroundModuleBody: 41 | Enabled: true 42 | 43 | Layout/FirstArgumentIndentation: 44 | Enabled: true 45 | 46 | # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. 47 | Style/HashSyntax: 48 | Enabled: false 49 | 50 | # Method definitions after `private` or `protected` isolated calls need one 51 | # extra level of indentation. 52 | Layout/IndentationConsistency: 53 | Enabled: true 54 | EnforcedStyle: indented_internal_methods 55 | 56 | # Two spaces, no tabs (for indentation). 57 | Layout/IndentationWidth: 58 | Enabled: true 59 | 60 | Layout/LeadingCommentSpace: 61 | Enabled: true 62 | 63 | Layout/SpaceAfterColon: 64 | Enabled: true 65 | 66 | Layout/SpaceAfterComma: 67 | Enabled: true 68 | 69 | Layout/SpaceAroundEqualsInParameterDefault: 70 | Enabled: true 71 | 72 | Layout/SpaceAroundKeyword: 73 | Enabled: true 74 | 75 | Layout/SpaceAroundOperators: 76 | Enabled: true 77 | 78 | Layout/SpaceBeforeComma: 79 | Enabled: true 80 | 81 | Layout/SpaceBeforeFirstArg: 82 | Enabled: true 83 | 84 | Style/DefWithParentheses: 85 | Enabled: true 86 | 87 | # Defining a method with parameters needs parentheses. 88 | Style/MethodDefParentheses: 89 | Enabled: true 90 | 91 | Style/FrozenStringLiteralComment: 92 | Enabled: false 93 | EnforcedStyle: always 94 | 95 | # Use `foo {}` not `foo{}`. 96 | Layout/SpaceBeforeBlockBraces: 97 | Enabled: true 98 | 99 | # Use `foo { bar }` not `foo {bar}`. 100 | Layout/SpaceInsideBlockBraces: 101 | Enabled: true 102 | 103 | # Use `{ a: 1 }` not `{a:1}`. 104 | Layout/SpaceInsideHashLiteralBraces: 105 | Enabled: true 106 | 107 | Layout/SpaceInsideParens: 108 | Enabled: true 109 | 110 | # Check quotes usage according to lint rule below. 111 | #Style/StringLiterals: 112 | # Enabled: true 113 | # EnforcedStyle: single_quotes 114 | 115 | # Detect hard tabs, no hard tabs. 116 | Layout/IndentationStyle: 117 | Enabled: true 118 | 119 | # Blank lines should not have any spaces. 120 | Layout/TrailingEmptyLines: 121 | Enabled: true 122 | 123 | # No trailing whitespace. 124 | Layout/TrailingWhitespace: 125 | Enabled: false 126 | 127 | # Use quotes for string literals when they are enough. 128 | Style/RedundantPercentQ: 129 | Enabled: true 130 | 131 | # Align `end` with the matching keyword or starting expression except for 132 | # assignments, where it should be aligned with the LHS. 133 | Layout/EndAlignment: 134 | Enabled: true 135 | EnforcedStyleAlignWith: variable 136 | AutoCorrect: true 137 | 138 | # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. 139 | Lint/RequireParentheses: 140 | Enabled: true 141 | 142 | Style/RedundantReturn: 143 | Enabled: true 144 | AllowMultipleReturnValues: true 145 | 146 | Style/Semicolon: 147 | Enabled: true 148 | AllowAsExpressionSeparator: true 149 | -------------------------------------------------------------------------------- /.review/generated_files/docs/PrinceOptions.md: -------------------------------------------------------------------------------- 1 | # DocRaptor::PrinceOptions 2 | 3 | ## Properties 4 | 5 | | Name | Type | Description | Notes | 6 | | ---- | ---- | ----------- | ----- | 7 | | **baseurl** | **String** | Set the baseurl for assets. | [optional] | 8 | | **no_xinclude** | **Boolean** | Disable XML inclusion. | [optional] | 9 | | **no_network** | **Boolean** | Disable network access. | [optional] | 10 | | **no_parallel_downloads** | **Boolean** | Disables parallel fetching of assets during PDF creation. Useful if your asset host has strict rate limiting. | [optional] | 11 | | **http_user** | **String** | Set the user for HTTP authentication. | [optional] | 12 | | **http_password** | **String** | Set the password for HTTP authentication. | [optional] | 13 | | **http_proxy** | **String** | Set the HTTP proxy server. | [optional] | 14 | | **http_timeout** | **Integer** | Set the HTTP request timeout. | [optional] | 15 | | **insecure** | **Boolean** | Disable SSL verification. | [optional] | 16 | | **media** | **String** | Specify the CSS media type. Defaults to \"print\" but you may want to use \"screen\" for web styles. | [optional] | 17 | | **no_author_style** | **Boolean** | Ignore author stylesheets. | [optional] | 18 | | **no_default_style** | **Boolean** | Ignore default stylesheets. | [optional] | 19 | | **no_embed_fonts** | **Boolean** | Disable font embedding in PDFs. | [optional] | 20 | | **no_subset_fonts** | **Boolean** | Disable font subsetting in PDFs. | [optional] | 21 | | **no_compress** | **Boolean** | Disable PDF compression. | [optional] | 22 | | **encrypt** | **Boolean** | Encrypt PDF output. | [optional] | 23 | | **key_bits** | **Integer** | Set encryption key size. | [optional] | 24 | | **user_password** | **String** | Set the PDF user password. | [optional] | 25 | | **owner_password** | **String** | Set the PDF owner password. | [optional] | 26 | | **disallow_print** | **Boolean** | Disallow printing of this PDF. | [optional] | 27 | | **disallow_copy** | **Boolean** | Disallow copying of this PDF. | [optional] | 28 | | **disallow_annotate** | **Boolean** | Disallow annotation of this PDF. | [optional] | 29 | | **disallow_modify** | **Boolean** | Disallow modification of this PDF. | [optional] | 30 | | **debug** | **Boolean** | Enable Prince debug mode. | [optional] | 31 | | **input** | **String** | Specify the input format, defaults to html. | [optional] | 32 | | **version** | **String** | Deprecated, use the appropriate `pipeline` version. Specify a specific verison of PrinceXML to use. | [optional] | 33 | | **javascript** | **Boolean** | Enable PrinceXML JavaScript. DocRaptor JavaScript parsing is also available elsewhere. | [optional] | 34 | | **css_dpi** | **Integer** | Set the DPI when rendering CSS. Defaults to 96 but can be set with Prince 9.0 and up. | [optional] | 35 | | **profile** | **String** | In Prince 9.0 and up you can set the PDF profile. | [optional] | 36 | | **pdf_title** | **String** | Specify the PDF title, part of the document's metadata. | [optional] | 37 | | **iframes** | **Boolean** | Enable loading of iframes. | [optional] | 38 | | **page_margin** | **String** | Specify the page margin distance. | [optional] | 39 | | **pdf_forms** | **Boolean** | Make form fields editable by default. | [optional] | 40 | 41 | ## Example 42 | 43 | ```ruby 44 | require 'docraptor' 45 | 46 | instance = DocRaptor::PrinceOptions.new( 47 | baseurl: null, 48 | no_xinclude: null, 49 | no_network: null, 50 | no_parallel_downloads: null, 51 | http_user: null, 52 | http_password: null, 53 | http_proxy: null, 54 | http_timeout: null, 55 | insecure: null, 56 | media: null, 57 | no_author_style: null, 58 | no_default_style: null, 59 | no_embed_fonts: null, 60 | no_subset_fonts: null, 61 | no_compress: null, 62 | encrypt: null, 63 | key_bits: null, 64 | user_password: null, 65 | owner_password: null, 66 | disallow_print: null, 67 | disallow_copy: null, 68 | disallow_annotate: null, 69 | disallow_modify: null, 70 | debug: null, 71 | input: null, 72 | version: null, 73 | javascript: null, 74 | css_dpi: null, 75 | profile: null, 76 | pdf_title: null, 77 | iframes: null, 78 | page_margin: null, 79 | pdf_forms: null 80 | ) 81 | ``` 82 | 83 | -------------------------------------------------------------------------------- /.review/generated_files/spec/api/doc_api_spec.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | require 'spec_helper' 14 | require 'json' 15 | 16 | # Unit tests for DocRaptor::DocApi 17 | # Automatically generated by openapi-generator (https://openapi-generator.tech) 18 | # Please update as you see appropriate 19 | describe 'DocApi' do 20 | before do 21 | # run before each test 22 | @api_instance = DocRaptor::DocApi.new 23 | end 24 | 25 | after do 26 | # run after each test 27 | end 28 | 29 | describe 'test an instance of DocApi' do 30 | it 'should create an instance of DocApi' do 31 | expect(@api_instance).to be_instance_of(DocRaptor::DocApi) 32 | end 33 | end 34 | 35 | # unit tests for create_async_doc 36 | # Creates a document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. 37 | # @param doc 38 | # @param [Hash] opts the optional parameters 39 | # @return [AsyncDoc] 40 | describe 'create_async_doc test' do 41 | it 'should work' do 42 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 43 | end 44 | end 45 | 46 | # unit tests for create_doc 47 | # Creates a document synchronously. 48 | # @param doc 49 | # @param [Hash] opts the optional parameters 50 | # @return [String] 51 | describe 'create_doc test' do 52 | it 'should work' do 53 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 54 | end 55 | end 56 | 57 | # unit tests for create_hosted_async_doc 58 | # Creates a hosted document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document. 59 | # @param doc 60 | # @param [Hash] opts the optional parameters 61 | # @return [AsyncDoc] 62 | describe 'create_hosted_async_doc test' do 63 | it 'should work' do 64 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 65 | end 66 | end 67 | 68 | # unit tests for create_hosted_doc 69 | # Creates a hosted document synchronously. 70 | # @param doc The document to be created. 71 | # @param [Hash] opts the optional parameters 72 | # @return [DocStatus] 73 | describe 'create_hosted_doc test' do 74 | it 'should work' do 75 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 76 | end 77 | end 78 | 79 | # unit tests for expire 80 | # Expires a previously created hosted doc. 81 | # @param id The download_id returned from status request or hosted document response. 82 | # @param [Hash] opts the optional parameters 83 | # @return [nil] 84 | describe 'expire test' do 85 | it 'should work' do 86 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 87 | end 88 | end 89 | 90 | # unit tests for get_async_doc 91 | # Downloads a finished document. 92 | # @param id The download_id returned from an async status request or callback. 93 | # @param [Hash] opts the optional parameters 94 | # @return [String] 95 | describe 'get_async_doc test' do 96 | it 'should work' do 97 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 98 | end 99 | end 100 | 101 | # unit tests for get_async_doc_status 102 | # Check on the status of an asynchronously created document. 103 | # @param id The status_id returned when creating an asynchronous document. 104 | # @param [Hash] opts the optional parameters 105 | # @return [DocStatus] 106 | describe 'get_async_doc_status test' do 107 | it 'should work' do 108 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 109 | end 110 | end 111 | 112 | end 113 | -------------------------------------------------------------------------------- /.review/generated_files/spec/models/doc_spec.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | require 'spec_helper' 14 | require 'json' 15 | require 'date' 16 | 17 | # Unit tests for DocRaptor::Doc 18 | # Automatically generated by openapi-generator (https://openapi-generator.tech) 19 | # Please update as you see appropriate 20 | describe DocRaptor::Doc do 21 | let(:instance) { DocRaptor::Doc.new } 22 | 23 | describe 'test an instance of Doc' do 24 | it 'should create an instance of Doc' do 25 | expect(instance).to be_instance_of(DocRaptor::Doc) 26 | end 27 | end 28 | describe 'test attribute "name"' do 29 | it 'should work' do 30 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 31 | end 32 | end 33 | 34 | describe 'test attribute "document_type"' do 35 | it 'should work' do 36 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 37 | # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["pdf", "xls", "xlsx"]) 38 | # validator.allowable_values.each do |value| 39 | # expect { instance.document_type = value }.not_to raise_error 40 | # end 41 | end 42 | end 43 | 44 | describe 'test attribute "document_content"' do 45 | it 'should work' do 46 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 47 | end 48 | end 49 | 50 | describe 'test attribute "document_url"' do 51 | it 'should work' do 52 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 53 | end 54 | end 55 | 56 | describe 'test attribute "test"' do 57 | it 'should work' do 58 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 59 | end 60 | end 61 | 62 | describe 'test attribute "pipeline"' do 63 | it 'should work' do 64 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 65 | end 66 | end 67 | 68 | describe 'test attribute "strict"' do 69 | it 'should work' do 70 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 71 | # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["none", "html"]) 72 | # validator.allowable_values.each do |value| 73 | # expect { instance.strict = value }.not_to raise_error 74 | # end 75 | end 76 | end 77 | 78 | describe 'test attribute "ignore_resource_errors"' do 79 | it 'should work' do 80 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 81 | end 82 | end 83 | 84 | describe 'test attribute "ignore_console_messages"' do 85 | it 'should work' do 86 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 87 | end 88 | end 89 | 90 | describe 'test attribute "tag"' do 91 | it 'should work' do 92 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 93 | end 94 | end 95 | 96 | describe 'test attribute "help"' do 97 | it 'should work' do 98 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 99 | end 100 | end 101 | 102 | describe 'test attribute "javascript"' do 103 | it 'should work' do 104 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 105 | end 106 | end 107 | 108 | describe 'test attribute "referrer"' do 109 | it 'should work' do 110 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 111 | end 112 | end 113 | 114 | describe 'test attribute "callback_url"' do 115 | it 'should work' do 116 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 117 | end 118 | end 119 | 120 | describe 'test attribute "hosted_download_limit"' do 121 | it 'should work' do 122 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 123 | end 124 | end 125 | 126 | describe 'test attribute "hosted_expires_at"' do 127 | it 'should work' do 128 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 129 | end 130 | end 131 | 132 | describe 'test attribute "prince_options"' do 133 | it 'should work' do 134 | # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/ 135 | end 136 | end 137 | 138 | end 139 | -------------------------------------------------------------------------------- /.review/generated_files/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | # load the gem 14 | require 'docraptor' 15 | 16 | # The following was generated by the `rspec --init` command. Conventionally, all 17 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 18 | # The generated `.rspec` file contains `--require spec_helper` which will cause 19 | # this file to always be loaded, without a need to explicitly require it in any 20 | # files. 21 | # 22 | # Given that it is always loaded, you are encouraged to keep this file as 23 | # light-weight as possible. Requiring heavyweight dependencies from this file 24 | # will add to the boot time of your test suite on EVERY test run, even for an 25 | # individual file that may not need all of that loaded. Instead, consider making 26 | # a separate helper file that requires the additional dependencies and performs 27 | # the additional setup, and require it from the spec files that actually need 28 | # it. 29 | # 30 | # The `.rspec` file also contains a few flags that are not defaults but that 31 | # users commonly want. 32 | # 33 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 34 | RSpec.configure do |config| 35 | # rspec-expectations config goes here. You can use an alternate 36 | # assertion/expectation library such as wrong or the stdlib/minitest 37 | # assertions if you prefer. 38 | config.expect_with :rspec do |expectations| 39 | # This option will default to `true` in RSpec 4. It makes the `description` 40 | # and `failure_message` of custom matchers include text for helper methods 41 | # defined using `chain`, e.g.: 42 | # be_bigger_than(2).and_smaller_than(4).description 43 | # # => "be bigger than 2 and smaller than 4" 44 | # ...rather than: 45 | # # => "be bigger than 2" 46 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 47 | end 48 | 49 | # rspec-mocks config goes here. You can use an alternate test double 50 | # library (such as bogus or mocha) by changing the `mock_with` option here. 51 | config.mock_with :rspec do |mocks| 52 | # Prevents you from mocking or stubbing a method that does not exist on 53 | # a real object. This is generally recommended, and will default to 54 | # `true` in RSpec 4. 55 | mocks.verify_partial_doubles = true 56 | end 57 | 58 | # The settings below are suggested to provide a good initial experience 59 | # with RSpec, but feel free to customize to your heart's content. 60 | =begin 61 | # These two settings work together to allow you to limit a spec run 62 | # to individual examples or groups you care about by tagging them with 63 | # `:focus` metadata. When nothing is tagged with `:focus`, all examples 64 | # get run. 65 | config.filter_run :focus 66 | config.run_all_when_everything_filtered = true 67 | 68 | # Allows RSpec to persist some state between runs in order to support 69 | # the `--only-failures` and `--next-failure` CLI options. We recommend 70 | # you configure your source control system to ignore this file. 71 | config.example_status_persistence_file_path = "spec/examples.txt" 72 | 73 | # Limits the available syntax to the non-monkey patched syntax that is 74 | # recommended. For more details, see: 75 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 76 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 77 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 78 | config.disable_monkey_patching! 79 | 80 | # This setting enables warnings. It's recommended, but in some cases may 81 | # be too noisy due to issues in dependencies. 82 | config.warnings = true 83 | 84 | # Many RSpec users commonly either run the entire suite or an individual 85 | # file, and it's useful to allow more verbose output when running an 86 | # individual spec file. 87 | if config.files_to_run.one? 88 | # Use the documentation formatter for detailed output, 89 | # unless a formatter has already been configured 90 | # (e.g. via a command-line flag). 91 | config.default_formatter = 'doc' 92 | end 93 | 94 | # Print the 10 slowest examples and example groups at the 95 | # end of the spec run, to help surface which specs are running 96 | # particularly slow. 97 | config.profile_examples = 10 98 | 99 | # Run specs in random order to surface order dependencies. If you find an 100 | # order dependency and want to debug it, you can fix the order by providing 101 | # the seed, which is printed after each run. 102 | # --seed 1234 103 | config.order = :random 104 | 105 | # Seed global randomization in this process using the `--seed` CLI option. 106 | # Setting this allows you to use `--seed` to deterministically reproduce 107 | # test failures related to randomization by passing the same `--seed` value 108 | # as the one that triggered the failure. 109 | Kernel.srand config.seed 110 | =end 111 | end 112 | -------------------------------------------------------------------------------- /lib/docraptor/models/async_doc.rb: -------------------------------------------------------------------------------- 1 | =begin 2 | #DocRaptor 3 | 4 | #A native client library for the DocRaptor HTML to PDF/XLS service. 5 | 6 | The version of the OpenAPI document: 2.0.0 7 | 8 | Generated by: https://openapi-generator.tech 9 | OpenAPI Generator version: 6.6.0 10 | 11 | =end 12 | 13 | require 'date' 14 | require 'time' 15 | 16 | module DocRaptor 17 | class AsyncDoc 18 | # The identifier used to get the status of the document using the status API. 19 | attr_accessor :status_id 20 | 21 | # Attribute mapping from ruby-style variable name to JSON key. 22 | def self.attribute_map 23 | { 24 | :'status_id' => :'status_id' 25 | } 26 | end 27 | 28 | # Returns all the JSON keys this model knows about 29 | def self.acceptable_attributes 30 | attribute_map.values 31 | end 32 | 33 | # Attribute type mapping. 34 | def self.openapi_types 35 | { 36 | :'status_id' => :'String' 37 | } 38 | end 39 | 40 | # List of attributes with nullable: true 41 | def self.openapi_nullable 42 | Set.new([ 43 | ]) 44 | end 45 | 46 | # Initializes the object 47 | # @param [Hash] attributes Model attributes in the form of hash 48 | def initialize(attributes = {}) 49 | if (!attributes.is_a?(Hash)) 50 | fail ArgumentError, "The input argument (attributes) must be a hash in `DocRaptor::AsyncDoc` initialize method" 51 | end 52 | 53 | # check to see if the attribute exists and convert string to symbol for hash key 54 | attributes = attributes.each_with_object({}) { |(k, v), h| 55 | if (!self.class.attribute_map.key?(k.to_sym)) 56 | fail ArgumentError, "`#{k}` is not a valid attribute in `DocRaptor::AsyncDoc`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect 57 | end 58 | h[k.to_sym] = v 59 | } 60 | 61 | if attributes.key?(:'status_id') 62 | self.status_id = attributes[:'status_id'] 63 | end 64 | end 65 | 66 | # Show invalid properties with the reasons. Usually used together with valid? 67 | # @return Array for valid properties with the reasons 68 | def list_invalid_properties 69 | invalid_properties = Array.new 70 | invalid_properties 71 | end 72 | 73 | # Check to see if the all the properties in the model are valid 74 | # @return true if the model is valid 75 | def valid? 76 | true 77 | end 78 | 79 | # Checks equality by comparing each attribute. 80 | # @param [Object] Object to be compared 81 | def ==(o) 82 | return true if self.equal?(o) 83 | self.class == o.class && 84 | status_id == o.status_id 85 | end 86 | 87 | # @see the `==` method 88 | # @param [Object] Object to be compared 89 | def eql?(o) 90 | self == o 91 | end 92 | 93 | # Calculates hash code according to all attributes. 94 | # @return [Integer] Hash code 95 | def hash 96 | [status_id].hash 97 | end 98 | 99 | # Builds the object from hash 100 | # @param [Hash] attributes Model attributes in the form of hash 101 | # @return [Object] Returns the model itself 102 | def self.build_from_hash(attributes) 103 | new.build_from_hash(attributes) 104 | end 105 | 106 | # Builds the object from hash 107 | # @param [Hash] attributes Model attributes in the form of hash 108 | # @return [Object] Returns the model itself 109 | def build_from_hash(attributes) 110 | return nil unless attributes.is_a?(Hash) 111 | attributes = attributes.transform_keys(&:to_sym) 112 | self.class.openapi_types.each_pair do |key, type| 113 | if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) 114 | self.send("#{key}=", nil) 115 | elsif type =~ /\AArray<(.*)>/i 116 | # check to ensure the input is an array given that the attribute 117 | # is documented as an array but the input is not 118 | if attributes[self.class.attribute_map[key]].is_a?(Array) 119 | self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) 120 | end 121 | elsif !attributes[self.class.attribute_map[key]].nil? 122 | self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) 123 | end 124 | end 125 | 126 | self 127 | end 128 | 129 | # Deserializes the data based on type 130 | # @param string type Data type 131 | # @param string value Value to be deserialized 132 | # @return [Object] Deserialized data 133 | def _deserialize(type, value) 134 | case type.to_sym 135 | when :Time 136 | Time.parse(value) 137 | when :Date 138 | Date.parse(value) 139 | when :String 140 | value.to_s 141 | when :Integer 142 | value.to_i 143 | when :Float 144 | value.to_f 145 | when :Boolean 146 | if value.to_s =~ /\A(true|t|yes|y|1)\z/i 147 | true 148 | else 149 | false 150 | end 151 | when :Object 152 | # generic object (usually a Hash), return directly 153 | value 154 | when /\AArray<(?