Skip to content
/ print Public

Streamline document printing workflows with a lightweight, API-driven service. Supports cross-platform integration, queue management.

License

Notifications You must be signed in to change notification settings

cap-js/print

Welcome to @cap-js/print

REUSE status

About this project

CDS plugin for SAP Print service (package @cap-js/print) is a CDS plugin providing print service features through integration with SAP Print Service.

Table of Contents

Requirements and Setup

See Getting Started on how to jumpstart your development and grow as you go with SAP Cloud Application Programming Model.

Usage of this plugin requires a valid subscription of the SAP Print Service.

To integrate the print functionality in your application, simply annotate any action with @print. This annotation automatically manages the process of sending documents to the print queues, requiring no additional setup for handling print jobs.

Required Fields

The following three fields should be annotated with the corresponding @print annotations:

  1. @print.queue: Specifies the queue to which the document should be sent for printing.
  2. @print.numberOfCopies: Defines the number of copies to be printed.
  3. @print.fileContent: Provides the file content to be printed. You can also specify the file name using the fileNameField property.

Example

@print.fileContent: {
    fileNameField: '<Field Name>',
}

Multiple fields can be annotated with @print.fileContent to send several documents to the print queue in a single action.

Main Document

To designate a specific document as the primary document for printing, annotate it with @print.MainDocument:

@print.MainDocument
invoiceContent,

This ensures the specified document is treated as the main document when multiple documents are involved.

Print Queue Configuration

You can retrieve all available print queues from the Print Service Application for selection by defining a Queues entity with skip persistency. This setup will offer a value help for the print queues, allowing users to select from available options.

Define the Queues Entity

Define an entity like Product and associate it with the Queues entity as shown below:

Example

entity Product {
    qName : Association to one Queues;
}

@cds.skip.persistence
entity Queues {
    key ID          : String;
        description : String;
}

Annotating with @print.queue

Once the Queues entity is defined, specify it in the @print.queue annotation like so:

@print.queue: {
    SourceEntity: 'Queues'
}
qName

Parameterizing Print Queue in Actions

Alternatively, if the print queue is passed as a parameter in the action, you can annotate it directly within the action definition. This can be done as follows:

In Database Definition:

entity Product {
    qName : Association to one Queues;
}

@cds.skip.persistence
entity Queues {
    key ID          : String;
        description : String;
}

In Service Definition:

service MyService {
    @print
    action print(
        @print.queue: {
            SourceEntity: 'Queues'
        }
        @Common: {
            ValueListWithFixedValues,
            ValueList: {
                $Type: 'Common.ValueListType',
                CollectionPath: 'Queues',
                Parameters: [{
                    $Type: 'Common.ValueListParameterInOut',
                    LocalDataProperty: qnameID,
                    ValueListProperty: 'ID'
                }]
            },
            Label: 'Print Queues',
        }
        qnameID: String
    );

    entity Queues as projection on db.Queues;
}

In this setup, the qnameID parameter will be used to dynamically select the print queue from the Queues entity. The Common.ValueList provides a drop-down selection for available queues during runtime.

Note

If you are running the application in a production way locally(E.g. adding VCAP_SERVICES in default-env.json), add the environmental variable SUBSCRIBER_SUBDOMAIN_FOR_LOCAL_TESTING=<Your subscriber subdomain name> in the package.json as shown below.

Example

"scripts": {
    "start": "SUBSCRIBER_SUBDOMAIN_FOR_LOCAL_TESTING=sub01 cds-serve"
}

Support, Feedback, Contributing

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.

Security / Disclosure

If you find any bug that may be a security problem, please follow our instructions at in our security policy on how to report it. Please do not create GitHub issues for security-related doubts or problems.

Code of Conduct

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.

Licensing

Copyright 2025 SAP SE or an SAP affiliate company and print contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

About

Streamline document printing workflows with a lightweight, API-driven service. Supports cross-platform integration, queue management.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •