happypdf_json_schema 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.rdoc +7 -0
- data/Gemfile +2 -0
- data/README.rdoc +46 -0
- data/Rakefile +18 -0
- data/happypdf_json_schema.gemspec +28 -0
- data/lib/happypdf/schema.rb +11 -0
- data/lib/happypdf/version.rb +5 -0
- data/lib/happypdf_json_schema.rb +1 -0
- data/schema/v1.0/block.json +59 -0
- data/schema/v1.0/page.json +73 -0
- data/schema/v1.0/pdt.json +100 -0
- data/schema/v1.0/table.json +117 -0
- data/schema/v1.0/table_cell.json +93 -0
- data/schema/v1.0/text_block.json +42 -0
- data/schema/v1.0/textflow_block.json +38 -0
- data/spec/happypdf_schema_spec.rb +22 -0
- data/spec/spec_helper.rb +10 -0
- metadata +135 -0
data/.gitignore
ADDED
data/CHANGELOG.rdoc
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
= HappyPDF API Schema
|
2
|
+
|
3
|
+
{<img src="https://secure.travis-ci.org/happypdf/happypdf_json_schema.png?branch=master" alt="Build Status" />}[http://travis-ci.org/happypdf/happypdf_json_schema]
|
4
|
+
|
5
|
+
Our API (objects,resources) is described with JSON Schema (http://json-schema.org).
|
6
|
+
Each Object has its own description, with those top-level keys:
|
7
|
+
|
8
|
+
{
|
9
|
+
"name": "pdf", // object type
|
10
|
+
"properties": { .. }, // field descriptions
|
11
|
+
"links": [ .. ] // CRUD actions, relationships to other resources
|
12
|
+
}
|
13
|
+
|
14
|
+
Look into the /json/ folder for the resources schema-files
|
15
|
+
For ruby pirates this project is available as gem. It provides some utility
|
16
|
+
methods to read the schema files and convert objects to their schema notation.
|
17
|
+
See {/lib/happypdf/schema.rb}[https://github.com/happypdf/happypdf_json_schema/blob/master/lib/happypdf/schema.rb]
|
18
|
+
|
19
|
+
Other languages should take advantage of the raw json files.
|
20
|
+
|
21
|
+
== Field types & formats
|
22
|
+
|
23
|
+
Most of the fields are of type 'string'. Their format(espacially date fields)
|
24
|
+
is casted on our side. We try to go with the {formats}[http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23] and {types}[http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1] defined by JSON-Schema
|
25
|
+
|
26
|
+
All text MUST be UTF-8 encoded.
|
27
|
+
|
28
|
+
*Text-Format* length varies, between ~16,000 to 65.535, with the occurence of non-ASCII Characters {see this post on stackoverflow}[http://stackoverflow.com/questions/4420164/how-much-utf-8-text-fits-in-a-mysql-text-field]
|
29
|
+
|
30
|
+
|
31
|
+
== Install
|
32
|
+
|
33
|
+
gem install happypdf_json_schema
|
34
|
+
|
35
|
+
== Test
|
36
|
+
|
37
|
+
Tested with {travis-ci}[http://travis-ci.org/happypdf/happypdf_json_schema], but of
|
38
|
+
course you can run them too. Install required gems with bundler and go for it:
|
39
|
+
# git clone
|
40
|
+
bundle install
|
41
|
+
rake spec
|
42
|
+
|
43
|
+
|
44
|
+
== ToDo:
|
45
|
+
|
46
|
+
Copyright (c) 2012-2013 Georg Leciejewski, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rdoc/task'
|
6
|
+
|
7
|
+
desc 'Run specs'
|
8
|
+
RSpec::Core::RakeTask.new
|
9
|
+
task :default => :spec
|
10
|
+
|
11
|
+
desc 'Generate documentation.'
|
12
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
13
|
+
rdoc.rdoc_dir = 'rdoc'
|
14
|
+
rdoc.title = 'happyPDF JSON Schema'
|
15
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
16
|
+
rdoc.rdoc_files.include('README')
|
17
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'happypdf/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.version = HappyPdf::Schema::VERSION
|
7
|
+
s.date = %q{2012-12-23}
|
8
|
+
s.name = %q{happypdf_json_schema}
|
9
|
+
s.summary = 'happyPDF API - JSON Schema'
|
10
|
+
s.description = %q{happyPDF JSON Schema describes our PDF API in terms of available objects, their fields and links to url endpoints with related objects.
|
11
|
+
Besides ruby users can use a small lib with utility methods to load and test the schema files.}
|
12
|
+
s.authors = ['Georg Leciejewski']
|
13
|
+
s.email = %q{gl@happypdf.com}
|
14
|
+
s.homepage = %q{http://github.com/happypdf/happypdf_json_schema}
|
15
|
+
s.extra_rdoc_files = ['README.rdoc']
|
16
|
+
s.executables = nil
|
17
|
+
s.files = `git ls-files`.split("\n").reject{|i| i[/^docs\//] }
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
|
20
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
21
|
+
s.require_paths = ['lib']
|
22
|
+
|
23
|
+
s.add_development_dependency 'rdoc'
|
24
|
+
s.add_development_dependency 'rspec'
|
25
|
+
s.add_development_dependency 'json_schema_tools'
|
26
|
+
s.add_development_dependency 'rake', '>= 0.9.2'
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module HappyPdf
|
3
|
+
class Schema
|
4
|
+
# Get the path to schema files. So it can be used f.ex. with json_schema_tools
|
5
|
+
# gem
|
6
|
+
# @param [String] version folder name to use
|
7
|
+
def self.path(version='v1.0')
|
8
|
+
File.expand_path( File.join('../../schema', version), File.dirname(__FILE__))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'happypdf/schema'
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"title": "Block",
|
3
|
+
"name": "block",
|
4
|
+
"description":"A block acts as a placeholder in PDF templates. It can hold text, multiline text, images or pdf's. In this file you find the general properties for all block types. See details in the derived block-type schemas.",
|
5
|
+
"type":"object",
|
6
|
+
"properties":{
|
7
|
+
"name": {
|
8
|
+
"description": "Name of the block. Must unique within each page. [ ] / are not allowed.",
|
9
|
+
"type": "string",
|
10
|
+
"maxLength": 125,
|
11
|
+
"required": true
|
12
|
+
},
|
13
|
+
"rect":{
|
14
|
+
"description": "The block coordinates in DTP points. [ LowerLeftX llY UpperRightX urY] x-increases to the right, y counts upwards, The coordinate system in PDF starts in the lower left corner of a page. Calculation with 72 DPI: 1pt = 1/72inch = 25.4/72 mm = 0.3528 mm",
|
15
|
+
"type": "array",
|
16
|
+
"properties":{
|
17
|
+
"type": "number"
|
18
|
+
},
|
19
|
+
"minItems": 4,
|
20
|
+
"maxItems": 4,
|
21
|
+
"required": true
|
22
|
+
},
|
23
|
+
"backgroundcolor": {
|
24
|
+
"description": "Background color of the Block.",
|
25
|
+
"type": "string",
|
26
|
+
"format": "color"
|
27
|
+
},
|
28
|
+
"bordercolor": {
|
29
|
+
"description": "Draws a rectangle around the block in the given color.",
|
30
|
+
"type": "number",
|
31
|
+
"format": "color"
|
32
|
+
},
|
33
|
+
"linewidth": {
|
34
|
+
"description": "Border line width. Only used if border color is set.",
|
35
|
+
"type": "number",
|
36
|
+
"default": 1
|
37
|
+
},
|
38
|
+
"orientate": {
|
39
|
+
"description": "Orientation of the content. Only used for NON-textflow",
|
40
|
+
"type": "string",
|
41
|
+
"enum": ["north","east","south","west"],
|
42
|
+
"default": "north"
|
43
|
+
},
|
44
|
+
"position": {
|
45
|
+
"description": "Reference point for content placement. Defaults to lower-left corner[0,0]. Values are [x,y] percentages from the start point. E.G. top-right: [100,100] center: [50,50] bottom-center [50,0]. NOT available for textflow blocks",
|
46
|
+
"type": "array",
|
47
|
+
"items":{
|
48
|
+
"type": ["number", "string"]
|
49
|
+
},
|
50
|
+
"minItems": 2,
|
51
|
+
"maxItems": 2
|
52
|
+
},
|
53
|
+
"rotate": {
|
54
|
+
"description": "Rotation angle(degrees) by which the block will be rotated counter-clockwise. The center of the rotation is the position-value, which defaults to lower-left corner.",
|
55
|
+
"type": "number",
|
56
|
+
"default": 0
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "Page",
|
4
|
+
"name": "page",
|
5
|
+
"description": "A page of a PDF which can either belong to a PDF template or archived PDF.",
|
6
|
+
"properties": {
|
7
|
+
"id": {
|
8
|
+
"description": "The object identifier.",
|
9
|
+
"identity": true,
|
10
|
+
"readonly": true,
|
11
|
+
"type": "integer"
|
12
|
+
},
|
13
|
+
"number": {
|
14
|
+
"description": "Number of this page inside the document",
|
15
|
+
"readonly": true,
|
16
|
+
"type": "integer"
|
17
|
+
},
|
18
|
+
"related_object_id": {
|
19
|
+
"description": "ID of the PDF object the page belongs to.",
|
20
|
+
"readonly": true,
|
21
|
+
"type": "integer"
|
22
|
+
},
|
23
|
+
"related_object_type": {
|
24
|
+
"description": "Type of the related object Pdf or Pdt (camelCased class name)",
|
25
|
+
"readonly": true,
|
26
|
+
"type": "string",
|
27
|
+
"maxlength": 20
|
28
|
+
},
|
29
|
+
"width": {
|
30
|
+
"description": "Page width",
|
31
|
+
"type": "number"
|
32
|
+
},
|
33
|
+
"created_at": {
|
34
|
+
"description": "Creation date.",
|
35
|
+
"readonly": true,
|
36
|
+
"type": "string",
|
37
|
+
"format": "date-time"
|
38
|
+
},
|
39
|
+
"updated_at": {
|
40
|
+
"description": "Update date.",
|
41
|
+
"readonly": true,
|
42
|
+
"type": "string",
|
43
|
+
"format": "date-time"
|
44
|
+
},
|
45
|
+
"user_id": {
|
46
|
+
"description": "User who created the object.",
|
47
|
+
"readonly": true,
|
48
|
+
"type": "integer"
|
49
|
+
},
|
50
|
+
"screenshot": {
|
51
|
+
"description": "Screenshot file url png",
|
52
|
+
"type": "string",
|
53
|
+
"maxlength": 128
|
54
|
+
},
|
55
|
+
"account_id": {
|
56
|
+
"description": "Account this objects belongs to.",
|
57
|
+
"type": "integer"
|
58
|
+
},
|
59
|
+
"blocks": {
|
60
|
+
"description": "Placeholder blocks on this page,, if it belongs to a PDF Template",
|
61
|
+
"type": "array",
|
62
|
+
"properties": {"$ref":"./block.json#properties"}
|
63
|
+
}
|
64
|
+
|
65
|
+
},
|
66
|
+
"links": [
|
67
|
+
{
|
68
|
+
"rel": "self",
|
69
|
+
"method": "GET",
|
70
|
+
"href": "/pages/{id}"
|
71
|
+
}
|
72
|
+
]
|
73
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
{
|
2
|
+
"type": "object",
|
3
|
+
"title": "PDF Template",
|
4
|
+
"name": "pdt",
|
5
|
+
"description": "A PDF Template is a plain PDF with data-placeholders(blocks) in it. During the PDF creation process each block is substituted with supplied plain-text or image data.",
|
6
|
+
"properties": {
|
7
|
+
"id": {
|
8
|
+
"description": "The object identifier.",
|
9
|
+
"identity": true,
|
10
|
+
"readonly": true,
|
11
|
+
"type": "integer"
|
12
|
+
},
|
13
|
+
"name": {
|
14
|
+
"description": "Name shown in interface",
|
15
|
+
"type": "string",
|
16
|
+
"maxlength": 60
|
17
|
+
},
|
18
|
+
"file": {
|
19
|
+
"description": "Filename",
|
20
|
+
"type": "string",
|
21
|
+
"maxlength": 60
|
22
|
+
},
|
23
|
+
"description": {
|
24
|
+
"description": "A description of the template",
|
25
|
+
"type": "string"
|
26
|
+
},
|
27
|
+
"user_id": {
|
28
|
+
"description": "User who created the object",
|
29
|
+
"type": "integer"
|
30
|
+
},
|
31
|
+
"created_at": {
|
32
|
+
"description": "Creation date",
|
33
|
+
"readonly": true,
|
34
|
+
"type": "string",
|
35
|
+
"format": "date-time"
|
36
|
+
},
|
37
|
+
"updated_at": {
|
38
|
+
"description": "Update date",
|
39
|
+
"readonly": true,
|
40
|
+
"type": "string",
|
41
|
+
"format": "date-time"
|
42
|
+
},
|
43
|
+
"md5": {
|
44
|
+
"description": "MD5 hash created from pdf string.",
|
45
|
+
"type": "string",
|
46
|
+
"maxlength": 40
|
47
|
+
},
|
48
|
+
"author": {
|
49
|
+
"description": "Default Author for PDF created from this template.",
|
50
|
+
"type": "string",
|
51
|
+
"maxlength": 128
|
52
|
+
},
|
53
|
+
"title": {
|
54
|
+
"description": "Default title for PDF created from this template.",
|
55
|
+
"type": "string",
|
56
|
+
"maxlength": 128
|
57
|
+
},
|
58
|
+
"pdf_filename": {
|
59
|
+
"description": "Default filename for PDF created from this template",
|
60
|
+
"type": "string",
|
61
|
+
"maxlength": 128
|
62
|
+
},
|
63
|
+
"account_id": {
|
64
|
+
"description": "Account this objects belongs to.",
|
65
|
+
"type": "integer"
|
66
|
+
},
|
67
|
+
"pages": {
|
68
|
+
"description": "Pages of the doc.",
|
69
|
+
"type": "array",
|
70
|
+
"properties":{"$ref":"./page.json#properties"}
|
71
|
+
}
|
72
|
+
},
|
73
|
+
"links": [
|
74
|
+
|
75
|
+
{
|
76
|
+
"rel": "instances",
|
77
|
+
"method": "GET",
|
78
|
+
"href": "/pdts"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"rel": "create",
|
82
|
+
"method": "POST",
|
83
|
+
"href": "/pdts"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"rel": "self",
|
87
|
+
"href": "/pdts/{id}"
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"rel": "update",
|
91
|
+
"method": "PUT",
|
92
|
+
"href": "/pdts/{id}"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"rel": "destroy",
|
96
|
+
"method": "DELETE",
|
97
|
+
"href": "/pdts/{id}"
|
98
|
+
}
|
99
|
+
]
|
100
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
{
|
2
|
+
"title": "Table",
|
3
|
+
"name": "table",
|
4
|
+
"description":"A table to be rendered into a pdf. The table is more or less just a nested hash. Formatting options and table sections(footer, header, body) are on the top level. Rows with cells and options are nested in array-hash structures beneath each section-key.",
|
5
|
+
"type":"object",
|
6
|
+
"properties":{
|
7
|
+
"header": {
|
8
|
+
"description": "Header rows with an array of cells for each row.",
|
9
|
+
"type": "array",
|
10
|
+
"items": {
|
11
|
+
"type": "array",
|
12
|
+
"description": "A single row",
|
13
|
+
"items": {
|
14
|
+
"type": "object",
|
15
|
+
"description": "The cells in the row",
|
16
|
+
"$ref": "./table_cell"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"body": {
|
21
|
+
"description": "Body rows with an array of cells for each row.",
|
22
|
+
"type": "array",
|
23
|
+
"items": {
|
24
|
+
"type": "array",
|
25
|
+
"description": "A single row",
|
26
|
+
"items": {
|
27
|
+
"type": "object",
|
28
|
+
"description": "The cells in the row",
|
29
|
+
"$ref": "./table_cell"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"footer": {
|
34
|
+
"description": "Footer rows with an array of cells for each row.",
|
35
|
+
"type": "array",
|
36
|
+
"items": {
|
37
|
+
"type": "array",
|
38
|
+
"description": "A single row",
|
39
|
+
"items": {
|
40
|
+
"type": "object",
|
41
|
+
"description": "The cells in the row",
|
42
|
+
"$ref": "./table_cell"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
},
|
46
|
+
"page_break_header": {
|
47
|
+
"description": "Carry over header row. The content of the the last cell is being replace with page_break_value(page_break_footer) from the last body row cell.",
|
48
|
+
"type": "array",
|
49
|
+
"items": {
|
50
|
+
"type": "object",
|
51
|
+
"description": "The cells in the row",
|
52
|
+
"$ref": "./table_cell"
|
53
|
+
}
|
54
|
+
},
|
55
|
+
"page_break_footer": {
|
56
|
+
"description": "Carry over header row used as a template for page breaks. The content of the the last cell is being replace with page_break_value from the last body row cell.",
|
57
|
+
"type": "array",
|
58
|
+
"items": {
|
59
|
+
"type": "object",
|
60
|
+
"description": "The cells in the row",
|
61
|
+
"$ref": "./table_cell"
|
62
|
+
}
|
63
|
+
},
|
64
|
+
"showcells": {
|
65
|
+
"description": "Show the border of each inner cell. More or less just for debugging.",
|
66
|
+
"type": "boolean",
|
67
|
+
"default": false
|
68
|
+
},
|
69
|
+
"showborder": {
|
70
|
+
"description": "Show the outer border of a table",
|
71
|
+
"type": "boolean",
|
72
|
+
"default": false
|
73
|
+
},
|
74
|
+
"showgrid": {
|
75
|
+
"description": "Draw a border for the vertical and horizontal boundaries of all columns and rows",
|
76
|
+
"type": "boolean",
|
77
|
+
"default": false
|
78
|
+
},
|
79
|
+
"fill": {
|
80
|
+
"description": "fill rows or columns with color",
|
81
|
+
"type": "array",
|
82
|
+
"items":{
|
83
|
+
"area":{
|
84
|
+
"description":"Defines the area to be filled with the given fillcolor. col#: column number # in the table",
|
85
|
+
"type": "string",
|
86
|
+
"enum":["col#","collast","coleven", "colodd", "colother", "row#", "rowlast","roweven","rowodd","header","footer","rowother","table"]
|
87
|
+
},
|
88
|
+
"fillcolor":{
|
89
|
+
"description":" The filling color",
|
90
|
+
"type": "color",
|
91
|
+
"required": true
|
92
|
+
}
|
93
|
+
}
|
94
|
+
},
|
95
|
+
"stroke": {
|
96
|
+
"description": "Draw border-lines for rows or columns: 'stroke': [{'line':'horother', 'strokecolor':'rgb 0 0 0' }]",
|
97
|
+
"type": "array",
|
98
|
+
"items":{
|
99
|
+
"line":{
|
100
|
+
"description":"Defines the area to be filled: vert0: line at the right border of column number #; vert0 is the left table border",
|
101
|
+
"type": "string",
|
102
|
+
"enum":["vert#","vertfirst","vertlast","vertother","hor#","horlast","horfirst","horother","frame","other"]
|
103
|
+
},
|
104
|
+
"strokecolor":{
|
105
|
+
"description":" The line color",
|
106
|
+
"type": "color",
|
107
|
+
"required": true
|
108
|
+
},
|
109
|
+
"linewidth":{
|
110
|
+
"description":" Width if the line.",
|
111
|
+
"type": "number",
|
112
|
+
"default": 1
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
{
|
2
|
+
"title": "TableCell",
|
3
|
+
"name": "table_cell",
|
4
|
+
"description":"Table formatting can be done by passing a json string in the data-attribute table-opts in a html table definition.",
|
5
|
+
"type":"object",
|
6
|
+
"properties":{
|
7
|
+
"content": {
|
8
|
+
"description": "The text content for the cell. Probably something your want to fill.",
|
9
|
+
"type": "string"
|
10
|
+
},
|
11
|
+
"type": {
|
12
|
+
"description": "The cell type is auto-detected by the content length. texflow for >20 chars. Sometimes you should force the type since formatting options differ between line and textflow e.g. Text might start at different line height f.ex. in footer rows.",
|
13
|
+
"type": "boolean",
|
14
|
+
"values": ["textline", "textflow"]
|
15
|
+
},
|
16
|
+
"align": {
|
17
|
+
"description": "Align the text content.",
|
18
|
+
"type": "boolean",
|
19
|
+
"values": ["right", "left"]
|
20
|
+
},
|
21
|
+
"page_break_value": {
|
22
|
+
"description": "If the table has to be split the last cell in the last row can provide this value, used fo a sub total/carry over row.",
|
23
|
+
"type": "string"
|
24
|
+
},
|
25
|
+
"colspan": {
|
26
|
+
"description": "Columns spanned by this cell.",
|
27
|
+
"type": "number",
|
28
|
+
"default": 1
|
29
|
+
},
|
30
|
+
"rowspan": {
|
31
|
+
"description": "Rows spanned by this cell.",
|
32
|
+
"type": "number",
|
33
|
+
"default": 1
|
34
|
+
},
|
35
|
+
"colwidth": {
|
36
|
+
"description": "Column width. The last definition counts for all cells in a column",
|
37
|
+
"type": "boolean",
|
38
|
+
"default": false
|
39
|
+
},
|
40
|
+
"margin": {
|
41
|
+
"description": "Margin for all sides. Specific margins left,right,top,bottom override this value. Value can be given as number or percentage(string) and must be >0",
|
42
|
+
"type": ["number", "string"],
|
43
|
+
"minimum": 0,
|
44
|
+
"default": 0
|
45
|
+
},
|
46
|
+
"marginleft": {
|
47
|
+
"description": "Left Margin. Overrides margin value if set.",
|
48
|
+
"type": ["number", "string"],
|
49
|
+
"minimum": 0,
|
50
|
+
"default": 0
|
51
|
+
},
|
52
|
+
"marginright": {
|
53
|
+
"description": "Right Margin. Overrides margin value if set.",
|
54
|
+
"type": ["number", "string"],
|
55
|
+
"minimum": 0,
|
56
|
+
"default": 0
|
57
|
+
},
|
58
|
+
"margintop": {
|
59
|
+
"description": "Top Margin. Overrides margin value if set.",
|
60
|
+
"type": ["number", "string"],
|
61
|
+
"minimum": 0,
|
62
|
+
"default": 0
|
63
|
+
},
|
64
|
+
"marginbottom": {
|
65
|
+
"description": "Bottom Margin. Overrides margin value if set.",
|
66
|
+
"type": ["number", "string"],
|
67
|
+
"minimum": 0,
|
68
|
+
"default": 0
|
69
|
+
},
|
70
|
+
"matchbox": {
|
71
|
+
"description": "Formatting options applied to the text inside the cell. E.g. used to draw a border independently from the cell.",
|
72
|
+
"type": "Object",
|
73
|
+
"properties": {
|
74
|
+
"borderwidth": {},
|
75
|
+
"drawleft": {},
|
76
|
+
"drawbottom": {},
|
77
|
+
"drawright": {},
|
78
|
+
"offsettop": {},
|
79
|
+
"offsetleft": {},
|
80
|
+
"dasharray": {}
|
81
|
+
}
|
82
|
+
},
|
83
|
+
"font": {
|
84
|
+
"description": "Font for this cell. The font MUST be available on the system generating the PDF.",
|
85
|
+
"type": "Object",
|
86
|
+
"properties": {
|
87
|
+
"fontname": {},
|
88
|
+
"fontsize": {},
|
89
|
+
"fontstyle": {}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"title": "Text Block",
|
3
|
+
"extends": "block",
|
4
|
+
"description":"A single line text block. Multiline text-blocks inherit from this one, see textflow for ref.",
|
5
|
+
"name": "text_block",
|
6
|
+
"type":"object",
|
7
|
+
"properties":{
|
8
|
+
"defaulttext": {
|
9
|
+
"description": "Content if no text is supplied by the client.",
|
10
|
+
"type": "string"
|
11
|
+
},
|
12
|
+
"fillcolor":{
|
13
|
+
"description": "Text fill color. Defaults to black",
|
14
|
+
"type": "color",
|
15
|
+
"default": "gray 0"
|
16
|
+
},
|
17
|
+
"fontname":{
|
18
|
+
"description": "Name of the font. Must be the exact file-name as present on the system(Case-Sensitive), excl. file extension. Must be an OTF, TTF unicode font as all text is UTF-8.",
|
19
|
+
"type": "string"
|
20
|
+
},
|
21
|
+
"fontsize":{
|
22
|
+
"description": "Size of the font in points",
|
23
|
+
"type": "float"
|
24
|
+
},
|
25
|
+
"fontstyle":{
|
26
|
+
"description": "Style of the font. If the font does not support the style e.g. Bold print occurs 3 times with normal style.",
|
27
|
+
"type": "enum",
|
28
|
+
"values": ["normal", "bold", "italic","bolditalic"]
|
29
|
+
},
|
30
|
+
"strokecolor":{
|
31
|
+
"description": "Stroke(border) color of the text",
|
32
|
+
"type": "string",
|
33
|
+
"format": "color",
|
34
|
+
"default": "gray 0"
|
35
|
+
},
|
36
|
+
"fitmethod":{
|
37
|
+
"type": "string",
|
38
|
+
"enum": ["auto","nofit","clip","meet", "slice", "entire"],
|
39
|
+
"default": "auto"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{
|
2
|
+
"title": "TextFlowBlock",
|
3
|
+
"name": "textflow_block",
|
4
|
+
"description":"Multi line text block, inheriting all properties from Block and TextBlock.",
|
5
|
+
"type":"object",
|
6
|
+
"extends": "text_block",
|
7
|
+
"properties":{
|
8
|
+
"alignment":{
|
9
|
+
"description": "Alignment for lines in a paragraph.",
|
10
|
+
"type": "string",
|
11
|
+
"enum": ["left","center","right","justify"],
|
12
|
+
"default": "left"
|
13
|
+
},
|
14
|
+
"verticalalign":{
|
15
|
+
"description": "Vertical alignment for the text.",
|
16
|
+
"type": "string",
|
17
|
+
"enum": ["top","center","bottom","justify"],
|
18
|
+
"default": "top"
|
19
|
+
},
|
20
|
+
"leading":{
|
21
|
+
"description": "Line height(distance between text baselines). In points or as percentage of the font size.",
|
22
|
+
"type": ["number","string"],
|
23
|
+
"default": "100%"
|
24
|
+
},
|
25
|
+
"shrinklimit":{
|
26
|
+
"description": "Max. percentage for text shrinking, if it does not fit the box.",
|
27
|
+
"type": "string",
|
28
|
+
"default": "85%"
|
29
|
+
},
|
30
|
+
"fitmethod ":{
|
31
|
+
"description": "If the text does not fit: auto => fontsize and leading will be decreased until the text fits. nofit => Text will run beyond the bottom margin of the block. clip => Text will be clipped at the block margin.",
|
32
|
+
"type": "string",
|
33
|
+
"enum": ["auto","nofit","clip"],
|
34
|
+
"default": "auto",
|
35
|
+
"required": true
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HappyPdf::Schema do
|
4
|
+
|
5
|
+
context 'path' do
|
6
|
+
it 'should provide path to schema files' do
|
7
|
+
HappyPdf::Schema.path.should == File.expand_path( File.join('../schema/v1.0'), File.dirname(__FILE__))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'read schemata' do
|
12
|
+
|
13
|
+
it 'should read all json files' do
|
14
|
+
SchemaTools.schema_path = HappyPdf::Schema.path
|
15
|
+
SchemaTools::Reader.read_all
|
16
|
+
SchemaTools::Reader.registry.should_not be_empty
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: happypdf_json_schema
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Georg Leciejewski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json_schema_tools
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.9.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.9.2
|
78
|
+
description: ! 'happyPDF JSON Schema describes our PDF API in terms of available objects,
|
79
|
+
their fields and links to url endpoints with related objects.
|
80
|
+
|
81
|
+
Besides ruby users can use a small lib with utility methods to load and test the
|
82
|
+
schema files.'
|
83
|
+
email: gl@happypdf.com
|
84
|
+
executables: []
|
85
|
+
extensions: []
|
86
|
+
extra_rdoc_files:
|
87
|
+
- README.rdoc
|
88
|
+
files:
|
89
|
+
- .gitignore
|
90
|
+
- .travis.yml
|
91
|
+
- CHANGELOG.rdoc
|
92
|
+
- Gemfile
|
93
|
+
- README.rdoc
|
94
|
+
- Rakefile
|
95
|
+
- happypdf_json_schema.gemspec
|
96
|
+
- lib/happypdf/schema.rb
|
97
|
+
- lib/happypdf/version.rb
|
98
|
+
- lib/happypdf_json_schema.rb
|
99
|
+
- schema/v1.0/block.json
|
100
|
+
- schema/v1.0/page.json
|
101
|
+
- schema/v1.0/pdt.json
|
102
|
+
- schema/v1.0/table.json
|
103
|
+
- schema/v1.0/table_cell.json
|
104
|
+
- schema/v1.0/text_block.json
|
105
|
+
- schema/v1.0/textflow_block.json
|
106
|
+
- spec/happypdf_schema_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
homepage: http://github.com/happypdf/happypdf_json_schema
|
109
|
+
licenses: []
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
hash: -1675451129783921194
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 1.8.24
|
132
|
+
signing_key:
|
133
|
+
specification_version: 3
|
134
|
+
summary: happyPDF API - JSON Schema
|
135
|
+
test_files: []
|