aspose_pdf_cloud 18.3.0 → 18.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,5 +20,5 @@ SOFTWARE.
20
20
  =end
21
21
 
22
22
  module AsposePdfCloud
23
- VERSION = "18.3.0"
23
+ VERSION = "18.4.0"
24
24
  end
@@ -21,23 +21,17 @@ SOFTWARE.
21
21
 
22
22
  require 'minitest/autorun'
23
23
  require 'minitest/unit'
24
- require 'aspose_storage_cloud'
25
24
 
26
25
  require_relative '../lib/aspose_pdf_cloud'
27
26
 
28
27
  class PdfTests < Minitest::Test
29
28
  include MiniTest::Assertions
30
29
  include AsposePdfCloud
31
- include AsposeStorageCloud
32
30
 
33
31
 
34
32
  def setup
35
33
  # Get App key and App SID from https://cloud.aspose.com
36
- AsposeApp.app_key_and_sid('app_key', 'app_sid')
37
-
38
- @pdf_api = PdfApi.new
39
- @storage_api = StorageApi.new
40
- @storage_api.api_client.host = 'http://api-dev.aspose.cloud/v1.1'
34
+ @pdf_api = PdfApi.new('app_key', 'app_sid')
41
35
 
42
36
  @temp_folder = 'TempPdfCloud'
43
37
  @test_data_folder = '../test_data/'
@@ -53,7 +47,7 @@ class PdfTests < Minitest::Test
53
47
 
54
48
 
55
49
  def upload_file(file_name)
56
- response = @storage_api.put_create(@temp_folder + '/' + file_name, File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
50
+ response = @pdf_api.put_create(@temp_folder + '/' + file_name, File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
57
51
  assert(response, "Failed to upload #{file_name} file.")
58
52
  end
59
53
 
@@ -84,7 +78,7 @@ class PdfTests < Minitest::Test
84
78
  upload_file(append_file_name)
85
79
 
86
80
  opts = {
87
- :append_file => append_file_name,
81
+ :append_file => @temp_folder + '/' + append_file_name,
88
82
  :startPage => 2,
89
83
  :endPage => 4,
90
84
  :folder => @temp_folder
@@ -103,7 +97,7 @@ class PdfTests < Minitest::Test
103
97
  upload_file(append_file_name)
104
98
 
105
99
  append_document = AppendDocument.new
106
- append_document.document = append_file_name
100
+ append_document.document = @temp_folder + '/' + append_file_name
107
101
  append_document.start_page = 2
108
102
  append_document.end_page = 4
109
103
 
@@ -431,6 +425,34 @@ class PdfTests < Minitest::Test
431
425
  end
432
426
 
433
427
 
428
+ def test_delete_field
429
+ file_name = 'PdfWithAcroForm.pdf'
430
+ upload_file(file_name)
431
+
432
+ field_name = 'textField'
433
+
434
+ opts = {
435
+ :folder => @temp_folder
436
+ }
437
+
438
+ response = @pdf_api.delete_field(file_name, field_name, opts)
439
+ assert(response, 'Failed to delete fields.')
440
+ end
441
+
442
+
443
+ def test_put_fields_flatten
444
+ file_name = 'PdfWithAcroForm.pdf'
445
+ upload_file(file_name)
446
+
447
+ opts = {
448
+ :folder => @temp_folder
449
+ }
450
+
451
+ response = @pdf_api.put_fields_flatten(file_name, opts)
452
+ assert(response, 'Failed to make fields flatten.')
453
+ end
454
+
455
+
434
456
  # Fragments And Segments Tests
435
457
 
436
458
  def test_get_fragment
@@ -1060,6 +1082,47 @@ class PdfTests < Minitest::Test
1060
1082
  end
1061
1083
 
1062
1084
 
1085
+ def test_get_verify_signature
1086
+ file_name = 'BlankWithSignature.pdf'
1087
+ upload_file(file_name)
1088
+
1089
+ signature_file_name = 'test1234.pfx'
1090
+ upload_file(signature_file_name)
1091
+
1092
+ rectangle = Rectangle.new
1093
+ rectangle.x = 100
1094
+ rectangle.y = 100
1095
+ rectangle.width = 400
1096
+ rectangle.height = 100
1097
+
1098
+ signature = Signature.new
1099
+ signature.authority = 'Sergey Smal'
1100
+ signature.contact = 'test@mail.ru'
1101
+ signature.date = '08/01/2012 12:15:00.000 PM'
1102
+ signature.form_field_name = 'Signature1'
1103
+ signature.location = 'Ukraine'
1104
+ signature.password = 'test1234'
1105
+ signature.rectangle = rectangle
1106
+ signature.signature_path = @temp_folder + '/' + signature_file_name
1107
+ signature.signature_type = SignatureType::PKCS_7
1108
+ signature.visible = true
1109
+
1110
+ opts = {
1111
+ :signature => signature,
1112
+ :folder => @temp_folder
1113
+ }
1114
+
1115
+ response_sign = @pdf_api.post_sign_document(file_name, opts)
1116
+ assert(response_sign, 'Failed to sign document.')
1117
+
1118
+ opts = {
1119
+ :folder => @temp_folder
1120
+ }
1121
+ response = @pdf_api.get_verify_signature(file_name, signature.form_field_name, opts)
1122
+ assert(response, 'Failed to verify signature.')
1123
+ end
1124
+
1125
+
1063
1126
  # Text Items Tests
1064
1127
 
1065
1128
  def test_get_page_text_items
@@ -1333,7 +1396,7 @@ class PdfTests < Minitest::Test
1333
1396
  opts = {
1334
1397
  :folder => @temp_folder
1335
1398
  }
1336
- response = @pdf_api.put_pdf_in_storage_to_doc(file_name, res_file, opts)
1399
+ response = @pdf_api.put_pdf_in_storage_to_doc(file_name, @temp_folder + '/' + res_file, opts)
1337
1400
  assert(response, 'Filed to convert PDF to DOC.')
1338
1401
  end
1339
1402
 
@@ -1370,7 +1433,7 @@ class PdfTests < Minitest::Test
1370
1433
  opts = {
1371
1434
  :folder => @temp_folder
1372
1435
  }
1373
- response = @pdf_api.put_pdf_in_storage_to_pdf_a(file_name, res_file, PdfAType::PDFA1_A, opts)
1436
+ response = @pdf_api.put_pdf_in_storage_to_pdf_a(file_name, @temp_folder + '/' + res_file, PdfAType::PDFA1_A, opts)
1374
1437
  assert(response, 'Filed to convert PDF to PDFA.')
1375
1438
  end
1376
1439
 
@@ -1406,7 +1469,7 @@ class PdfTests < Minitest::Test
1406
1469
  opts = {
1407
1470
  :folder => @temp_folder
1408
1471
  }
1409
- response = @pdf_api.put_pdf_in_storage_to_tiff(file_name, res_file, opts)
1472
+ response = @pdf_api.put_pdf_in_storage_to_tiff(file_name, @temp_folder + '/' + res_file, opts)
1410
1473
  assert(response, 'Filed to convert PDF to Tiff.')
1411
1474
  end
1412
1475
 
@@ -1442,7 +1505,7 @@ class PdfTests < Minitest::Test
1442
1505
  opts = {
1443
1506
  :folder => @temp_folder
1444
1507
  }
1445
- response = @pdf_api.put_pdf_in_storage_to_svg(file_name, res_file, opts)
1508
+ response = @pdf_api.put_pdf_in_storage_to_svg(file_name, @temp_folder + '/' + res_file, opts)
1446
1509
  assert(response, 'Filed to convert PDF to SVG.')
1447
1510
  end
1448
1511
 
@@ -1478,7 +1541,7 @@ class PdfTests < Minitest::Test
1478
1541
  opts = {
1479
1542
  :folder => @temp_folder
1480
1543
  }
1481
- response = @pdf_api.put_pdf_in_storage_to_xps(file_name, res_file, opts)
1544
+ response = @pdf_api.put_pdf_in_storage_to_xps(file_name, @temp_folder + '/' + res_file, opts)
1482
1545
  assert(response, 'Filed to convert PDF to XPS.')
1483
1546
  end
1484
1547
 
@@ -1514,7 +1577,7 @@ class PdfTests < Minitest::Test
1514
1577
  opts = {
1515
1578
  :folder => @temp_folder
1516
1579
  }
1517
- response = @pdf_api.put_pdf_in_storage_to_xls(file_name, res_file, opts)
1580
+ response = @pdf_api.put_pdf_in_storage_to_xls(file_name, @temp_folder + '/' + res_file, opts)
1518
1581
  assert(response, 'Filed to convert PDF to XLS.')
1519
1582
  end
1520
1583
 
@@ -1529,5 +1592,300 @@ class PdfTests < Minitest::Test
1529
1592
  response = @pdf_api.put_pdf_in_request_to_xls(@temp_folder + '/' + res_file, opts)
1530
1593
  assert(response, 'Filed to convert PDF to XLS.')
1531
1594
  end
1595
+
1596
+ def test_get_pdf_in_storage_to_html
1597
+ file_name = '4pages.pdf'
1598
+ upload_file(file_name)
1599
+
1600
+ opts = {
1601
+ :folder => @temp_folder
1602
+ }
1603
+
1604
+ response = @pdf_api.get_pdf_in_storage_to_html(file_name, opts)
1605
+ assert(response, 'Filed to convert PDF to HTML.')
1606
+ end
1607
+
1608
+ def test_put_pdf_in_storage_to_html
1609
+ file_name = '4pages.pdf'
1610
+ upload_file(file_name)
1611
+ res_file = 'result.html'
1612
+
1613
+ opts = {
1614
+ :folder => @temp_folder
1615
+ }
1616
+ response = @pdf_api.put_pdf_in_storage_to_html(file_name, @temp_folder + '/' + res_file, opts)
1617
+ assert(response, 'Filed to convert PDF to HTML.')
1618
+ end
1619
+
1620
+ def test_put_pdf_in_request_to_html
1621
+ file_name = '4pages.pdf'
1622
+
1623
+ res_file = 'result.html'
1624
+
1625
+ opts = {
1626
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1627
+ }
1628
+ response = @pdf_api.put_pdf_in_request_to_html(@temp_folder + '/' + res_file, opts)
1629
+ assert(response, 'Filed to convert PDF to HTML.')
1630
+ end
1631
+
1632
+ def test_get_pdf_in_storage_to_epub
1633
+ file_name = '4pages.pdf'
1634
+ upload_file(file_name)
1635
+
1636
+ opts = {
1637
+ :folder => @temp_folder
1638
+ }
1639
+
1640
+ response = @pdf_api.get_pdf_in_storage_to_epub(file_name, opts)
1641
+ assert(response, 'Filed to convert PDF to EPUB.')
1642
+ end
1643
+
1644
+ def test_put_pdf_in_storage_to_epub
1645
+ file_name = '4pages.pdf'
1646
+ upload_file(file_name)
1647
+ res_file = 'result.epub'
1648
+
1649
+ opts = {
1650
+ :folder => @temp_folder
1651
+ }
1652
+ response = @pdf_api.put_pdf_in_storage_to_epub(file_name, @temp_folder + '/' + res_file, opts)
1653
+ assert(response, 'Filed to convert PDF to EPUB.')
1654
+ end
1655
+
1656
+ def test_put_pdf_in_request_to_epub
1657
+ file_name = '4pages.pdf'
1658
+
1659
+ res_file = 'result.epub'
1660
+
1661
+ opts = {
1662
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1663
+ }
1664
+ response = @pdf_api.put_pdf_in_request_to_epub(@temp_folder + '/' + res_file, opts)
1665
+ assert(response, 'Filed to convert PDF to EPUB.')
1666
+ end
1667
+
1668
+ def test_get_pdf_in_storage_to_pptx
1669
+ file_name = '4pages.pdf'
1670
+ upload_file(file_name)
1671
+
1672
+ opts = {
1673
+ :folder => @temp_folder
1674
+ }
1675
+
1676
+ response = @pdf_api.get_pdf_in_storage_to_pptx(file_name, opts)
1677
+ assert(response, 'Filed to convert PDF to PPTX.')
1678
+ end
1679
+
1680
+ def test_put_pdf_in_storage_to_pptx
1681
+ file_name = '4pages.pdf'
1682
+ upload_file(file_name)
1683
+ res_file = 'result.pptx'
1684
+
1685
+ opts = {
1686
+ :folder => @temp_folder
1687
+ }
1688
+ response = @pdf_api.put_pdf_in_storage_to_pptx(file_name, @temp_folder + '/' + res_file, opts)
1689
+ assert(response, 'Filed to convert PDF to PPTX.')
1690
+ end
1691
+
1692
+
1693
+ def test_put_pdf_in_request_to_pptx
1694
+ file_name = '4pages.pdf'
1695
+
1696
+ res_file = 'result.pptx'
1697
+
1698
+ opts = {
1699
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1700
+ }
1701
+ response = @pdf_api.put_pdf_in_request_to_pptx(@temp_folder + '/' + res_file, opts)
1702
+ assert(response, 'Filed to convert PDF to PPTX.')
1703
+ end
1704
+
1705
+ def test_get_pdf_in_storage_to_la_te_x
1706
+ file_name = '4pages.pdf'
1707
+ upload_file(file_name)
1708
+
1709
+ opts = {
1710
+ :folder => @temp_folder
1711
+ }
1712
+
1713
+ response = @pdf_api.get_pdf_in_storage_to_la_te_x(file_name, opts)
1714
+ assert(response, 'Filed to convert PDF to LaTex.')
1715
+ end
1716
+
1717
+ def test_put_pdf_in_storage_to_la_te_x
1718
+ file_name = '4pages.pdf'
1719
+ upload_file(file_name)
1720
+ res_file = 'result.latex'
1721
+
1722
+ opts = {
1723
+ :folder => @temp_folder
1724
+ }
1725
+ response = @pdf_api.put_pdf_in_storage_to_la_te_x(file_name, @temp_folder + '/' + res_file, opts)
1726
+ assert(response, 'Filed to convert PDF to LaTeX.')
1727
+ end
1728
+
1729
+
1730
+ def test_put_pdf_in_request_to_la_te_x
1731
+ file_name = '4pages.pdf'
1732
+
1733
+ res_file = 'result.latex'
1734
+
1735
+ opts = {
1736
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1737
+ }
1738
+ response = @pdf_api.put_pdf_in_request_to_la_te_x(@temp_folder + '/' + res_file, opts)
1739
+ assert(response, 'Filed to convert PDF to LaTeX.')
1740
+ end
1741
+
1742
+ def test_get_pdf_in_storage_to_mobi_xml
1743
+ file_name = '4pages.pdf'
1744
+ upload_file(file_name)
1745
+
1746
+ opts = {
1747
+ :folder => @temp_folder
1748
+ }
1749
+
1750
+ response = @pdf_api.get_pdf_in_storage_to_mobi_xml(file_name, opts)
1751
+ assert(response, 'Filed to convert PDF to Moby Xml.')
1752
+ end
1753
+
1754
+ def test_put_pdf_in_storage_to_mobi_xml
1755
+ file_name = '4pages.pdf'
1756
+ upload_file(file_name)
1757
+ res_file = 'result.mobi'
1758
+
1759
+ opts = {
1760
+ :folder => @temp_folder
1761
+ }
1762
+ response = @pdf_api.put_pdf_in_storage_to_mobi_xml(file_name, @temp_folder + '/' + res_file, opts)
1763
+ assert(response, 'Filed to convert PDF to Moby Xml.')
1764
+ end
1765
+
1766
+
1767
+ def test_put_pdf_in_request_to_mobi_xml
1768
+ file_name = '4pages.pdf'
1769
+
1770
+ res_file = 'result.mobi'
1771
+
1772
+ opts = {
1773
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1774
+ }
1775
+ response = @pdf_api.put_pdf_in_request_to_mobi_xml(@temp_folder + '/' + res_file, opts)
1776
+ assert(response, 'Filed to convert PDF to Moby Xml.')
1777
+ end
1778
+
1779
+ def test_get_xfa_pdf_in_storage_to_acro_form
1780
+ file_name = 'PdfWithXfaForm.pdf'
1781
+ upload_file(file_name)
1782
+
1783
+ opts = {
1784
+ :folder => @temp_folder
1785
+ }
1786
+
1787
+ response = @pdf_api.get_xfa_pdf_in_storage_to_acro_form(file_name, opts)
1788
+ assert(response, 'Filed to convert Xfa PDF to Acro form.')
1789
+ end
1790
+
1791
+ def test_put_xfa_pdf_in_storage_to_acro_form
1792
+ file_name = 'PdfWithXfaForm.pdf'
1793
+ upload_file(file_name)
1794
+ res_file = 'result.pdf'
1795
+
1796
+ opts = {
1797
+ :folder => @temp_folder
1798
+ }
1799
+ response = @pdf_api.put_xfa_pdf_in_storage_to_acro_form(file_name, @temp_folder + '/' + res_file, opts)
1800
+ assert(response, 'Filed to convert Xfa PDF to Acro form.')
1801
+ end
1802
+
1803
+
1804
+ def test_put_xfa_pdf_in_request_to_acro_form
1805
+ file_name = 'PdfWithXfaForm.pdf'
1806
+
1807
+ res_file = 'result.pdf'
1808
+
1809
+ opts = {
1810
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1811
+ }
1812
+ response = @pdf_api.put_xfa_pdf_in_request_to_acro_form(@temp_folder + '/' + res_file, opts)
1813
+ assert(response, 'Filed to convert Xfa PDF to Acro form.')
1814
+ end
1815
+
1816
+
1817
+ def test_get_pdf_in_storage_to_xml
1818
+ file_name = '4pages.pdf'
1819
+ upload_file(file_name)
1820
+
1821
+ opts = {
1822
+ :folder => @temp_folder
1823
+ }
1824
+
1825
+ response = @pdf_api.get_pdf_in_storage_to_xml(file_name, opts)
1826
+ assert(response, 'Filed to convert PDF to Xml.')
1827
+ end
1828
+
1829
+ def test_put_pdf_in_storage_to_xml
1830
+ file_name = '4pages.pdf'
1831
+ upload_file(file_name)
1832
+ res_file = 'result.xml'
1833
+
1834
+ opts = {
1835
+ :folder => @temp_folder
1836
+ }
1837
+ response = @pdf_api.put_pdf_in_storage_to_xml(file_name, @temp_folder + '/' + res_file, opts)
1838
+ assert(response, 'Filed to convert PDF to Xml.')
1839
+ end
1840
+
1841
+
1842
+ def test_put_pdf_in_request_to_xml
1843
+ file_name = '4pages.pdf'
1844
+
1845
+ res_file = 'result.xml'
1846
+
1847
+ opts = {
1848
+ :file => File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) }
1849
+ }
1850
+ response = @pdf_api.put_pdf_in_request_to_xml(@temp_folder + '/' + res_file, opts)
1851
+ assert(response, 'Filed to convert PDF to Xml.')
1852
+ end
1853
+
1854
+ # Upload & Download Tests
1855
+
1856
+ def test_put_create
1857
+ file_name = '4pages.pdf'
1858
+
1859
+ response = @pdf_api.put_create(@temp_folder + '/' + file_name, File.open(@test_data_folder + file_name, 'r') { |io| io.read(io.size) } )
1860
+ assert(response, "Failed to upload #{file_name} file.")
1861
+ end
1862
+
1863
+ def test_get_download
1864
+ file_name = '4pages.pdf'
1865
+ upload_file(file_name)
1866
+
1867
+
1868
+ response = @pdf_api.get_download(@temp_folder + '/' + file_name)
1869
+ assert(response, "Failed to download #{file_name} file.")
1870
+ end
1871
+
1872
+ # Privileges Tests
1873
+
1874
+ def test_put_privileges
1875
+ file_name = '4pages.pdf'
1876
+ upload_file(file_name)
1877
+
1878
+ privileges = DocumentPrivilege.new
1879
+ privileges.allow_copy = false
1880
+ privileges.allow_print = false
1881
+
1882
+ opts = {
1883
+ :privileges => privileges,
1884
+ :folder => @temp_folder
1885
+ }
1886
+ response = @pdf_api.put_privileges(file_name, opts)
1887
+ assert(response, 'Failed to set pdf privileges.')
1888
+ end
1889
+
1532
1890
  end
1533
1891