pd4ml 1.0.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -15
- data/docs/api.md +155 -3
- data/docs/guide.md +937 -782
- data/exe/pd4ml +6 -1
- data/lib/pd4ml/bridge.rb +362 -362
- data/lib/pd4ml/installer.rb +45 -6
- data/lib/pd4ml/java.rb +22 -2
- data/lib/pd4ml/pd4ml.rb +31 -1
- data/lib/pd4ml/version.rb +1 -1
- data/lib/pd4ml.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eada212500d1ee924117e4c9b8f0ad4f8d29f7b69fb4ff6b0b1775caf3c23bfe
|
|
4
|
+
data.tar.gz: c3f70c2b02f24e52517d95b4bb10ee2c81116230b9b8d356ccae0f7619b4bf74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6f7e9b5e9ff21c9db8a8cbae74770c766444afd2c9ce6123a08817691c9dfac6c941104a12cf56f2614d4274e858df788baaeb986a8ecd88d5c246128f0a8c1
|
|
7
|
+
data.tar.gz: ad146b82b276a72480749a4f2f25e3254b982e8d1a3dfd4d065e202e06b61496c6b4e250abddf5aac44a5f29150259cdb0f57853ea132b3be0d75dc5740bafc9
|
data/README.md
CHANGED
|
@@ -16,29 +16,30 @@ pd.write_pdf('hello.pdf') # or pdf = pd.write_pdf (a binary String), or
|
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
|
-
With Bundler, in the `Gemfile`:
|
|
20
|
-
|
|
21
|
-
```ruby
|
|
22
|
-
gem 'pd4ml', git: 'https://github.com/zxfr/pd4ml-ruby.git'
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
or download the gem from <https://github.com/zxfr/pd4ml-ruby/releases>:
|
|
26
|
-
|
|
27
19
|
```
|
|
28
|
-
gem install pd4ml
|
|
20
|
+
gem install pd4ml
|
|
29
21
|
pd4ml install # optional: otherwise the first use downloads PD4ML
|
|
30
22
|
```
|
|
31
23
|
|
|
24
|
+
or `gem 'pd4ml'` in the `Gemfile`. The gem is on RubyGems (<https://rubygems.org/gems/pd4ml>);
|
|
25
|
+
its contents and releases are also on GitHub (<https://github.com/zxfr/pd4ml-ruby>).
|
|
26
|
+
|
|
32
27
|
Requirements:
|
|
33
28
|
|
|
34
29
|
- Ruby 3.1 or later.
|
|
35
30
|
- Java 8 or later, found through `PD4ML_JAVA`, `JAVA_HOME` or the `PATH`.
|
|
36
31
|
|
|
37
|
-
PD4ML itself is downloaded from <https://pd4ml.com/maven2>: the most recent
|
|
38
|
-
Bouncy Castle jars it needs for encryption and signing. Every file is checked
|
|
39
|
-
checksum. The download happens with `pd4ml install`, or on first use
|
|
40
|
-
turns that off). Builds are stored per user
|
|
41
|
-
or `PD4ML_HOME`).
|
|
32
|
+
PD4ML itself is downloaded from <https://pd4ml.com/maven2>: by default the most recent release from
|
|
33
|
+
4.2.0 on, plus the Bouncy Castle jars it needs for encryption and signing. Every file is checked
|
|
34
|
+
against its SHA-1 checksum. The download happens with `pd4ml install`, or on first use
|
|
35
|
+
(`PD4ML_AUTO_INSTALL=0` turns that off). Builds are stored per user
|
|
36
|
+
(`%LOCALAPPDATA%\pd4ml-ruby`, `~/.cache/pd4ml-ruby`, or `PD4ML_HOME`).
|
|
37
|
+
|
|
38
|
+
The gem's PD4ML 4.2 API (`read_eml`/`read_mht`, `add_allowed_resource_location`, XMP
|
|
39
|
+
`add_metadata`, the DOM API) needs PD4ML 4.2. Until PD4ML 4.2.0 is released, the default is
|
|
40
|
+
therefore the most recent 4.2.x development snapshot (4.2.0-SNAPSHOT). Once 4.2.0 is out, new
|
|
41
|
+
installs take it, and `pd4ml install` updates existing ones. `pd4ml install 4.1.2` installs the
|
|
42
|
+
current 4.1 release instead (the rest of the API works with it). See [Install PD4ML](docs/guide.md#22-install-pd4ml).
|
|
42
43
|
|
|
43
44
|
To use a PD4ML jar of your own, set `PD4ML_CLASSPATH`, set `PD4ML_CLASSPATH_FILE`, or call
|
|
44
45
|
`Pd4ml.configure(classpath: [...])`.
|
|
@@ -56,10 +57,15 @@ The gem adds Ruby I/O on top: paths, URLs, binary Strings and IO objects in and
|
|
|
56
57
|
for progress listeners. Several processes can share one bridge server: run `pd4ml serve` and set
|
|
57
58
|
`PD4ML_BRIDGE=tcp://127.0.0.1:8723`.
|
|
58
59
|
|
|
60
|
+
With PD4ML 4.2, the gem also reads e-mail messages and saved web pages (`read_eml`, `read_mht`),
|
|
61
|
+
and gives access to the parsed document before it is written (`get_document`, `layout`: the DOM
|
|
62
|
+
API of the DMS and UA editions, whose lists come back as Ruby Arrays). See the
|
|
63
|
+
[guide](docs/guide.md#516-e-mail-messages-and-saved-web-pages).
|
|
64
|
+
|
|
59
65
|
## Command line
|
|
60
66
|
|
|
61
67
|
```
|
|
62
|
-
pd4ml install [VERSION] [--snapshots] download PD4ML (or update it
|
|
68
|
+
pd4ml install [VERSION] [--snapshots] download PD4ML (default: 4.2, see above) or update it
|
|
63
69
|
pd4ml list versions in the repository
|
|
64
70
|
pd4ml version the PD4ML version in use
|
|
65
71
|
pd4ml convert in.html out.pdf [--page-size A4 --landscape --spec pdf/a-2b ...]
|
data/docs/api.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
_Generated by `tools/gen_api.rb` from the PD4ML Java classes - do not edit._
|
|
4
4
|
|
|
5
|
-
Every public PD4ML class is a Ruby class in the `Pd4ml` module. Methods can be called by their Java name (`setPageSize`) or Ruby-style (`set_page_size`; `isDemoMode` as `demo_mode?`); both are listed below. Constants and static fields are Ruby constants or class methods (`Pd4ml::PageSize::A4`, `Pd4ml::LayoutEngine.v42`), public instance fields are read with `obj[:name]`. Java types appear as Ruby types: binary Strings for `byte[]` and `InputStream`, a path or URL String for `URL`/`File`, `JavaObject` for any other Java object. Descriptions of each method are in the [PD4ML manual](https://pd4ml.com/docs/pd4ml-manual.html).
|
|
5
|
+
Every public PD4ML class is a Ruby class in the `Pd4ml` module. Methods can be called by their Java name (`setPageSize`) or Ruby-style (`set_page_size`; `isDemoMode` as `demo_mode?`); both are listed below. Constants and static fields are Ruby constants or class methods (`Pd4ml::PageSize::A4`, `Pd4ml::LayoutEngine.v42`), public instance fields are read with `obj[:name]`. Java types appear as Ruby types: binary Strings for `byte[]` and `InputStream`, a path or URL String for `URL`/`File`, `JavaObject` for any other Java object. The DOM API classes (`Pd4ml::Dom`: `PD4ML#get_document` and `PD4ML#layout` return them; v42 layout engine, DMS and UA editions) return Java lists and sets as Ruby Arrays, maps as Hashes. Descriptions of each method are in the [PD4ML manual](https://pd4ml.com/docs/pd4ml-manual.html).
|
|
6
6
|
|
|
7
7
|
## Pd4ml::PD4ML
|
|
8
8
|
|
|
@@ -78,6 +78,8 @@ keep_trailing_blank_pages?() -> true/false # isKeepTrailingBlankPages
|
|
|
78
78
|
test_termination() -> nil # testTermination
|
|
79
79
|
get_height(width: Integer) -> Integer # getHeight
|
|
80
80
|
get_document_title() -> String # getDocumentTitle
|
|
81
|
+
layout() -> Dom::Layout # layout
|
|
82
|
+
get_document() -> Dom::Document # getDocument
|
|
81
83
|
set_rendering_hints(hints: Hash) -> nil # setRenderingHints
|
|
82
84
|
dump(mode: Integer) -> String # dump
|
|
83
85
|
protect_physical_unit_dimensions(keep_physical_unit_dimensions: true/false) -> nil # protectPhysicalUnitDimensions
|
|
@@ -85,10 +87,12 @@ Pd4ml::PD4ML.translate_to_pt(mm: Float) -> Float # translateToPt
|
|
|
85
87
|
Pd4ml::PD4ML.predict_scale(page_margins: PageMargins, page_size: PageSize, user_space: Integer) -> Float # predictScale
|
|
86
88
|
Pd4ml::PD4ML.predict_page_height(page_margins: PageMargins, page_size: PageSize, user_space: Integer) -> Integer # predictPageHeight
|
|
87
89
|
set_dynamic_data(map: Hash) -> nil # setDynamicData
|
|
90
|
+
add_allowed_resource_location(locations: String) -> nil # addAllowedResourceLocation
|
|
88
91
|
set_param(key: String, value: String) -> nil # setParam
|
|
89
92
|
get_last_render_info(key: String) -> Object # getLastRenderInfo
|
|
90
93
|
output_range(description: String) -> nil # outputRange
|
|
91
94
|
add_metadata(key: String, value: String, hide: true/false) -> nil # addMetadata
|
|
95
|
+
add_metadata(namespace_uri: String, prefix: String, key: String, value: String) -> nil # addMetadata
|
|
92
96
|
apply_kerning(enable: true/false) -> nil # applyKerning
|
|
93
97
|
enable_ligatures(enable: true/false) -> nil # enableLigatures
|
|
94
98
|
get_cache() -> Object # getCache
|
|
@@ -119,7 +123,6 @@ async_resource_loader(thread_pool_size: Integer) -> nil # asyncResourceLoader
|
|
|
119
123
|
| `Pd4ml::Constants::PD4ML_EXTRA_RESOURCE_LOADERS` | String | static read-only |
|
|
120
124
|
| `Pd4ml::Constants::PD4ML_DOCUMENT_VIEW_MODE` | String | static read-only |
|
|
121
125
|
| `Pd4ml::Constants::PD4ML_DOCUMENT_DATE` | String | static read-only |
|
|
122
|
-
| `Pd4ml::Constants::PD4ML_WORD_EDITABLE` | String | static read-only |
|
|
123
126
|
| `Pd4ml::Constants::PD4ML_DOCUMENT_XMP_DATE` | String | static read-only |
|
|
124
127
|
| `Pd4ml::Constants::PD4ML_FAKE_BROWSER` | String | static read-only |
|
|
125
128
|
| `Pd4ml::Constants::PD4ML_CACHE_ENABLE` | String | static read-only |
|
|
@@ -398,6 +401,7 @@ requires_metadata() -> true/false # requiresMetadata
|
|
|
398
401
|
requires_output_internet() -> true/false # requiresOutputInternet
|
|
399
402
|
allows_external_hyperlinking() -> true/false # allowsExternalHyperlinking
|
|
400
403
|
requires_reliable_unicode_semantics() -> true/false # requiresReliableUnicodeSemantics
|
|
404
|
+
has_pdf_version() -> true/false # hasPdfVersion
|
|
401
405
|
get_pdf_version_label() -> String # getPdfVersionLabel
|
|
402
406
|
get_pdf_ext_level() -> Integer # getPdfExtLevel
|
|
403
407
|
get_pdfa_version() -> Integer # getPdfaVersion
|
|
@@ -450,7 +454,7 @@ Pd4ml::PdfDocumentBase.compute_scope(scope: String, page_num: Integer) -> Array<
|
|
|
450
454
|
|
|
451
455
|
## Pd4ml::PdfDocument
|
|
452
456
|
|
|
453
|
-
`com.pd4ml.PdfDocument`
|
|
457
|
+
`com.pd4ml.PdfDocument` — also the methods of `Pd4ml::PdfDocumentBase`
|
|
454
458
|
|
|
455
459
|
```ruby
|
|
456
460
|
Pd4ml::PdfDocument.new(bytes: String (binary), password: String)
|
|
@@ -544,3 +548,151 @@ error?() -> true/false # isError
|
|
|
544
548
|
warning?() -> true/false # isWarning
|
|
545
549
|
get_message() -> String # getMessage
|
|
546
550
|
```
|
|
551
|
+
|
|
552
|
+
## Pd4ml::Dom::Node
|
|
553
|
+
|
|
554
|
+
`com.pd4ml.dom.Node` (DOM API)
|
|
555
|
+
|
|
556
|
+
```ruby
|
|
557
|
+
get_node_name() -> String # getNodeName
|
|
558
|
+
get_parent_node() -> Dom::Node # getParentNode
|
|
559
|
+
get_parent_element() -> Dom::Element # getParentElement
|
|
560
|
+
get_owner_document() -> Dom::Document # getOwnerDocument
|
|
561
|
+
get_child_nodes() -> Array<Dom::Node> # getChildNodes
|
|
562
|
+
has_child_nodes() -> true/false # hasChildNodes
|
|
563
|
+
get_first_child() -> Dom::Node # getFirstChild
|
|
564
|
+
get_last_child() -> Dom::Node # getLastChild
|
|
565
|
+
get_next_sibling() -> Dom::Node # getNextSibling
|
|
566
|
+
get_previous_sibling() -> Dom::Node # getPreviousSibling
|
|
567
|
+
get_text_content() -> String # getTextContent
|
|
568
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
569
|
+
append_child(child: Dom::Node) -> Dom::Node # appendChild
|
|
570
|
+
insert_before(child: Dom::Node, ref: Dom::Node) -> Dom::Node # insertBefore
|
|
571
|
+
replace_child(replacement: Dom::Node, old: Dom::Node) -> Dom::Node # replaceChild
|
|
572
|
+
remove_child(child: Dom::Node) -> Dom::Node # removeChild
|
|
573
|
+
remove() -> nil # remove
|
|
574
|
+
clone_node(deep: true/false) -> Dom::Node # cloneNode
|
|
575
|
+
contains(other: Dom::Node) -> true/false # contains
|
|
576
|
+
to_html() -> String # toHtml
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
## Pd4ml::Dom::Document
|
|
580
|
+
|
|
581
|
+
`com.pd4ml.dom.Document` (DOM API) — also the methods of `Pd4ml::Dom::Node`
|
|
582
|
+
|
|
583
|
+
```ruby
|
|
584
|
+
get_document_element() -> Dom::Element # getDocumentElement
|
|
585
|
+
get_head() -> Dom::Element # getHead
|
|
586
|
+
get_body() -> Dom::Element # getBody
|
|
587
|
+
get_doctype() -> Dom::DocumentType # getDoctype
|
|
588
|
+
quirks_mode?() -> true/false # isQuirksMode
|
|
589
|
+
get_base_uri() -> String # getBaseURI
|
|
590
|
+
get_title() -> String # getTitle
|
|
591
|
+
get_element_by_id(id: String) -> Dom::Element # getElementById
|
|
592
|
+
get_elements_by_tag_name(name: String) -> Array<Dom::Element> # getElementsByTagName
|
|
593
|
+
get_elements_by_class_name(names: String) -> Array<Dom::Element> # getElementsByClassName
|
|
594
|
+
query_selector(selectors: String) -> Dom::Element # querySelector
|
|
595
|
+
query_selector_all(selectors: String) -> Array<Dom::Element> # querySelectorAll
|
|
596
|
+
create_element(tag_name: String) -> Dom::Element # createElement
|
|
597
|
+
create_text_node(data: String) -> Dom::Text # createTextNode
|
|
598
|
+
create_comment(data: String) -> Dom::Comment # createComment
|
|
599
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
## Pd4ml::Dom::Element
|
|
603
|
+
|
|
604
|
+
`com.pd4ml.dom.Element` (DOM API) — also the methods of `Pd4ml::Dom::Node`
|
|
605
|
+
|
|
606
|
+
```ruby
|
|
607
|
+
get_tag_name() -> String # getTagName
|
|
608
|
+
get_attribute(name: String) -> String # getAttribute
|
|
609
|
+
has_attribute(name: String) -> true/false # hasAttribute
|
|
610
|
+
set_attribute(name: String, value: String) -> nil # setAttribute
|
|
611
|
+
remove_attribute(name: String) -> nil # removeAttribute
|
|
612
|
+
get_attributes() -> Hash # getAttributes
|
|
613
|
+
get_id() -> String # getId
|
|
614
|
+
set_id(id: String) -> nil # setId
|
|
615
|
+
get_class_name() -> String # getClassName
|
|
616
|
+
set_class_name(class_name: String) -> nil # setClassName
|
|
617
|
+
get_class_list() -> Array<String> # getClassList
|
|
618
|
+
has_class(name: String) -> true/false # hasClass
|
|
619
|
+
add_class(name: String) -> nil # addClass
|
|
620
|
+
remove_class(name: String) -> nil # removeClass
|
|
621
|
+
toggle_class(name: String) -> true/false # toggleClass
|
|
622
|
+
get_children() -> Array<Dom::Element> # getChildren
|
|
623
|
+
get_first_element_child() -> Dom::Element # getFirstElementChild
|
|
624
|
+
get_last_element_child() -> Dom::Element # getLastElementChild
|
|
625
|
+
get_next_element_sibling() -> Dom::Element # getNextElementSibling
|
|
626
|
+
get_previous_element_sibling() -> Dom::Element # getPreviousElementSibling
|
|
627
|
+
get_elements_by_tag_name(name: String) -> Array<Dom::Element> # getElementsByTagName
|
|
628
|
+
get_elements_by_class_name(names: String) -> Array<Dom::Element> # getElementsByClassName
|
|
629
|
+
query_selector(selectors: String) -> Dom::Element # querySelector
|
|
630
|
+
query_selector_all(selectors: String) -> Array<Dom::Element> # querySelectorAll
|
|
631
|
+
matches(selectors: String) -> true/false # matches
|
|
632
|
+
closest(selectors: String) -> Dom::Element # closest
|
|
633
|
+
get_inner_html() -> String # getInnerHTML
|
|
634
|
+
set_inner_html(html: String) -> nil # setInnerHTML
|
|
635
|
+
get_outer_html() -> String # getOuterHTML
|
|
636
|
+
set_outer_html(html: String) -> nil # setOuterHTML
|
|
637
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
## Pd4ml::Dom::Text
|
|
641
|
+
|
|
642
|
+
`com.pd4ml.dom.Text` (DOM API) — also the methods of `Pd4ml::Dom::Node`
|
|
643
|
+
|
|
644
|
+
```ruby
|
|
645
|
+
get_data() -> String # getData
|
|
646
|
+
set_data(data: String) -> nil # setData
|
|
647
|
+
whitespace?() -> true/false # isWhitespace
|
|
648
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## Pd4ml::Dom::Comment
|
|
652
|
+
|
|
653
|
+
`com.pd4ml.dom.Comment` (DOM API) — also the methods of `Pd4ml::Dom::Node`
|
|
654
|
+
|
|
655
|
+
```ruby
|
|
656
|
+
get_data() -> String # getData
|
|
657
|
+
set_data(data: String) -> nil # setData
|
|
658
|
+
get_text_content() -> String # getTextContent
|
|
659
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
## Pd4ml::Dom::DocumentType
|
|
663
|
+
|
|
664
|
+
`com.pd4ml.dom.DocumentType` (DOM API) — also the methods of `Pd4ml::Dom::Node`
|
|
665
|
+
|
|
666
|
+
```ruby
|
|
667
|
+
get_name() -> String # getName
|
|
668
|
+
get_public_id() -> String # getPublicId
|
|
669
|
+
get_system_id() -> String # getSystemId
|
|
670
|
+
set_text_content(text: String) -> nil # setTextContent
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
## Pd4ml::Dom::Layout
|
|
674
|
+
|
|
675
|
+
`com.pd4ml.dom.Layout` (DOM API)
|
|
676
|
+
|
|
677
|
+
```ruby
|
|
678
|
+
get_page_count() -> Integer # getPageCount
|
|
679
|
+
get_page_width(page: Integer) -> Float # getPageWidth
|
|
680
|
+
get_page_height(page: Integer) -> Float # getPageHeight
|
|
681
|
+
get_page_number(page: Integer) -> Integer # getPageNumber
|
|
682
|
+
get_boxes(element: Dom::Element) -> Array<Dom::LayoutBox> # getBoxes
|
|
683
|
+
get_pages(element: Dom::Element) -> Array<Integer> # getPages
|
|
684
|
+
get_computed_style(element: Dom::Element, property: String) -> String # getComputedStyle
|
|
685
|
+
element_at(page: Integer, x: Float, y: Float) -> Dom::Element # elementAt
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
## Pd4ml::Dom::LayoutBox
|
|
689
|
+
|
|
690
|
+
`com.pd4ml.dom.LayoutBox` (DOM API)
|
|
691
|
+
|
|
692
|
+
```ruby
|
|
693
|
+
get_page() -> Integer # getPage
|
|
694
|
+
get_x() -> Float # getX
|
|
695
|
+
get_y() -> Float # getY
|
|
696
|
+
get_width() -> Float # getWidth
|
|
697
|
+
get_height() -> Float # getHeight
|
|
698
|
+
```
|