001/*
002 * (C) Copyright 2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Thibaud Arguillere
018 *     Miguel Nixo
019 *     Michael Vachette
020 */
021package org.nuxeo.ecm.platform.pdf.operations;
022
023import org.nuxeo.ecm.automation.core.Constants;
024import org.nuxeo.ecm.automation.core.annotations.Context;
025import org.nuxeo.ecm.automation.core.annotations.Operation;
026import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
027import org.nuxeo.ecm.automation.core.annotations.Param;
028import org.nuxeo.ecm.automation.core.collectors.BlobCollector;
029import org.nuxeo.ecm.core.api.Blob;
030import org.nuxeo.ecm.core.api.NuxeoException;
031import org.nuxeo.ecm.platform.pdf.service.PDFTransformationService;
032
033/**
034 * Returns a new blob combining the input PDF and an overlaid PDF on every page.
035 * @since 8.10
036 */
037@Operation(
038        id = PDFWatermarkPDFOperation.ID,
039        category = Constants.CAT_CONVERSION,
040        label = "PDF: Watermark with PDF",
041        description = PDFWatermarkPDFOperation.DESCRIPTION)
042public class PDFWatermarkPDFOperation {
043
044    public static final String ID = "PDF.WatermarkWithPDF";
045
046    public static final String DESCRIPTION =
047            "Returns a new blob combining the input PDF and an overlaid PDF on every page.";
048
049    @Context
050    protected PDFTransformationService pdfTransformationService;
051
052    @Param(name = "overlayPdf", description="The PDF Blob to overlay on top of the input")
053    protected Blob overlayPdf;
054
055    @OperationMethod(collector = BlobCollector.class)
056    public Blob run(Blob inBlob) throws NuxeoException {
057        return pdfTransformationService.overlayPDF(inBlob,overlayPdf);
058    }
059
060}