All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.pdfservices.operation.pdfjobs.params.rotatepages.RotatePagesParams Maven / Gradle / Ivy

Go to download

Adobe PDF Services SDK allows you to access RESTful APIs to create, convert, and manipulate PDFs within your applications. Older versions can be found under groupId: com.adobe.documentservices, artifactId: pdftools-sdk

There is a newer version: 4.2.0
Show newest version
/*
 * Copyright 2024 Adobe
 * All Rights Reserved.
 *
 * NOTICE: Adobe permits you to use, modify, and distribute this file in
 * accordance with the terms of the Adobe license agreement accompanying
 * it. If you have received this file from a source other than Adobe,
 * then your use, modification, or distribution of it requires the prior
 * written permission of Adobe.
 */

package com.adobe.pdfservices.operation.pdfjobs.params.rotatepages;

import com.adobe.pdfservices.operation.internal.constants.CustomErrorMessages;
import com.adobe.pdfservices.operation.internal.dto.request.pagemanipulation.PageAction;
import com.adobe.pdfservices.operation.internal.dto.request.pagemanipulation.RotatePageAction;
import com.adobe.pdfservices.operation.internal.util.ObjectUtil;
import com.adobe.pdfservices.operation.internal.util.ValidationUtil;
import com.adobe.pdfservices.operation.pdfjobs.jobs.RotatePagesJob;
import com.adobe.pdfservices.operation.pdfjobs.params.PDFServicesJobParams;
import com.adobe.pdfservices.operation.pdfjobs.params.PageRanges;

import java.util.ArrayList;
import java.util.List;

/**
 * Parameters to rotate pages of a pdf using {@link RotatePagesJob}.
 */
public class RotatePagesParams implements PDFServicesJobParams {

    private List pageActions;


    private RotatePagesParams(Builder builder) {
        this.pageActions = builder.pageActions;
    }

    /**
     * Returns the list of {@link PageAction} to be used for rotating pages.
     *
     * @return list of {@link PageAction} to be used for rotating pages.
     */
    public List getPageActions() {
        return pageActions;
    }

    /**
     * Creates a new {@link Builder}.
     *
     * @return a {@link Builder} instance
     */
    public static Builder rotatePagesParamsBuilder() {
        return new Builder();
    }

    /**
     * Builds a {@link RotatePagesParams} instance.
     */
    public static class Builder {
        private List pageActions;

        /**
         * Constructs a {@code RotatePagesParams.Builder} instance.
         */
        public Builder() {
            this.pageActions = new ArrayList<>();
        }

        /**
         * Sets the {@link Angle} to be used for rotating pages.
         *
         * @param angle see {@link Angle}; can not be null.
         * @return this Builder instance to add any additional parameters
         */
        public Builder withAngleToRotatePagesBy(Angle angle) {
            ObjectUtil.requireNonNull(angle, String.format(CustomErrorMessages.GENERIC_CAN_NOT_BE_NULL, "Rotate " +
                    "angle"));
            PageRanges pageRanges = new PageRanges();
            pageRanges.addAll();
            RotatePageAction rotatePageAction = new RotatePageAction(angle.getValue(), pageRanges.getRanges());
            this.pageActions.add(rotatePageAction);
            return this;
        }


        /**
         * Sets the {@link Angle} to be used for rotating pages specified in {@link PageRanges}.
         *
         * @param angle      see {@link Angle}; can not be null.
         * @param pageRanges see {@link PageRanges}; can not be null.
         * @return this Builder instance to add any additional parameters
         */
        public Builder withAngleToRotatePagesBy(Angle angle, PageRanges pageRanges) {
            // Validate angle
            ObjectUtil.requireNonNull(angle, String.format(CustomErrorMessages.GENERIC_CAN_NOT_BE_NULL, "Rotate " +
                    "angle"));
            // Validate page ranges
            ObjectUtil.requireNonNull(pageRanges, String.format(CustomErrorMessages.GENERIC_CAN_NOT_BE_NULL, "Page " +
                    "ranges"));
            pageRanges.validate();
            RotatePageAction rotatePageAction = new RotatePageAction(angle.getValue(), pageRanges.getRanges());
            this.pageActions.add(rotatePageAction);
            return this;
        }

        /**
         * Returns a new {@link RotatePagesParams} instance built from the current state of this builder.
         *
         * @return a new {@link RotatePagesParams} instance
         */
        public RotatePagesParams build() {
            ValidationUtil.validateRotatePageActions(this.pageActions);
            return new RotatePagesParams(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy