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.

Usage

To use this plugin to print documents there are two main steps:

  1. Add required annotations to your CDS model: a. Entity b. Action
  2. Configure print queues to select from available options. (Optional, but recommended)

Annotations in CDS model

Entity

First of all, the entity needs to be annotated to define the content and the name of the document to be printed.

entity Incidents : cuid {
  @print.fileContent
  file : LargeBinary @Core.MediaType: 'application/pdf';
  @print.fileName
  fileName : String;
}
  • @print.fileContent: Annotates the field containing the document content to be printed.
  • @print.fileName: Annotates the field containing the name of the document

Annotation of actions

Sending a print request works via bound actions annotated with @print. The parameter of the action are used to define the print job details.

service IncidentService {
    entity Incidents as projection on db.Incidents actions {

    @print
    action printIncidentFile(
          @Common: {
              ValueListWithFixedValues,
              ValueList: {
                  $Type: 'Common.ValueListType',
                  CollectionPath: 'Queues',
                  Parameters: [{
                      $Type: 'Common.ValueListParameterInOut',
                      LocalDataProperty: qnameID,
                      ValueListProperty: 'ID'
                  }]
              },
              Label: 'Print Queues',
          }
          @print.queue
          qnameID: String,
          @print.numberOfCopies
          @UI.ParameterDefaultValue : 1
          copies: Integer
      );
    };
}
  • @print: Annotates the action that triggers the print job.
  • @print.queue: Annotates the parameter specifying the print queue. It is recommended to use a value help for this parameter to select from available print queues. See TOOD
  • @print.numberOfCopies: Annotates the parameter specifying the number of copies to print

Queues

Every print request needs to specify a print queue it is send to. It is recommended to provide a value help for the print queue selection. To enbale this, define an entity as projection on the Queues entity provided by the print service. When this projection is in place, the plugin automatically provides the available print queues coming from the print service.

using {sap.print as sp} from '@cap-js/print';

service IncidentService {
    entity Queues as projection on sp.Queues;
}

Local Development

When running the application locally, i.e. cds watch, the print service is mocked. This mock implementation prints the print job details to the console instead of sending it to the actual print service. It also provides a number of sample print queues for selection.

Hybrid Testing

You can also run the application locally with a binding to the cloud print service with CAP profiles. For more information, see Hybrid Testing. You need an instance of the SAP Print Service.

Local

To set up local hybrid integration tests, run the following. The service key is created automatically.

# Once as setup
cds bind -2 <print-service-instance-name>
# Run the tests
cds bind --exec npm run test

CI

For CI, the hybrid integration tests are automatically run against a SAP Print Service instance created for testing purposes.

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

Releases

No releases published

Packages

No packages published

Contributors 5