@@ -0,0 +1,2308 @@
+/*%0A   Copyright 2019-2021 WeAreFrank!%0A%0A   Licensed under the Apache License, Version 2.0 (the %22License%22);%0A   you may not use this file except in compliance with the License.%0A   You may obtain a copy of the License at%0A%0A       http://www.apache.org/licenses/LICENSE-2.0%0A%0A   Unless required by applicable law or agreed to in writing, software%0A   distributed under the License is distributed on an %22AS IS%22 BASIS,%0A   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A   See the License for the specific language governing permissions and%0A   limitations under the License.%0A*/%0Apackage nl.nn.adapterframework.extensions.aspose.pipe;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport nl.nn.adapterframework.configuration.ConfigurationException;%0Aimport nl.nn.adapterframework.core.IPipeLineSession;%0Aimport nl.nn.adapterframework.core.PipeRunException;%0Aimport nl.nn.adapterframework.core.PipeRunResult;%0Aimport nl.nn.adapterframework.doc.IbisDoc;%0Aimport nl.nn.adapterframework.pipes.FixedForwardPipe;%0Aimport nl.nn.adapterframework.stream.Message;%0Aimport nl.nn.adapterframework.util.StreamUtil;%0A%0Aimport com.aspose.pdf.Document;%0Aimport com.aspose.pdf.exceptions.InvalidPasswordException;%0A%0A/**%0A * Returns the amount of pages of a PDF file.%0A * %0A * %0A * @author Laurens M%C3%A4kel%0A * @since  7.6%0A *%0A */%0Apublic class AmountOfPagesPipe extends FixedForwardPipe %7B%0A%09private String charset = StreamUtil.DEFAULT_INPUT_STREAM_ENCODING;%0A%0A%09@Override%0A%09public PipeRunResult doPipe(Message input, IPipeLineSession session) throws PipeRunException %7B%0A%09%09int result = 0;%0A%0A%09%09try (InputStream binaryInputStream = input.asInputStream(getCharset()))%7B%0A%09%09%09Document doc = new Document(binaryInputStream);%0A%09%09%09result = doc.getPages().size();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09throw new PipeRunException(this, getLogPrefix(session) + %22cannot encode message using charset %5B%22 + getCharset() + %22%5D%22, e);%0A%09%09%7D catch (InvalidPasswordException ip) %7B%0A%09%09%09return new PipeRunResult(findForward(%22passwordProtected%22), %22File is password protected.%22 );%0A%09%09%7D%0A      %0A%09%09return new PipeRunResult(getForward(), Integer.toString(result) );%0A%09%7D%0A%0A%09@IbisDoc(%7B %22charset to be used to encode the given input string %22, %22UTF-8%22 %7D)%0A%09public void setCharset(String charset)%7B%0A%09%09this.charset = charset;%0A%09%7D%0A%09public String getCharset()%7B%0A%09%09return charset;%0A%09%7D%0A%7D%0A

Add Amount of pages pipe to Aspose module (#983)