Skip to content

Commit 709ad42

Browse files
authored
Merge pull request #162 from DemchaAV/docs/word-export-example
Word-export companion + library-wide import/Javadoc cleanup + ConfigLoader removal
2 parents 40d854a + 17e89da commit 709ad42

344 files changed

Lines changed: 7764 additions & 8178 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ jobs:
147147
run: ./mvnw -B -ntp test -pl . -P no-poi
148148

149149
binary-compat:
150-
name: Binary Compatibility (japicmp vs v1.6.9)
150+
name: Binary Compatibility (japicmp vs pom baseline)
151151
if: github.event_name == 'pull_request'
152152
needs: architecture-and-documentation-guards
153153
runs-on: ubuntu-latest
@@ -166,8 +166,9 @@ jobs:
166166
cache: maven
167167

168168
- name: Compare public API against baseline
169-
# The `japicmp` profile resolves the prior published jar
170-
# (v1.6.8 from Maven Central) and diffs it against the
169+
# The `japicmp` profile resolves the baseline release pinned
170+
# by the `japicmp.baseline` property in pom.xml (via the
171+
# profile-local JitPack repository) and diffs it against the
171172
# freshly-built artifact. Fails the job on any binary-
172173
# incompatible modification to the public surface. Source-
173174
# incompatible changes are reported only (phased policy).

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ Entries land here as they merge.
9595
not fit in the remaining page space relocates whole to the next page instead
9696
of orphaning its heading from the content below. Blocks taller than a page
9797
still flow. Default off — existing layouts are byte-identical.
98+
- **Removed: `ConfigLoader`** (breaking). The `com.demcha.compose.ConfigLoader`
99+
YAML/JSON config-file helper was an application-bootstrap utility with no
100+
connection to document rendering — nothing in the library, tests, or
101+
examples referenced it. Gone with it: the `<optional>`
102+
`jackson-dataformat-yaml` dependency (ConfigLoader was its only consumer)
103+
and the YAML entry in the `NoClassDefFoundError` troubleshooting section.
104+
Consumers who relied on the helper can copy the former ~100-line class into
105+
their own codebase or load configs directly with Jackson
106+
(`new ObjectMapper(new YAMLFactory()).readValue(...)`).
98107

99108
### Bug fixes
100109

@@ -136,6 +145,15 @@ Entries land here as they merge.
136145
regression testing. Every snippet is verified against the current API;
137146
the folder index (`docs/recipes/README.md`) no longer carries a
138147
"not yet covered" list.
148+
- **Word-export example.** New `WordExportExample`
149+
(`examples/features/docx`) renders the same `DocumentSession` as a
150+
fixed-layout PDF *and* an editable Word file via `DocxSemanticBackend`,
151+
one section per capability-table row: inline runs, nested lists with
152+
custom markers, tables, side-by-side rows, an embedded image, a page
153+
break, the chart→data-table fallback, and the geometry that stays
154+
PDF-only. Committed previews live under `assets/readme/examples/`
155+
(`word-export-companion.pdf` / `.docx`); the examples module adds the
156+
optional `poi-ooxml` dependency exactly like a consuming project would.
139157
- **`BusinessReportExample` chart is now a native vector chart.** The flagship
140158
report's five-quarter Revenue/Profit block previously rasterised a bar chart
141159
through Graphics2D into an embedded PNG; it now uses `ChartSpec.bar()` with a
7.8 KB
Binary file not shown.
12.6 KB
Binary file not shown.

docs/troubleshooting.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Per-feature mapping: [canonical ↔ legacy parity matrix](architecture/canonical
3939

4040
## `NoClassDefFoundError` at runtime
4141

42-
GraphCompose marks two heavy, rarely-needed dependencies **optional** so
43-
PDF-only consumers don't pay for them. If you use the feature, add the
42+
GraphCompose marks one heavy, rarely-needed dependency **optional** so
43+
PDF-only consumers don't pay for it. If you use DOCX export, add the
4444
dependency to **your** project.
4545

4646
**DOCX export**`document.export(new DocxSemanticBackend())` needs
@@ -54,20 +54,6 @@ Apache POI on your classpath:
5454
</dependency>
5555
```
5656

57-
**YAML config** — loading a `*.yaml` / `*.yml` resource through
58-
`ConfigLoader` needs the Jackson YAML dataformat (the error names
59-
`YAMLFactory`):
60-
61-
```xml
62-
<dependency>
63-
<groupId>com.fasterxml.jackson.dataformat</groupId>
64-
<artifactId>jackson-dataformat-yaml</artifactId>
65-
<!-- version: match the Jackson you already depend on -->
66-
</dependency>
67-
```
68-
69-
…or load a JSON config instead, which needs no extra dependency.
70-
7157
## The bundled examples won't resolve `graph-compose`
7258

7359
**Cause.** `examples/` is a **separate Maven module** that depends on the

examples/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ are with the canonical DSL, then jump to its detailed section below.
9393
| [Charts](#charts) | Native vector bar, line, and pie/donut charts — data/spec/style layers, axis & grid toggles, point markers, value labels, legend | [PDF](../assets/readme/examples/chart-showcase.pdf) · [Source](src/main/java/com/demcha/examples/features/charts/ChartShowcaseExample.java) |
9494
| [PDF chrome](#pdf-chrome) | `DocumentMetadata`, `DocumentWatermark`, `DocumentHeaderFooter`, `DocumentBookmarkOptions` | [PDF](../assets/readme/examples/pdf-chrome.pdf) · [Source](src/main/java/com/demcha/examples/features/chrome/PdfChromeExample.java) |
9595
| [HTTP streaming](#http-streaming) | `writePdf(OutputStream)` for Servlet / S3 / GCS — caller's stream is not closed | [PDF](../assets/readme/examples/invoice-http-stream.pdf) · [Source](src/main/java/com/demcha/examples/features/streaming/HttpStreamingExample.java) |
96+
| [Word export (DOCX)](#word-export-docx) | `DocxSemanticBackend` — the same session renders a fixed-layout PDF and an editable Word file; paragraphs / lists / tables / images map 1:1, charts fall back to their data table | [PDF](../assets/readme/examples/word-export-companion.pdf) · [DOCX](../assets/readme/examples/word-export-companion.docx) · [Source](src/main/java/com/demcha/examples/features/docx/WordExportExample.java) |
9697
| [Layout snapshot regression](#layout-snapshot-regression) | Deterministic `layoutSnapshot()` workflow with baseline + drift report — production regression-testing pattern | [PDF](../assets/readme/examples/invoice-snapshot-regression.pdf) · [Source](src/main/java/com/demcha/examples/features/snapshots/LayoutSnapshotRegressionExample.java) |
9798
| [Business report cover](#business-report-cover) | Single-page Q1 investor brief — hero image, KPI cards, bar chart, metrics table | [PDF](../assets/readme/examples/business-report.pdf) · [Source](src/main/java/com/demcha/examples/flagships/BusinessReportExample.java) |
9899
| [Master showcase](#master-showcase) | Kitchen-sink "Q2 sample report" combining the canonical surface end-to-end | [PDF](../assets/readme/examples/master-showcase.pdf) · [Source](src/main/java/com/demcha/examples/flagships/MasterShowcaseExample.java) |
@@ -576,6 +577,47 @@ public ResponseEntity<StreamingResponseBody> invoice(@PathVariable Long id) {
576577
[📄 View PDF](../assets/readme/examples/invoice-http-stream.pdf) ·
577578
[📜 Full source](src/main/java/com/demcha/examples/features/streaming/HttpStreamingExample.java)
578579

580+
### Word export (DOCX)
581+
582+
The semantic backend walks the document graph and writes **editable
583+
Word content** — no layout pass, no PDF chrome. One session, two
584+
outputs:
585+
586+
```java
587+
try (DocumentSession document = GraphCompose.document(pdfFile)
588+
.pageSize(595, 842)
589+
.margin(DocumentInsets.of(48))
590+
.create()) {
591+
document.metadata(DocumentMetadata.builder()
592+
.title("GraphCompose Word export companion")
593+
.author("GraphCompose").build()); // → Word core properties
594+
595+
document.pageFlow().name("Flow")
596+
.addRich(rich -> rich.plain("Inline ").bold("runs").plain(" survive."))
597+
.addList(list -> list.markerFor(1, ListMarker.custom(""))
598+
.addItem("Nested authoring", l1 -> l1
599+
.addItem("Two spaces of indent per depth in Word")))
600+
.addTable(t -> t.headerRow("Quarter", "Revenue").row("Q1", "42"))
601+
.addSection("Chart", s -> s.chart(ChartSpec.bar().data(quarters).build()))
602+
.build();
603+
604+
document.buildPdf(); // fixed-layout PDF
605+
document.export(new DocxSemanticBackend(), docxFile); // editable Word file
606+
}
607+
```
608+
609+
Paragraphs (inline runs included), lists, tables, side-by-side rows,
610+
images, spacers, and page breaks map 1:1; session metadata lands in the
611+
Word core properties. Charts export as their categories-by-series data
612+
table (one capability warning per export), shape containers flatten to
613+
inline layers, and pure geometry — dividers, shapes, barcodes — stays
614+
PDF-only by design. Requires `org.apache.poi:poi-ooxml` on the
615+
classpath (the dependency is optional in the GraphCompose POM).
616+
617+
[📄 View PDF](../assets/readme/examples/word-export-companion.pdf) ·
618+
[📝 Word file](../assets/readme/examples/word-export-companion.docx) ·
619+
[📜 Full source](src/main/java/com/demcha/examples/features/docx/WordExportExample.java)
620+
579621
### Layout snapshot regression
580622

581623
The full `compose → layoutSnapshot() → LayoutSnapshotJson.toJson(...)`

examples/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@
4444
<version>${graphcompose.version}</version>
4545
</dependency>
4646

47+
<!-- DOCX export (WordExportExample): poi-ooxml is optional in the
48+
GraphCompose POM, so consumers add it explicitly.
49+
Keep in lockstep with the root pom's poi.version. -->
50+
<dependency>
51+
<groupId>org.apache.poi</groupId>
52+
<artifactId>poi-ooxml</artifactId>
53+
<version>5.5.1</version>
54+
</dependency>
55+
4756
<dependency>
4857
<groupId>ch.qos.logback</groupId>
4958
<artifactId>logback-classic</artifactId>

examples/src/main/java/com/demcha/examples/GenerateAllExamples.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.demcha.examples.features.barcodes.BarcodeShowcaseExample;
44
import com.demcha.examples.features.charts.ChartShowcaseExample;
55
import com.demcha.examples.features.canvas.CanvasLayerExample;
6+
import com.demcha.examples.features.docx.WordExportExample;
67
import com.demcha.examples.features.chrome.PdfChromeExample;
78
import com.demcha.examples.features.lists.NestedListExample;
89
import com.demcha.examples.features.shapes.ShapeContainerExample;
@@ -138,6 +139,9 @@ public static void main(String[] args) throws Exception {
138139
System.out.println("Generated: " + CustomBusinessThemeExample.generate());
139140
System.out.println("Generated: " + PdfChromeExample.generate());
140141

142+
// DOCX export
143+
System.out.println("Generated: " + WordExportExample.generate());
144+
141145
// Barcodes
142146
System.out.println("Generated: " + BarcodeShowcaseExample.generate());
143147

0 commit comments

Comments
 (0)