We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot sign PDF, get an error message

class com.aspose.pdf.internal.ms.System.lv: Specified argument was out of the range of valid values.
Parameter name: Parameter name: index
com.aspose.pdf.internal.ms.System.Collections.Generic.l0t.get_Item(Unknown Source)
com.aspose.pdf.internal.l12k.ly.lI(Unknown Source)
com.aspose.pdf.internal.l12k.ly.lI(Unknown Source)
com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
com.aspose.pdf.Signature.lI(Unknown Source)
com.aspose.pdf.SignatureField.lI(Unknown Source)
com.aspose.pdf.SignatureField.sign(Unknown Source)
com.aspose.pdf.facades.PdfFileSignature.lI(Unknown Source)
com.aspose.pdf.facades.PdfFileSignature.save(Unknown Source)
com.aspose.pdf.facades.PdfFileSignature.save(Unknown Source)
com.inputdata.inputprocess.signing.AsposeSigning.signDocument3(AsposeSigning.java:194)
org.apache.jsp.test35_jsp._jspService(test35_jsp.java:146)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
com.inputdata.inputprocess.filters.NavigationFilter.doFilter(NavigationFilter.java:119)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
com.inputdata.inputprocess.filters.AccessControlFilter.doFilter(AccessControlFilter.java:174)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
com.inputdata.inputprocess.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:145)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1626)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)
at com.aspose.pdf.internal.ms.System.Collections.Generic.l0t.get_Item(Unknown Source)
at com.aspose.pdf.internal.l12k.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l12k.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
at com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
at com.aspose.pdf.internal.l1f.l0p.lI(Unknown Source)
at com.aspose.pdf.Signature.lI(Unknown Source)
at com.aspose.pdf.SignatureField.lI(Unknown Source)
at com.aspose.pdf.SignatureField.sign(Unknown Source)
at com.aspose.pdf.facades.PdfFileSignature.lI(Unknown Source)
at com.aspose.pdf.facades.PdfFileSignature.save(Unknown Source)
at com.aspose.pdf.facades.PdfFileSignature.save(Unknown Source)
at com.inputdata.inputprocess.signing.AsposeSigning.signDocument3(AsposeSigning.java:194)
at org.apache.jsp.test35_jsp._jspService(test35_jsp.java:146)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:476)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.inputdata.inputprocess.filters.NavigationFilter.doFilter(NavigationFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.inputdata.inputprocess.filters.AccessControlFilter.doFilter(AccessControlFilter.java:174)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.inputdata.inputprocess.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:145)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1626)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Code:

public void signDocument(String signpath, String outpath, String signimg, Bruker bruker) {
try {
Document document = new Document(signpath);
PdfFileSignature pdfSign = new PdfFileSignature(document);
PKCS7 pkcs = new PKCS7("/tmp/TSACertificate.crt", “password”);
java.awt.Rectangle rect = new java.awt.Rectangle(10, 10, 10, 10);
pdfSign.sign(1, true, rect, pkcs);
pdfSign.save(outpath);
} catch(Exception e) {
e.printStackTrace();
}
}

@ron.inputdata.no

Would you please share the sample PDF document for our reference? We will test the scenario in our environment and address it accordingly.

inn.pdf (55.5 KB)TSACertificate.crt.zip (1.4 KB)

@ron.inputdata.no

We have reproduced the similar issue in our environment with Aspose.PDF for Java 22.5. Therefore, have logged it as PDFJAVA-41668 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.