### Node.js Migration Tool Examples Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0705_migration_tool.adoc Examples demonstrating how to use the Node.js migration tool for a single file or the current directory. ```bash # file print-model-migration my-print-model.json --backup # current folder print-model-migration . --backup ``` -------------------------------- ### Install Node.js Migration Tool Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0705_migration_tool.adoc Install the latest version of the Node.js based migration tool globally using pnpm. ```bash pnpm install -g @com.mgmtp.a12.print/print-model-migration ``` -------------------------------- ### Start Print Shell Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter04/04_migration.adoc Command to launch the print-shell interface. Ensure Java 21 is installed and accessible. ```bash java -jar print-shell-[PrintEngineVersion].jar ``` -------------------------------- ### Spring Configuration Class Example Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0302_configuration.adoc Example of a Spring configuration class for the Print Engine. Includes loading Print Model content, IDocumentModel, and customizing fonts. ```java @Configuration public class PrintShellConfiguration { @Bean public PrintEngineConfig printEngineConfig() { final PrintEngineConfig printEngineConfig = new PrintEngineConfig(); // Load Print Model content. // The implementation should be changed by your local service accordingly. printEngineConfig.setPrintModel(new PrintModel("classpath:/print/print-model.xml")); // Load IDocumentModel. // The implementation should be changed by your local service accordingly. printEngineConfig.setDocumentModel(new DocumentModel("classpath:/print/document-model.xml")); // Customization fonts could be set for the PrintEngineConfig. printEngineConfig.addFont("customFont", "classpath:/fonts/custom.ttf"); return printEngineConfig; } @Bean public PrintJobManager printJobManager(final PrintEngineConfig printEngineConfig) { final PrintJobManagerApi printJobManagerApi = new PrintJobManagerApi() { @Override public void print(final PrintJob printJob) { // TODO Auto-generated method stub } @Override public void print(final PrintJob printJob, final PrintJobListener printJobListener) { // TODO Auto-generated method stub } @Override public void print(final PrintJob printJob, final PrintJobListener printJobListener, final ExecutorService executorService) { // TODO Auto-generated method stub } @Override public void print(final PrintJob printJob, final PrintJobListener printJobListener, final ExecutorService executorService, final PrintEngineConfig printEngineConfig) { // TODO Auto-generated method stub } @Override public void print(final PrintJob printJob, final PrintJobListener printJobListener, final ExecutorService executorService, final PrintEngineConfig printEngineConfig, final PrintJobManagerConfig printJobManagerConfig) { // TODO Auto-generated method stub } }; final ExecutorService executorService = ExecutorServiceFactory.getInstance(Runtime.getRuntime().availableProcessors(), "print-pool"); return new PrintJobManager(printJobManagerApi, executorService, new PdfBoxPrintEngine(printEngineConfig), true); } } ``` -------------------------------- ### Java Migration Tool Examples Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0705_migration_tool.adoc Examples of using the Java migration tool with relative and absolute workspace paths. The --overwrite false flag is optional and acts as a backup mechanism. ```bash # relative path java -jar print-shell-2.1.3.jar migrate --workspace foldername --overwrite false # absolute path java -jar print-shell-2.1.3.jar migrate --workspace C:\Test\check\foldername --overwrite false ``` -------------------------------- ### Start the Print Engine Test App Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Navigate to the test-app directory and run this command to start the Test App, which serves as a development Print Model Editor. ```Shell cd test-app pnpm start ``` -------------------------------- ### Install Print Model Editor Component Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter05/0501_dependency.adoc Use this command to install the required print-model-editor-component package. Ensure your project has compatible peer dependencies. ```bash pnpm install @com.mgmtp.a12.print/print-model-editor-component ``` -------------------------------- ### Start Print Shell CLI Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Navigate to the print-shell directory and execute the JAR file to start the print-shell CLI tool. This tool provides commands for migrating print models and managing print jobs. ```Shell cd print-shell java -jar build/libs/print-shell-.jar ``` -------------------------------- ### Generate Frontend Component SBOM Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Execute the Gradle wrapper command to generate an SBOM for frontend components using Trivy. Ensure Trivy is installed beforehand. The SBOM will be saved in JSON format. ```Bash ./gradlew generatePnpmSbom ``` -------------------------------- ### Install Playwright Browser Dependency Source: https://github.com/mgm-tp/a12-print/blob/main/README.md This command installs the necessary browser dependency for running Playwright E2E tests within the Test App. ```Shell pnpm run chromium ``` -------------------------------- ### Reference Metadata Path Example Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_listing.adoc Demonstrates how to use the 'path' metadata field to reference an element's path as a string value within computations. This is useful for dynamic path comparisons. ```asciidoc [metadata/customer/addresses/isPublic/path] ``` -------------------------------- ### Run Playwright E2E Tests Source: https://github.com/mgm-tp/a12-print/blob/main/README.md After installing the browser dependency, use this command to execute the End-to-End tests for the Test App using Playwright. ```Shell pnpm run test ``` -------------------------------- ### Categorized Data Example - Resulting Dataset Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc Illustrates the resulting dataset after processing the Document data for categorized data, showing aggregated values per label. ```text A : 3 B : 1 ``` -------------------------------- ### Line Chart Series Data Example - Resulting Datasets Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc The resulting datasets derived from the input data for the Line Chart Series Data example. Each dataset corresponds to a 'Name of series' defined during modeling. ```plaintext DataSet1: [10,20,15] DataSet2: [1,4,6] ``` -------------------------------- ### Categorized Data Example - Data Modeling Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc Demonstrates how to model categorized data for a Bar Chart by specifying the 'Field with value' and 'Field for labels' from the Document Model. ```asciidoc [%header] |=== |Field with value|Field for labels |`root/Person/income`|`root/Person/occupation` |=== ``` -------------------------------- ### Build the Entire Project with Gradle Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Execute this command in the repository root to build all modules of the Print Engine project. ```Shell ./gradlew assemble ``` -------------------------------- ### Categorized Data Example - Document Data Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc Shows the structure of the Document data used to generate the categorized data example for a Bar Chart. ```yaml Person[0]: occupation: "A" income: 1 Person[1]: occupation: "A" income: 2 Person[2]: occupation: "B" income: 1 ``` -------------------------------- ### Publish Backend and Frontend Artifacts Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Use the Gradle wrapper to publish both backend and frontend component artifacts. This task automatically includes SBOM generation and requires specific properties to be set for frontend publishing. ```Bash ./gradlew publish ``` -------------------------------- ### Generate Backend Component SBOM Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Run the Gradle wrapper command to generate a Software Bill of Materials (SBOM) for backend components. The SBOM will be saved in JSON format. ```Bash ./gradlew cyclonedxDirectBom ``` -------------------------------- ### Hide Group Precondition Example Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_listing.adoc Hides a repeating group if a specific boolean field within it is marked as false. This example demonstrates conditional visibility for entire groups based on their properties. ```asciidoc Precondition: `[path] == [metadata/customer/addresses/isPublic/path] And [value] == False` Operation: `True` ``` -------------------------------- ### Migrate Print Model with Java Tool (Older Versions) Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0705_migration_tool.adoc Execute the Java-based migration tool for Print Model versions earlier than 2.1.0. Use --overwrite false to keep original files if not under version control. ```bash java -jar print-shell-2.1.3.jar migrate [OPTIONS] ``` -------------------------------- ### Line Chart Series Data Example - Input Data Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc Example of the Document Model data structure used for the Line Chart Series Data. It shows repeatable 'Person' groups with 'income' and 'tax' fields. ```plaintext Person[0]: income: 10 tax: 1 Person[1]: income: 20 tax: 4 Person[2]: income: 15 tax: 6 ``` -------------------------------- ### Test the Entire Project with Gradle Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Execute this command to run all tests across all modules in the Print Engine project. ```Shell ./gradlew check ``` -------------------------------- ### Line Chart Series Data Example Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_charts.adoc Model Series Data for a Line Chart by selecting repeatable fields. The 'Field with value' specifies the data for the axis defined by Orientation, while the other axis counts through repetitions. This example shows mapping 'income' and 'tax' fields to 'DataSet1' and 'DataSet2' respectively. ```asciidoc [%header] |=== |Field with value|Name of series |`root/Person/income`|DataSet1 |`root/Person/tax`|DataSet2 |=== ``` -------------------------------- ### Get Current Field Label Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter03/elements/03_listing.adoc Retrieves the label of the current entity within a listing. ```asciidoc ``[relativeMetadata/label]`` ``` -------------------------------- ### Usage of PdfBoxPrintEngine Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0703_2025.06-ext-2.adoc This snippet demonstrates the instantiation of the new PdfBoxPrintEngine. It requires a PrintJobManager with an additional boolean flag and a PdfBoxPrintEngine instance. ```java PrintJobManager printJobManager = new PrintJobManager(pool, printJobManagerApi, PrintJobConfig.DEFAULT, true); PdfBoxPrintEngine pdfBoxPrintEngine = new PdfBoxPrintEngine(pool, PdfBoxPrintEngineConfig.DEFAULT); ``` -------------------------------- ### Custom Fonts Configuration Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter05/0502_usage.adoc Example of how to configure custom fonts for the PrintModelEditorLight component, including specifying font source via URL or Data URI and format. ```tsx const customFonts: FontResourceMap = { "CustomFont1": { src: "./assets/fonts/custom-font-1.ttf", format: "ttf", }, "CustomFont2": { src: "https://my-cdn.com/fonts/custom-font-2.ttf", format: "ttf", }, "CustomFont3": { src: "data:application/octet-stream;base64,...", format: "ttf", }, }; ``` -------------------------------- ### List Available Codemod Recipes Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0706_codemod.adoc View a list of all available codemod recipes by running the tool with the --list flag. ```bash npx @com.mgmtp.a12.print/print-engine-codemod@latest --list ``` -------------------------------- ### Compile Frontend Code with pnpm Source: https://github.com/mgm-tp/a12-print/blob/main/README.md For modules with frontend code, this command compiles it without rerunning the Gradle build. Useful for development. ```Shell pnpm compile ``` -------------------------------- ### Test an Individual Module with Gradle Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Use this command to run tests for a specific module. Replace '' with the actual module name. ```Shell ./gradlew ::check ``` -------------------------------- ### Migrate Print Model with Node.js Tool Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0705_migration_tool.adoc Perform the migration of Print Model files using the Node.js tool. Use the --backup flag to create backups if files are not under version control. ```bash print-model-migration --backup ``` -------------------------------- ### Top-Level TypeScript Imports (Recommended) Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0702_2025.06-ext-4.adoc These are examples of top-level imports in TypeScript that are recommended to replace deep-level imports. They import multiple types from a single, top-level package path. ```typescript import { PossibleInputSource, InputValueSourceResolver, InputSourceGenerator } from "@com.mgmtp.a12.print/print-model-api"; ``` -------------------------------- ### Deep-Level TypeScript Imports (Deprecated) Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0702_2025.06-ext-4.adoc These are examples of deep-level imports in TypeScript that are deprecated and will be removed in a future release. They import specific modules from various sub-paths within the print packages. ```typescript import { PossibleInputSource } from "@com.mgmtp.a12.print/print-model-api/lib/input-source/input-source.js"; import { InputSourceGenerator } from "@com.mgmtp.a12.print/print-model-api-utils/lib/input-source/input-source-generator.js"; import { InputValueSourceResolver } from "@com.mgmtp.a12.print/print-engine-core/lib/input-source/input-source-resolver.js"; import { DeepPartialErrorMap } from "@com.mgmtp.a12.print/print-model-api-utils/lib/errors/deep-partial-error-map.js"; import { PrintModelMarshaller } from "@com.mgmtp.a12.print/print-model-api-utils/lib/marshaller/model-marshaller.js"; import { ElementDefinitionMarshaller } from "@com.mgmtp.a12.print/print-model-api-utils/lib/marshaller/element-definition-marshaller.js"; ``` -------------------------------- ### Generate Schemas from Model Interface Source: https://github.com/mgm-tp/a12-print/blob/main/model-migration/README.md Run this command to generate schemas from the model interface for each migration step. Schemas are necessary for type-system based correctness proofs. ```bash pnpm generate-schema ``` -------------------------------- ### KernelDocumentV2Provider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter02/0202_print_engine_runtime.adoc Interface for loading A12 Kernel _DocumentV2_. ```APIDOC ## KernelDocumentV2Provider ### Description Interface for loading A12 Kernel _DocumentV2_. ### Method Not applicable (Interface definition) ### Endpoint Not applicable (Interface definition) ### Parameters Not applicable (Interface definition) ### Request Example Not applicable (Interface definition) ### Response Not applicable (Interface definition) ``` -------------------------------- ### Create PrintJob with TypesettingModelProvider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0303_usage.adoc Configure a PrintJob to provide Typesetting Models to the PdfBoxPrintEngine. ```java PrintJob printJob = new PrintJob(); printJob.withProvider(new TypesettingModelProvider()); ``` -------------------------------- ### Build an Individual Module with Gradle Source: https://github.com/mgm-tp/a12-print/blob/main/README.md Use this command to build a specific module within the Print Engine project. Replace '' with the actual module name. ```Shell ./gradlew :engine-runtime:assemble ``` -------------------------------- ### Migrate Print Models via CLI Source: https://github.com/mgm-tp/a12-print/blob/main/model-migration/README.md Execute this command to migrate print models to the latest version using the CLI. Adjust the path to the script and provide the folder path containing your print models. ```bash node ./src/main/bin/print-model-migration.cjs ``` -------------------------------- ### Print All Print Models in Workspace Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-modeling-documentation/asciidoc/chapter04/04_migration.adoc Prints all Print Models within the current workspace. Allows configuration of timezone, locale, experimental rendering, suffix, and filtering. ```bash print-all -w workspacePath -t timeZone --locale localeString --useExperimentalRendering useExperimentalRendering --suffix suffix --filter filter ``` -------------------------------- ### Test Frontend Code with pnpm Source: https://github.com/mgm-tp/a12-print/blob/main/README.md This command is used to run frontend-specific tests within a module. ```Shell pnpm test ``` -------------------------------- ### TypeScript: Importing and Using PrintModelMarshaller Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0704_2025.06.adoc Demonstrates how to import the PrintModelMarshaller from the new '@com.mgmtp.a12.print/print-model-api-utils' package and use it for deserialization with document model validation. ```typescript import { PrintModelMarshaller } from "@com.mgmtp.a12.print/print-model-api-utils/lib/marshaller/index.js"; const printModelMarshaller = new PrintModelMarshaller(); const deserializedResult = printModelMarshaller.deserialize(printModel, documentModels); ``` -------------------------------- ### Create PrintJob with AttachmentProvider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0303_usage.adoc Configure a PrintJob with an AttachmentProvider, providing attachments as ByteArrayInputStream. ```java PrintJob printJob = new PrintJob(); printJob.withProvider(new AttachmentPrintJobProvider()); ``` -------------------------------- ### JSON: Print Model Header with Description Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter07/0704_2025.06.adoc Illustrates the new JSON structure for a print model, showing the 'description' field moved to the 'header' object. ```json { "header": { "id": "print-model", "modelType": "print", "modelVersion": "3.0.0", "description": "Description" }, "content": { ... } } ``` -------------------------------- ### Generate New Migration Step Template Source: https://github.com/mgm-tp/a12-print/blob/main/model-migration/README.md Use this command to generate a new template for a migration step, including the model interface and transform function. ```bash pnpm generate-step ``` -------------------------------- ### Create PrintJobManager and PrintEngine Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0302_configuration.adoc Instantiates PrintJobManager and either PdfBoxPrintEngine or PdfPrintEngine (Deprecated). Be aware of the usePdfBoxPrintProcess flag for rendering mode selection. ```java final PrintJobManager printJobManager = new PrintJobManager(printJobManagerApi, executorService, new PdfBoxPrintEngine(), true); ``` -------------------------------- ### KernelDocumentV2Provider Interface Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter02/0202_print_engine_runtime.adoc Interface for loading A12 Kernel DocumentV2. ```java include::../../sourceCode/engine-runtime/main/java/com/mgmtp/a12/print/engine/runtime/KernelDocumentV2Provider.java[tag=!*] ``` -------------------------------- ### Create PrintJob with KernelDocumentV2Provider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0303_usage.adoc Configure a PrintJob with a document provider for DocumentV2. This is an integration point for custom document providers. ```java PrintJob printJob = new PrintJob(); printJob.withProvider(KernelDocumentV2Provider.fromDocument(documentToPrint)); ``` -------------------------------- ### TypesettingModelProvider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter02/0202_print_engine_runtime.adoc Interface for loading Typesetting Models, which can be created within the SME. ```APIDOC ## TypesettingModelProvider ### Description Interface for loading Typesetting Models. They can be created within the SME. ### Method Not applicable (Interface definition) ### Endpoint Not applicable (Interface definition) ### Parameters Not applicable (Interface definition) ### Request Example Not applicable (Interface definition) ### Response Not applicable (Interface definition) ``` -------------------------------- ### Create PrintJob with KernelDocumentProvider Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0303_usage.adoc Configure a PrintJob with a document provider for IDocument. This is an integration point for custom document providers. ```java PrintJob printJob = new PrintJob(); printJob.withProvider(KernelDocumentProvider.fromDocument(documentToPrint)); ``` -------------------------------- ### TypesettingModelProvider Interface Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter02/0202_print_engine_runtime.adoc Interface for loading Typesetting Models, which can be configured in the SME. ```java include::../../sourceCode/engine-runtime/main/java/com/mgmtp/a12/print/engine/runtime/TypesettingModelProvider.java[tag=!*] ``` -------------------------------- ### Execute a PrintJob Source: https://github.com/mgm-tp/a12-print/blob/main/documentation/src/main/asciidoc/print-technical-documentation/asciidoc/chapter03/0303_usage.adoc Execute the configured PrintJob using the PdfPrintEngine to generate a PDF. ```java PdfPrintResult pdfPrintResult = pdfPrintEngine.execute(printJob); ```