CDS plugin for SAP Print service (package @cap-js/print
) is a CDS plugin providing print service features through integration with SAP Print Service.
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.
The following three fields should be annotated with the corresponding @print
annotations:
@print.queue
: Specifies the queue to which the document should be sent for printing.@print.numberOfCopies
: Defines the number of copies to be printed.@print.fileContent
: Provides the file content to be printed. You can also specify the file name using thefileNameField
property.
@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.
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.
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 an entity like Product
and associate it with the Queues
entity as shown below:
entity Product {
qName : Association to one Queues;
}
@cds.skip.persistence
entity Queues {
key ID : String;
description : String;
}
Once the Queues
entity is defined, specify it in the @print.queue
annotation like so:
@print.queue: {
SourceEntity: 'Queues'
}
qName
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:
entity Product {
qName : Association to one Queues;
}
@cds.skip.persistence
entity Queues {
key ID : String;
description : String;
}
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.
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.
"scripts": {
"start": "SUBSCRIBER_SUBDOMAIN_FOR_LOCAL_TESTING=sub01 cds-serve"
}
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.
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.
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.
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.