Skip to content

Commit d0c86cb

Browse files
authored
Merge pull request #95 from aspose-pdf-cloud/develop
update to 25.9
2 parents cc6695a + 6761a9b commit d0c86cb

File tree

7 files changed

+154
-12
lines changed

7 files changed

+154
-12
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ XLS, XLSX, PPTX, DOC, DOCX, MobiXML, JPEG, EMF, PNG, BMP, GIF, TIFF, Text
2929
## Read PDF Formats
3030
MHT, PCL, PS, XSLFO, MD
3131

32-
## Enhancements in Version 25.8
33-
- Implement document page resize functionality using the Pdf.Cloud API library.
32+
## Enhancements in Version 25.9
33+
- Implement PDF document page crop functionality using the Pdf.Cloud API library.
3434
- A new version of Aspose.PDF Cloud was prepared using the latest version of Aspose.PDF for .NET.
3535

36-
## Bugs fixed in Version 25.8
37-
- Implement delete watermark from PDF document using the Pdf.Cloud API library.
38-
3936
## Installation
4037

4138
### Build a gem
@@ -49,15 +46,15 @@ gem build aspose_pdf_cloud.gemspec
4946
Then either install the gem locally:
5047

5148
```shell
52-
gem install ./aspose_pdf_cloud-25.8.0.gem
49+
gem install ./aspose_pdf_cloud-25.9.0.gem
5350
```
54-
(for development, run `gem install --dev ./aspose_pdf_cloud-25.8.0.gem` to install the development dependencies)
51+
(for development, run `gem install --dev ./aspose_pdf_cloud-25.9.0.gem` to install the development dependencies)
5552

5653
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
5754

5855
Finally add this to the Gemfile:
5956

60-
gem 'aspose_pdf_cloud', '~> 25.8.0'
57+
gem 'aspose_pdf_cloud', '~> 25.9.0'
6158

6259
### Install from Git
6360

Rakefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
require 'bundler/gem_tasks'
22
require 'rake/testtask'
33
require 'ci/reporter/rake/minitest'
4+
45
ENV['CI_REPORTS'] = 'test/reports'
6+
if ENV['FARADAY_TIMEOUT'].to_i.zero?
7+
ENV['FARADAY_TIMEOUT'] = '1200'
8+
end
9+
510
Rake::TestTask.new do |t|
611
t.test_files = FileList['test/*.rb']
12+
t.verbose = true
13+
end
14+
15+
task :setup_test_environment do
16+
require_relative 'test/faraday_config' if File.exist?('test/faraday_config.rb')
717
end
8-
task test: 'ci:setup:minitest'
18+
19+
task test: [:setup_test_environment, 'ci:setup:minitest']
20+
921
task default: :test

docs/PdfApi.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Method | HTTP request | Description
212212
[**post_document_image_stamps**](PdfApi.md#post_document_image_stamps) | **POST** /pdf/\{name}/stamps/image | Add document pages image stamps.
213213
[**post_document_image_stamps_page_specified**](PdfApi.md#post_document_image_stamps_page_specified) | **POST** /pdf/\{name}/stamps/image/pagespecified | Add document image stamps to specified pages.
214214
[**post_document_page_number_stamps**](PdfApi.md#post_document_page_number_stamps) | **POST** /pdf/\{name}/stamps/pagenumber | Add document page number stamps.
215+
[**post_document_pages_crop**](PdfApi.md#post_document_pages_crop) | **POST** /pdf/\{name}/crop | Crop PDF document pages.
215216
[**post_document_pages_resize**](PdfApi.md#post_document_pages_resize) | **POST** /pdf/\{name}/resize | Rsize PDF document.
216217
[**post_document_pages_rotate**](PdfApi.md#post_document_pages_rotate) | **POST** /pdf/\{name}/rotate | Rotate PDF document.
217218
[**post_document_text_footer**](PdfApi.md#post_document_text_footer) | **POST** /pdf/\{name}/footer/text | Add document text footer.
@@ -5662,6 +5663,33 @@ Name | Type | Description | Notes
56625663

56635664

56645665

5666+
# **post_document_pages_crop**
5667+
> AsposeResponse post_document_pages_crop(name, pages, rect, opts)
5668+
5669+
Crop PDF document pages.
5670+
5671+
### Parameters
5672+
5673+
Name | Type | Description | Notes
5674+
------------- | ------------- | ------------- | -------------
5675+
**name** | **String**| The document name. |
5676+
**pages** | **String**| Comma separated list of pages and page ranges. (Example: 1,3-5,8) |
5677+
**rect** | [**Rectangle**](Rectangle.md)| Rectangle of document area. |
5678+
**storage** | **String**| The document storage. | [optional]
5679+
**folder** | **String**| The document folder. | [optional]
5680+
**password** | **String**| Base64 encoded password. | [optional]
5681+
5682+
### Return type
5683+
5684+
[**AsposeResponse**](AsposeResponse.md)
5685+
5686+
### HTTP request headers
5687+
5688+
- **Content-Type**: application/json
5689+
- **Accept**: application/json
5690+
5691+
5692+
56655693
# **post_document_pages_resize**
56665694
> AsposeResponse post_document_pages_resize(name, height, width, pages, opts)
56675695

lib/aspose_pdf_cloud/api/pdf_api.rb

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16351,6 +16351,93 @@ def post_document_page_number_stamps_with_http_info(name, stamp, opts = {})
1635116351
return data, status_code, headers
1635216352
end
1635316353

16354+
# Crop PDF document pages.
16355+
#
16356+
# @param name The document name.
16357+
# @param pages Comma separated list of pages and page ranges. (Example: 1,3-5,8)
16358+
# @param rect Rectangle of document area.
16359+
# @param [Hash] opts the optional parameters
16360+
# @option opts [String] :storage The document storage.
16361+
# @option opts [String] :folder The document folder.
16362+
# @option opts [String] :password Base64 encoded password.
16363+
# @return [AsposeResponse]
16364+
def post_document_pages_crop(name, pages, rect, opts = {})
16365+
@api_client.request_token_if_needed
16366+
data, _status_code, _headers = post_document_pages_crop_with_http_info(name, pages, rect, opts)
16367+
rescue ApiError => error
16368+
if error.code == 401
16369+
@api_client.request_token_if_needed
16370+
data, _status_code, _headers = post_document_pages_crop_with_http_info(name, pages, rect, opts)
16371+
else
16372+
raise
16373+
end
16374+
return data
16375+
end
16376+
16377+
# Crop PDF document pages.
16378+
#
16379+
# @param name The document name.
16380+
# @param pages Comma separated list of pages and page ranges. (Example: 1,3-5,8)
16381+
# @param rect Rectangle of document area.
16382+
# @param [Hash] opts the optional parameters
16383+
# @option opts [String] :storage The document storage.
16384+
# @option opts [String] :folder The document folder.
16385+
# @option opts [String] :password Base64 encoded password.
16386+
# @return [Array<(AsposeResponse, Fixnum, Hash)>] AsposeResponse data, response status code and response headers
16387+
def post_document_pages_crop_with_http_info(name, pages, rect, opts = {})
16388+
if @api_client.config.debugging
16389+
@api_client.config.logger.debug "Calling API: PdfApi.post_document_pages_crop ..."
16390+
end
16391+
# verify the required parameter 'name' is set
16392+
if @api_client.config.client_side_validation && name.nil?
16393+
fail ArgumentError, "Missing the required parameter 'name' when calling PdfApi.post_document_pages_crop"
16394+
end
16395+
# verify the required parameter 'pages' is set
16396+
if @api_client.config.client_side_validation && pages.nil?
16397+
fail ArgumentError, "Missing the required parameter 'pages' when calling PdfApi.post_document_pages_crop"
16398+
end
16399+
# verify the required parameter 'rect' is set
16400+
if @api_client.config.client_side_validation && rect.nil?
16401+
fail ArgumentError, "Missing the required parameter 'rect' when calling PdfApi.post_document_pages_crop"
16402+
end
16403+
# resource path
16404+
local_var_path = "/pdf/{name}/crop".sub('{' + 'name' + '}', name.to_s)
16405+
16406+
# query parameters
16407+
query_params = {}
16408+
query_params[:'pages'] = pages
16409+
query_params[:'storage'] = opts[:'storage'] if !opts[:'storage'].nil?
16410+
query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?
16411+
query_params[:'password'] = opts[:'password'] if !opts[:'password'].nil?
16412+
16413+
# header parameters
16414+
header_params = {}
16415+
# HTTP header 'Accept' (if needed)
16416+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
16417+
# HTTP header 'Content-Type'
16418+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
16419+
16420+
# form parameters
16421+
form_params = {}
16422+
# Fix header in file
16423+
post_body = nil
16424+
16425+
# http body (model)
16426+
post_body = @api_client.object_to_http_body(rect)
16427+
auth_names = ['JWT']
16428+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
16429+
:header_params => header_params,
16430+
:query_params => query_params,
16431+
:form_params => form_params,
16432+
:body => post_body,
16433+
:auth_names => auth_names,
16434+
:return_type => 'AsposeResponse')
16435+
if @api_client.config.debugging
16436+
@api_client.config.logger.debug "API called: PdfApi#post_document_pages_crop\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
16437+
end
16438+
return data, status_code, headers
16439+
end
16440+
1635416441
# Rsize PDF document.
1635516442
#
1635616443
# @param name The document name.

lib/aspose_pdf_cloud/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
=end
2121

2222
module AsposePdfCloud
23-
VERSION = "25.8.0"
23+
VERSION = "25.9.0"
2424
end

test/faraday_config.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'faraday'
2+
Faraday.default_connection_options = Faraday::ConnectionOptions.new(
3+
request: {
4+
timeout: ENV['FARADAY_TIMEOUT'].to_i
5+
}
6+
)

test/pdf_tests.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6784,7 +6784,7 @@ def test_post_document_pages_rotate
67846784
folder: @temp_folder
67856785
}
67866786
response = @pdf_api.post_document_pages_rotate(file_name, Rotation::ON90, '2-3', opts)
6787-
assert(response, 'Failed to organize document.')
6787+
assert(response, 'Failed to rotate document.')
67886788
end
67896789

67906790
def test_post_document_pages_resize
@@ -6794,6 +6794,18 @@ def test_post_document_pages_resize
67946794
folder: @temp_folder
67956795
}
67966796
response = @pdf_api.post_document_pages_resize(file_name, 100, 200, '2-3', opts)
6797-
assert(response, 'Failed to organize document.')
6797+
assert(response, 'Failed to resize document.')
6798+
end
6799+
6800+
def test_post_document_pages_crop
6801+
file_name = '4pages.pdf'
6802+
upload_file(file_name)
6803+
opts = {
6804+
folder: @temp_folder
6805+
}
6806+
6807+
rectangle = Rectangle.new({ LLX: 0, LLY: 0, URX: 800, URY: 400 })
6808+
response = @pdf_api.post_document_pages_crop(file_name, '2-3', rectangle, opts)
6809+
assert(response, 'Failed to crop document.')
67986810
end
67996811
end

0 commit comments

Comments
 (0)