The jar you are trying to run is not an executable jar. iText is a library that be used in a Java application by adding itextpdf-5.5.6.jar
to the CLASSPATH. If you don't write any Java code, then the jar won't do a thing, hence your Shell()
and your RunProgram()
methods are useless: there is nothing to execute.
Moreover: from your question, it is far from certain that you have a Java environment on your machine. You are working in a VBA environment, which makes one wonder why you'd use the Java version of iText. Have you tried using iTextSharp, which is the .NET version of iText (written in C#)?
Take a look at this tutorial: Programmatically Complete PDF Form Fields using Visual Basic and the iTextSharp DLL
In this tutorial, we take an existing PDF, we fill out a form, and we get another PDF based on the original PDF, but with extra data. You can easily adapt the code so that it takes an existing PDF, doesn't add anything to the PDF, but saves the original PDF without its passwords, as is explained in my answer to How can I decrypt a PDF document with the owner password?
If you combine what you can learn from my Java code:
public void manipulatePdf(String src, String dest) throws IOException, DocumentException {
PdfReader.unethicalreading = true;
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
stamper.close();
reader.close();
}
with what you learn from the form filling tutorial, you get something like this (provided that you use the iTextSharp DLL instead of the iText jar):
Dim pdfTemplate As String = "c:\Temp\PDF\encrypted.pdf"
Dim newFile As String = "c:\Temp\PDF\decrypted.pdf"
PdfReader.unethicalreading = true
Dim pdfReader As New PdfReader(pdfTemplate)
Dim pdfStamper As New PdfStamper(pdfReader, New FileStream(
newFile, FileMode.Create))
pdfStamper.Close()
pdfReader.Close()
IMPORTANT: this will only remove the password if the file is only protected with an owner password (which is what I assume when you talk about protected view). If the file is protected in any other way, you'll have to clarify. Also note that the parameter unethicalreading is not without meaning: make sure that you're not doing unethical by removing the protection.