I am using version 20.9 of the Aspose.Pdf for C++ Linux.
I am trying to strip Javascript from a PDF and whenever I run the Strip() method in the PdfJavaScriptStripper class, I get a System::NullReferenceException.
The following is my code to execute:
System::String path = System::String::FromUtf8(argv[1]);
System::String outputpath = path + u"-cleaned";
Console::WriteLine(u"Path: {0}",path);
Console::WriteLine(u"Output Path: {0}",outputpath);
auto stripper = MakeObject<Aspose::Pdf::Facades::PdfJavaScriptStripper>();
bool cleaned = stripper->Strip(path,outputpath);
The value passed into the application is “calendar.pdf”. I’ve validated that if I don’t execute the Strip() function I get all the metadata returned from the PDF and no other execeptions. It is only when I run the strip() do I get the exeception. I’ve also validated that I can execute the method ToString() against the stripper object after it is constructed, so the stripper object is not null.
I’ve also tried to run against multiple PDFs with scripts and all fail. I’m also outputting in my application if the PDF has javascript and the library is outputting true for the hasJavascript property for the PDF.