pdfgen-juanipis 0.1.3__tar.gz → 0.1.4__tar.gz

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.
Files changed (54) hide show
  1. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/PKG-INFO +35 -10
  2. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/README.md +35 -10
  3. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/pyproject.toml +3 -3
  4. pdfgen_juanipis-0.1.4/src/pdfgen_juanipis/__init__.py +18 -0
  5. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/api.py +33 -1
  6. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/cli.py +14 -3
  7. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/render.py +9 -2
  8. pdfgen_juanipis-0.1.4/src/pdfgen_juanipis/schema.json +272 -0
  9. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/validator.py +1 -1
  10. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/src/pdfgen_juanipis.egg-info/PKG-INFO +35 -10
  11. pdfgen_juanipis-0.1.4/src/pdfgen_juanipis.egg-info/SOURCES.txt +46 -0
  12. pdfgen_juanipis-0.1.4/src/pdfgen_juanipis.egg-info/entry_points.txt +2 -0
  13. pdfgen_juanipis-0.1.4/src/pdfgen_juanipis.egg-info/top_level.txt +1 -0
  14. pdfgen_juanipis-0.1.4/tests/test_api.py +25 -0
  15. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_cli_fonts_conf.py +1 -1
  16. pdfgen_juanipis-0.1.4/tests/test_cli_stdout.py +32 -0
  17. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_cli_yaml.py +1 -1
  18. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_html_rendering.py +1 -1
  19. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_pagination_smoke.py +1 -1
  20. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_refs_catalog.py +1 -1
  21. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_render_data.py +1 -1
  22. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_schema_validation.py +1 -1
  23. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/tests/test_validator.py +1 -1
  24. pdfgen_juanipis-0.1.3/src/pdfgen/__init__.py +0 -17
  25. pdfgen_juanipis-0.1.3/src/pdfgen/schema.json +0 -126
  26. pdfgen_juanipis-0.1.3/src/pdfgen_juanipis.egg-info/SOURCES.txt +0 -45
  27. pdfgen_juanipis-0.1.3/src/pdfgen_juanipis.egg-info/entry_points.txt +0 -2
  28. pdfgen_juanipis-0.1.3/src/pdfgen_juanipis.egg-info/top_level.txt +0 -1
  29. pdfgen_juanipis-0.1.3/tests/test_api.py +0 -11
  30. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/LICENSE +0 -0
  31. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/setup.cfg +0 -0
  32. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/banner-clean.png +0 -0
  33. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/banner.png +0 -0
  34. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDEEE_Calibri_5.ttf +0 -0
  35. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDFEE_CenturyGothic-Bold_9.ttf +0 -0
  36. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDGEE_CenturyGothic-Bold_14.ttf +0 -0
  37. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDHEE_Calibri-Bold_20.ttf +0 -0
  38. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDIEE_Calibri-Bold_25.ttf +0 -0
  39. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDJEE_Calibri_27.ttf +0 -0
  40. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDKEE_Calibri-Italic_33.ttf +0 -0
  41. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDLEE_Calibri-Italic_52.ttf +0 -0
  42. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDMEE_SegoeUI_54.ttf +0 -0
  43. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDNEE_SegoeUI_60.ttf +0 -0
  44. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDOEE_Aptos Narrow,Bold_142.ttf +0 -0
  45. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCDPEE_Aptos Narrow,Bold_144.ttf +0 -0
  46. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCEAEE_Aptos Narrow_149.ttf +0 -0
  47. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/BCEBEE_Aptos Narrow_154.ttf +0 -0
  48. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/fonts/TimesNewRomanPS-BoldMT_38.ttf +0 -0
  49. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/assets/logo.png +0 -0
  50. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/pagination.py +0 -0
  51. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/templates/boletin.css +0 -0
  52. {pdfgen_juanipis-0.1.3/src/pdfgen → pdfgen_juanipis-0.1.4/src/pdfgen_juanipis}/templates/boletin_template.html.jinja +0 -0
  53. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/src/pdfgen_juanipis.egg-info/dependency_links.txt +0 -0
  54. {pdfgen_juanipis-0.1.3 → pdfgen_juanipis-0.1.4}/src/pdfgen_juanipis.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdfgen-juanipis
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: HTML-to-PDF generator with pagination and validation
5
5
  Author-email: Juan Pablo Díaz Correa <juanipis@gmail.com>
6
6
  License-Expression: MIT
@@ -19,7 +19,7 @@ Requires-Dist: jsonschema==4.23.0
19
19
  Requires-Dist: PyYAML==6.0.2
20
20
  Dynamic: license-file
21
21
 
22
- # pdfgen
22
+ # pdfgen-juanipis
23
23
 
24
24
  Librería para generar PDFs a partir de data estructurada (HTML + WeasyPrint), con paginación, validación y soporte JSON/YAML.
25
25
 
@@ -29,12 +29,18 @@ Desde el repo:
29
29
 
30
30
  ```bash
31
31
  pip install -e .
32
+
33
+ Desde PyPI:
34
+
35
+ ```bash
36
+ pip install pdfgen-juanipis
37
+ ```
32
38
  ```
33
39
 
34
40
  ## Uso básico (Python)
35
41
 
36
42
  ```python
37
- from pdfgen.api import PDFGenConfig, PDFGen
43
+ from pdfgen_juanipis.api import PDFGenConfig, PDFGen
38
44
 
39
45
  config = PDFGenConfig.from_root("/ruta/a/tu/proyecto")
40
46
  pdf = PDFGen(config)
@@ -45,30 +51,40 @@ pdf.render(data, output_path="salida.pdf", paginate=True, validate=True)
45
51
  Atajo:
46
52
 
47
53
  ```python
48
- from pdfgen.api import render_with_defaults
54
+ from pdfgen_juanipis.api import render_with_defaults
49
55
 
50
56
  render_with_defaults(data, output_path="salida.pdf", root_dir="/ruta/a/tu/proyecto")
51
57
  ```
52
58
 
59
+ ## Salida en bytes
60
+
61
+ Si no quieres escribir a disco:
62
+
63
+ ```python
64
+ from pdfgen_juanipis.api import render_with_defaults_bytes
65
+
66
+ pdf_bytes = render_with_defaults_bytes(data, root_dir="/ruta/a/tu/proyecto")
67
+ ```
68
+
53
69
  ## CLI
54
70
 
55
71
  Render (JSON o YAML):
56
72
 
57
73
  ```bash
58
- pdfgen render data.json salida.pdf --root /ruta/proyecto
59
- pdfgen render data.yaml salida.pdf
74
+ pdfgen-juanipis render data.json salida.pdf --root /ruta/proyecto
75
+ pdfgen-juanipis render data.yaml salida.pdf
60
76
  ```
61
77
 
62
78
  Validar (sin generar PDF):
63
79
 
64
80
  ```bash
65
- pdfgen validate data.yaml
81
+ pdfgen-juanipis validate data.yaml
66
82
  ```
67
83
 
68
84
  Desde stdin (YAML por defecto):
69
85
 
70
86
  ```bash
71
- cat data.yaml | pdfgen render - salida.pdf
87
+ cat data.yaml | pdfgen-juanipis render - salida.pdf
72
88
  ```
73
89
 
74
90
  Opciones útiles:
@@ -79,6 +95,7 @@ Opciones útiles:
79
95
  - `--css-extra` inyectar CSS adicional
80
96
  - `--no-validate` desactivar validación
81
97
  - `--no-paginate` desactivar paginación
98
+ - `--stdout` escribir bytes a stdout
82
99
 
83
100
  ## Personalización
84
101
 
@@ -95,7 +112,7 @@ PDFGen(config).render(data, "salida.pdf")
95
112
  Opción B: directorio con `.ttf` desde CLI:
96
113
 
97
114
  ```bash
98
- pdfgen render data.json salida.pdf --fonts-dir /ruta/a/mis/fuentes
115
+ pdfgen-juanipis render data.json salida.pdf --fonts-dir /ruta/a/mis/fuentes
99
116
  ```
100
117
 
101
118
  ### Colores/estilos rápidos
@@ -110,9 +127,13 @@ render_with_defaults(data, "salida.pdf", root_dir="/ruta", css_extra=css_extra)
110
127
  ### Template y CSS propios
111
128
 
112
129
  ```bash
113
- pdfgen render data.json salida.pdf --template-dir /ruta/template --css /ruta/template/boletin.css
130
+ pdfgen-juanipis render data.json salida.pdf --template-dir /ruta/template --css /ruta/template/boletin.css
114
131
  ```
115
132
 
133
+ ### Assets
134
+
135
+ El usuario debe proveer `banner.png` y `logo.png` (o rutas absolutas). Si no usas `assets/` en tu proyecto, indica rutas absolutas en `theme`.
136
+
116
137
  ## Estructura mínima del data
117
138
 
118
139
  ```python
@@ -147,6 +168,10 @@ Los bloques de texto aceptan HTML:
147
168
  ## Ejemplos
148
169
 
149
170
  - `examples/minimal.yaml`
171
+ - `examples/minimal.json`
172
+ - `notebooks/usage.ipynb`
173
+ - `notebooks/bytes.ipynb`
174
+ - `notebooks/advanced.ipynb`
150
175
 
151
176
  ## Validación
152
177
 
@@ -1,4 +1,4 @@
1
- # pdfgen
1
+ # pdfgen-juanipis
2
2
 
3
3
  Librería para generar PDFs a partir de data estructurada (HTML + WeasyPrint), con paginación, validación y soporte JSON/YAML.
4
4
 
@@ -8,12 +8,18 @@ Desde el repo:
8
8
 
9
9
  ```bash
10
10
  pip install -e .
11
+
12
+ Desde PyPI:
13
+
14
+ ```bash
15
+ pip install pdfgen-juanipis
16
+ ```
11
17
  ```
12
18
 
13
19
  ## Uso básico (Python)
14
20
 
15
21
  ```python
16
- from pdfgen.api import PDFGenConfig, PDFGen
22
+ from pdfgen_juanipis.api import PDFGenConfig, PDFGen
17
23
 
18
24
  config = PDFGenConfig.from_root("/ruta/a/tu/proyecto")
19
25
  pdf = PDFGen(config)
@@ -24,30 +30,40 @@ pdf.render(data, output_path="salida.pdf", paginate=True, validate=True)
24
30
  Atajo:
25
31
 
26
32
  ```python
27
- from pdfgen.api import render_with_defaults
33
+ from pdfgen_juanipis.api import render_with_defaults
28
34
 
29
35
  render_with_defaults(data, output_path="salida.pdf", root_dir="/ruta/a/tu/proyecto")
30
36
  ```
31
37
 
38
+ ## Salida en bytes
39
+
40
+ Si no quieres escribir a disco:
41
+
42
+ ```python
43
+ from pdfgen_juanipis.api import render_with_defaults_bytes
44
+
45
+ pdf_bytes = render_with_defaults_bytes(data, root_dir="/ruta/a/tu/proyecto")
46
+ ```
47
+
32
48
  ## CLI
33
49
 
34
50
  Render (JSON o YAML):
35
51
 
36
52
  ```bash
37
- pdfgen render data.json salida.pdf --root /ruta/proyecto
38
- pdfgen render data.yaml salida.pdf
53
+ pdfgen-juanipis render data.json salida.pdf --root /ruta/proyecto
54
+ pdfgen-juanipis render data.yaml salida.pdf
39
55
  ```
40
56
 
41
57
  Validar (sin generar PDF):
42
58
 
43
59
  ```bash
44
- pdfgen validate data.yaml
60
+ pdfgen-juanipis validate data.yaml
45
61
  ```
46
62
 
47
63
  Desde stdin (YAML por defecto):
48
64
 
49
65
  ```bash
50
- cat data.yaml | pdfgen render - salida.pdf
66
+ cat data.yaml | pdfgen-juanipis render - salida.pdf
51
67
  ```
52
68
 
53
69
  Opciones útiles:
@@ -58,6 +74,7 @@ Opciones útiles:
58
74
  - `--css-extra` inyectar CSS adicional
59
75
  - `--no-validate` desactivar validación
60
76
  - `--no-paginate` desactivar paginación
77
+ - `--stdout` escribir bytes a stdout
61
78
 
62
79
  ## Personalización
63
80
 
@@ -74,7 +91,7 @@ PDFGen(config).render(data, "salida.pdf")
74
91
  Opción B: directorio con `.ttf` desde CLI:
75
92
 
76
93
  ```bash
77
- pdfgen render data.json salida.pdf --fonts-dir /ruta/a/mis/fuentes
94
+ pdfgen-juanipis render data.json salida.pdf --fonts-dir /ruta/a/mis/fuentes
78
95
  ```
79
96
 
80
97
  ### Colores/estilos rápidos
@@ -89,9 +106,13 @@ render_with_defaults(data, "salida.pdf", root_dir="/ruta", css_extra=css_extra)
89
106
  ### Template y CSS propios
90
107
 
91
108
  ```bash
92
- pdfgen render data.json salida.pdf --template-dir /ruta/template --css /ruta/template/boletin.css
109
+ pdfgen-juanipis render data.json salida.pdf --template-dir /ruta/template --css /ruta/template/boletin.css
93
110
  ```
94
111
 
112
+ ### Assets
113
+
114
+ El usuario debe proveer `banner.png` y `logo.png` (o rutas absolutas). Si no usas `assets/` en tu proyecto, indica rutas absolutas en `theme`.
115
+
95
116
  ## Estructura mínima del data
96
117
 
97
118
  ```python
@@ -126,6 +147,10 @@ Los bloques de texto aceptan HTML:
126
147
  ## Ejemplos
127
148
 
128
149
  - `examples/minimal.yaml`
150
+ - `examples/minimal.json`
151
+ - `notebooks/usage.ipynb`
152
+ - `notebooks/bytes.ipynb`
153
+ - `notebooks/advanced.ipynb`
129
154
 
130
155
  ## Validación
131
156
 
@@ -146,4 +171,4 @@ MIT
146
171
  Al hacer push a `main`, el workflow **Auto Release** crea tag y Release si la versión en `pyproject.toml` es nueva, y publica automáticamente en PyPI.
147
172
 
148
173
 
149
- Hecho por Juanipis
174
+ Hecho por Juanipis
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pdfgen-juanipis"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "HTML-to-PDF generator with pagination and validation"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -31,7 +31,7 @@ Issues = "https://github.com/Juanipis/pdfgen-juanipis/issues"
31
31
  Source = "https://github.com/Juanipis/pdfgen-juanipis"
32
32
 
33
33
  [project.scripts]
34
- pdfgen = "pdfgen.cli:main"
34
+ pdfgen-juanipis = "pdfgen_juanipis.cli:main"
35
35
 
36
36
  [tool.setuptools]
37
37
  package-dir = {"" = "src"}
@@ -40,7 +40,7 @@ package-dir = {"" = "src"}
40
40
  where = ["src"]
41
41
 
42
42
  [tool.setuptools.package-data]
43
- pdfgen = [
43
+ pdfgen_juanipis = [
44
44
  "schema.json",
45
45
  "templates/*.css",
46
46
  "templates/*.jinja",
@@ -0,0 +1,18 @@
1
+ """PDF generation package."""
2
+
3
+ from pdfgen_juanipis.render import render_pdf, build_sample_data
4
+ from pdfgen_juanipis.validator import validate_and_normalize
5
+ from pdfgen_juanipis.pagination import LayoutConfig, Paginator
6
+ from pdfgen_juanipis.api import PDFGen, PDFGenConfig, render_with_defaults, render_with_defaults_bytes
7
+
8
+ __all__ = [
9
+ "render_pdf",
10
+ "build_sample_data",
11
+ "validate_and_normalize",
12
+ "LayoutConfig",
13
+ "Paginator",
14
+ "PDFGen",
15
+ "PDFGenConfig",
16
+ "render_with_defaults",
17
+ "render_with_defaults_bytes",
18
+ ]
@@ -2,7 +2,7 @@ import pathlib
2
2
  from dataclasses import dataclass
3
3
  from typing import Any, Dict, Optional
4
4
 
5
- from pdfgen.render import render_pdf
5
+ from pdfgen_juanipis.render import render_pdf
6
6
 
7
7
 
8
8
  @dataclass
@@ -55,6 +55,26 @@ class PDFGen:
55
55
  root_dir=self.config.root_dir,
56
56
  )
57
57
 
58
+ def render_bytes(
59
+ self,
60
+ data: Dict[str, Any],
61
+ paginate: bool = True,
62
+ validate: bool = True,
63
+ css_extra: Optional[str] = None,
64
+ ) -> bytes:
65
+ return render_pdf(
66
+ data,
67
+ output_path=None,
68
+ paginate=paginate,
69
+ validate=validate,
70
+ css_extra=css_extra,
71
+ template_dir=self.config.template_dir,
72
+ css_path=self.config.css_path,
73
+ fonts_conf=self.config.fonts_conf,
74
+ root_dir=self.config.root_dir,
75
+ output_bytes=True,
76
+ )
77
+
58
78
 
59
79
  def render_with_defaults(
60
80
  data: Dict[str, Any],
@@ -67,3 +87,15 @@ def render_with_defaults(
67
87
  root = pathlib.Path(root_dir) if root_dir else pathlib.Path.cwd()
68
88
  config = PDFGenConfig.from_root(root)
69
89
  PDFGen(config).render(data, output_path, paginate=paginate, validate=validate, css_extra=css_extra)
90
+
91
+
92
+ def render_with_defaults_bytes(
93
+ data: Dict[str, Any],
94
+ root_dir: Optional[pathlib.Path] = None,
95
+ paginate: bool = True,
96
+ validate: bool = True,
97
+ css_extra: Optional[str] = None,
98
+ ) -> bytes:
99
+ root = pathlib.Path(root_dir) if root_dir else pathlib.Path.cwd()
100
+ config = PDFGenConfig.from_root(root)
101
+ return PDFGen(config).render_bytes(data, paginate=paginate, validate=validate, css_extra=css_extra)
@@ -4,7 +4,7 @@ import pathlib
4
4
  import sys
5
5
  import tempfile
6
6
 
7
- from pdfgen.api import PDFGen, PDFGenConfig
7
+ from pdfgen_juanipis.api import PDFGen, PDFGenConfig
8
8
 
9
9
 
10
10
  def _build_fonts_conf(fonts_dir: pathlib.Path) -> pathlib.Path:
@@ -45,7 +45,7 @@ def _load_data(path: pathlib.Path, fmt: str | None = None):
45
45
 
46
46
 
47
47
  def main(argv=None) -> int:
48
- parser = argparse.ArgumentParser(description="pdfgen CLI")
48
+ parser = argparse.ArgumentParser(description="pdfgen-juanipis CLI")
49
49
  sub = parser.add_subparsers(dest="command", required=True)
50
50
 
51
51
  render = sub.add_parser("render", help="Render a PDF from JSON/YAML")
@@ -60,6 +60,7 @@ def main(argv=None) -> int:
60
60
  render.add_argument("--format", dest="fmt", default=None, help="Input format: json|yaml")
61
61
  render.add_argument("--no-validate", action="store_true")
62
62
  render.add_argument("--no-paginate", action="store_true")
63
+ render.add_argument("--stdout", action="store_true", help="Write PDF bytes to stdout")
63
64
 
64
65
  validate = sub.add_parser("validate", help="Validate JSON/YAML input against schema")
65
66
  validate.add_argument("input", help="Path to JSON/YAML data (or - for stdin)")
@@ -69,7 +70,7 @@ def main(argv=None) -> int:
69
70
  args = parser.parse_args(argv)
70
71
 
71
72
  if args.command == "validate":
72
- from pdfgen.validator import validate_and_normalize
73
+ from pdfgen_juanipis.validator import validate_and_normalize
73
74
 
74
75
  root_dir = pathlib.Path(args.root_dir)
75
76
  data = _load_data(pathlib.Path(args.input), fmt=args.fmt)
@@ -92,6 +93,16 @@ def main(argv=None) -> int:
92
93
 
93
94
  data = _load_data(pathlib.Path(args.input), fmt=args.fmt)
94
95
 
96
+ if args.stdout:
97
+ pdf_bytes = PDFGen(config).render_bytes(
98
+ data,
99
+ paginate=not args.no_paginate,
100
+ validate=not args.no_validate,
101
+ css_extra=args.css_extra,
102
+ )
103
+ sys.stdout.buffer.write(pdf_bytes)
104
+ return 0
105
+
95
106
  PDFGen(config).render(
96
107
  data,
97
108
  output_path=pathlib.Path(args.output),
@@ -8,8 +8,8 @@ from weasyprint import HTML, CSS
8
8
  if __name__ == "__main__" and __package__ is None:
9
9
  sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "src"))
10
10
 
11
- from pdfgen.pagination import LayoutConfig, Paginator
12
- from pdfgen.validator import validate_and_normalize
11
+ from pdfgen_juanipis.pagination import LayoutConfig, Paginator
12
+ from pdfgen_juanipis.validator import validate_and_normalize
13
13
 
14
14
  ROOT = pathlib.Path(__file__).resolve().parents[2]
15
15
  PACKAGE_ROOT = pathlib.Path(__file__).resolve().parent
@@ -303,6 +303,7 @@ def render_pdf(
303
303
  fonts_conf=None,
304
304
  css_extra=None,
305
305
  root_dir=None,
306
+ output_bytes=False,
306
307
  ):
307
308
  root_dir = pathlib.Path(root_dir) if root_dir else ROOT
308
309
  template_dir = pathlib.Path(template_dir) if template_dir else TEMPLATE_DIR
@@ -334,7 +335,13 @@ def render_pdf(
334
335
  if css_extra:
335
336
  stylesheets.append(CSS(string=str(css_extra)))
336
337
 
338
+ if output_bytes or output_path is None:
339
+ return HTML(string=html, base_url=str(root_dir)).write_pdf(
340
+ stylesheets=stylesheets
341
+ )
342
+
337
343
  HTML(string=html, base_url=str(root_dir)).write_pdf(output_path, stylesheets=stylesheets)
344
+ return None
338
345
 
339
346
  print(f"Wrote {output_path}")
340
347
 
@@ -0,0 +1,272 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "PDFGenJuanipisDocument",
4
+ "type": "object",
5
+ "additionalProperties": true,
6
+ "properties": {
7
+ "title": {
8
+ "type": "string"
9
+ },
10
+ "refs_catalog": {
11
+ "type": "object",
12
+ "additionalProperties": {
13
+ "type": "string"
14
+ }
15
+ },
16
+ "theme": {
17
+ "type": "object",
18
+ "properties": {
19
+ "header_banner_path": {
20
+ "type": "string"
21
+ },
22
+ "header_banner_path_cont": {
23
+ "type": "string"
24
+ },
25
+ "header_logo_path": {
26
+ "type": "string"
27
+ },
28
+ "title_line1": {
29
+ "type": "string"
30
+ },
31
+ "title_line2": {
32
+ "type": "string"
33
+ },
34
+ "footer_site": {
35
+ "type": "string"
36
+ },
37
+ "footer_phone": {
38
+ "type": "string"
39
+ },
40
+ "show_header_titles": {
41
+ "type": "boolean"
42
+ }
43
+ },
44
+ "additionalProperties": true
45
+ },
46
+ "sections": {
47
+ "type": "array",
48
+ "items": {
49
+ "$ref": "#/definitions/section"
50
+ }
51
+ },
52
+ "pages": {
53
+ "type": "array",
54
+ "items": {
55
+ "$ref": "#/definitions/page"
56
+ }
57
+ }
58
+ },
59
+ "anyOf": [
60
+ {
61
+ "required": [
62
+ "sections"
63
+ ]
64
+ },
65
+ {
66
+ "required": [
67
+ "pages"
68
+ ]
69
+ }
70
+ ],
71
+ "definitions": {
72
+ "section": {
73
+ "type": "object",
74
+ "properties": {
75
+ "title": {
76
+ "type": "string"
77
+ },
78
+ "subtitle": {
79
+ "type": "string"
80
+ },
81
+ "content": {
82
+ "type": "array",
83
+ "items": {
84
+ "$ref": "#/definitions/block"
85
+ }
86
+ },
87
+ "refs": {
88
+ "type": "array",
89
+ "items": {
90
+ "type": "string"
91
+ }
92
+ },
93
+ "footer_notes": {
94
+ "type": "array",
95
+ "items": {
96
+ "type": "string"
97
+ }
98
+ }
99
+ },
100
+ "required": [
101
+ "content"
102
+ ],
103
+ "additionalProperties": true
104
+ },
105
+ "page": {
106
+ "type": "object",
107
+ "properties": {
108
+ "blocks": {
109
+ "type": "array",
110
+ "items": {
111
+ "$ref": "#/definitions/block"
112
+ }
113
+ },
114
+ "refs": {
115
+ "type": "array",
116
+ "items": {
117
+ "type": "string"
118
+ }
119
+ },
120
+ "footer_notes": {
121
+ "type": "array",
122
+ "items": {
123
+ "type": "string"
124
+ }
125
+ }
126
+ },
127
+ "required": [
128
+ "blocks"
129
+ ],
130
+ "additionalProperties": true
131
+ },
132
+ "block": {
133
+ "type": "object",
134
+ "properties": {
135
+ "type": {
136
+ "type": "string",
137
+ "enum": [
138
+ "text",
139
+ "table",
140
+ "figure",
141
+ "map_grid",
142
+ "html"
143
+ ]
144
+ },
145
+ "text": {
146
+ "type": [
147
+ "string",
148
+ "array"
149
+ ],
150
+ "items": {
151
+ "type": "string"
152
+ }
153
+ },
154
+ "html": {
155
+ "type": "string"
156
+ },
157
+ "refs": {
158
+ "type": "array",
159
+ "items": {
160
+ "type": "string"
161
+ }
162
+ },
163
+ "footer_notes": {
164
+ "type": "array",
165
+ "items": {
166
+ "type": "string"
167
+ }
168
+ },
169
+ "table": {
170
+ "$ref": "#/definitions/table"
171
+ },
172
+ "path": {
173
+ "type": "string"
174
+ },
175
+ "caption": {
176
+ "type": "string"
177
+ },
178
+ "wide": {
179
+ "type": "boolean"
180
+ },
181
+ "items": {
182
+ "type": "array",
183
+ "items": {
184
+ "type": "object",
185
+ "properties": {
186
+ "path": {
187
+ "type": "string"
188
+ },
189
+ "label": {
190
+ "type": "string"
191
+ }
192
+ },
193
+ "required": [
194
+ "path"
195
+ ],
196
+ "additionalProperties": true
197
+ }
198
+ },
199
+ "source": {
200
+ "type": "string"
201
+ }
202
+ },
203
+ "required": [
204
+ "type"
205
+ ],
206
+ "additionalProperties": true
207
+ },
208
+ "table": {
209
+ "type": "object",
210
+ "properties": {
211
+ "groups": {
212
+ "type": "array",
213
+ "items": {
214
+ "type": "object",
215
+ "properties": {
216
+ "title": {
217
+ "type": "string"
218
+ },
219
+ "months": {
220
+ "type": "array",
221
+ "items": {
222
+ "type": "string"
223
+ }
224
+ }
225
+ },
226
+ "required": [
227
+ "title",
228
+ "months"
229
+ ],
230
+ "additionalProperties": true
231
+ }
232
+ },
233
+ "rows": {
234
+ "type": "array",
235
+ "items": {
236
+ "type": "object",
237
+ "properties": {
238
+ "dep": {
239
+ "type": "string"
240
+ },
241
+ "vals": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "string"
245
+ }
246
+ }
247
+ },
248
+ "required": [
249
+ "dep",
250
+ "vals"
251
+ ],
252
+ "additionalProperties": true
253
+ }
254
+ },
255
+ "total_width": {
256
+ "type": "number"
257
+ },
258
+ "dep_width": {
259
+ "type": "number"
260
+ },
261
+ "show_header": {
262
+ "type": "boolean"
263
+ }
264
+ },
265
+ "required": [
266
+ "groups",
267
+ "rows"
268
+ ],
269
+ "additionalProperties": true
270
+ }
271
+ }
272
+ }
@@ -220,7 +220,7 @@ def _extract_ref_ids(text: str) -> List[str]:
220
220
 
221
221
  def _validate_schema(data: Dict[str, Any], root_dir: pathlib.Path) -> List[str]:
222
222
  warnings: List[str] = []
223
- schema_path = root_dir / "src" / "pdfgen" / "schema.json"
223
+ schema_path = root_dir / "src" / "pdfgen_juanipis" / "schema.json"
224
224
  if not schema_path.exists():
225
225
  schema_path = pathlib.Path(__file__).resolve().parent / "schema.json"
226
226
  if not schema_path.exists():