Acrobat DC preflight processes non-PDF files - pdf

I want to process and verify that PDFs within a folder are valid PDF/A files. The problem is that I need to process a folder with piles of files including word and excel among others that preflight converts to PDFs, processes, and then hangs for user input to discard the temperary file. There are some hundred files, so waiting for user input isn't doable.
Perhaps I'm not using the correct phrases when I search, but I can't find out how to force Adobe Acrobat DC to only process PDF files. I've found that in Acrobat X you can specify source files https://www.evermap.com/ActionWizardX.asp, but I've not found an equivalent in DC.
Is there a way to force an action to only process PDF files?
Edit:
Following #Joel Geraci's suggestion and finding this post, I've created the following script that runs in an action. At this point, It seems to run the profile, but I don't know if it actually modifies the document, since the call to this.closeDoc() doesn't prompt to save the document, and the resulting document doesn't seem to be saved as a PDF/A file.
/* Convert PDF/A-3a */
try
{
if(this.path.split('.').pop() === 'pdf')
{
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile);
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
this.closeDoc();
}
}
}
catch(theError)
{
$error = theError;
this.closeDoc( {bNoSave : true} );
}
Edit 2:
I ended up settling on using the saveAs function. I'm not sure how to export the XML data to a file, but this seems to be sufficient.
/* Convert PDF/A-3a */
try
{
if(this.path.split('.').pop() === 'pdf')
{
var oThermometer = app.thermometer;
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile, false, oThermometer );
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
if(myPreflightResult.numErrors > 0) {
var cXMLData = myPreflightResult.report(oThermometer);
console.println(cXMLData);
}
this.saveAs(path,"com.callas.preflight.pdfa");
}
}
}
catch(theError)
{
$error = theError;
this.closeDoc( {bNoSave : true} );
}
Edit 3:
So the problem is that non-PDF files are converted and read before my JavaScript is executed, which means that the this.path.split('.').pop() === 'pdf' doesn't actually filter out anything. I found that the requiresFullSave property of the Doc class specifies whether the document is a temp file or not. I have, however, found that I am still asked if I want to save the temp file, which doesn't help.
Edit 4
Calling Doc.closeDoc(true) on a temporary file causes Acrobat to crash and there doesn't seem to be another way to close a document without saving. I've found there is no clear way (that I've found) to close a temp document without prompting the user to save and have resorted to deleting all non-PDF files.
Final script:
/* Convert PDF/A-3a */
try
{
console.println(path + " is temp: " + requiresFullSave);
if(!requiresFullSave)
{
var oThermometer = app.thermometer;
var oProfile = Preflight.getProfileByName("Convert to PDF/A-3a");
if( oProfile != undefined )
{
var myPreflightResult = this.preflight( oProfile, false, oThermometer );
console.println( "Preflight found " + myPreflightResult.numErrors + " Errors.");
console.println( "Preflight found " + myPreflightResult.numWarnings + " Warnings.");
console.println( "Preflight found " + myPreflightResult.numInfos + " Infos.");
console.println( "Preflight fixed " + myPreflightResult.numFixed + " Errors.");
console.println( "Preflight not fixed " + myPreflightResult.numNotFixed + " Errors.");
if(myPreflightResult.numErrors > 0) {
var cXMLData = myPreflightResult.report(oThermometer);
console.println(cXMLData);
}
this.saveAs(path,"com.callas.preflight.pdfa");
}
}
else{
// As noted in the documentation found [here][2]
// Note:If the document is temporary or newly created, setting dirty to false has no effect. That is, the user is still asked to save changes before closing the document. See requiresFullSave.
// this.dirty = false;
// this.closeDoc(true);
}
}
catch(theError)
{
}

Rather than creating an action that runs preflight, try creating an action that runs some JavaScript. The JavaScript would test for the file extension of the file being processed and then execute preflight via JavaScript if it's a PDF, skipping it if not.

Related

How to fix the issue of output file not appearing, after having launched a run configuration?

I work on CVRP in combinatorial optimization, where the goal is to compare several models on several instances, using the OPL language. For this to e done, I first wrote and tested the said models; then I wrote an main flow control supposed to run each instance for a 2 hours duration.
My problem is that after 2 hours, and this for each model, the output file appears for some instances, containing the desired information; but for other instances, the output files do not appear, as if these instances do not exist. This problem persists even when you launch one or more of these instances in isolation.
below is the main flow control code, where BPF designates the name of the .mod file, which is simply modified in the code, when one wishes to switch to another model.
{string} datFiles=...;
main {
var source = new IloOplModelSource("BPF.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
cplex.tilim=2*60*60;
cplex.threads=1;
for(var datFile in thisOplModel.datFiles)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataSource(datFile);
opl.addDataSource(data2);
opl.generate();
var o=new IloOplOutputFile("BPF "+datFile+".txt");
if (cplex.solve()) {
if(cplex.getCplexStatus()==11){
o.writeln("instance : " + datFile
+" / opt = "
+ " / UB = " + cplex.getObjValue()
+ " / LB = " + cplex.getBestObjValue()
+" / time = " + " - "
+" / Gap = "+cplex.getMIPRelativeGap()*100+"%");
}
else {
o.writeln("instance : " + datFile
+ " / opt = " + cplex.getObjValue()
+ " / UB = " + cplex.getBestObjValue()+"*"
+" / time = " + cplex.getSolvedTime()
+ " / Gap : -");
}
o.close();
}
opl.end();
}
}

Podio java API how to download an Excel Spreadsheet

I am trying to download an Excel file from Podio space. I get access to space and get the files within space and the using fileAPI .
The problem is with the file that gets downloaded. I am not able to open it with Excel.
Here is the code:
List <File> aFileList = aFileAPI.getOnSpace(spaceId, null, null);
for (int i=0; i<aFileList.size(); i++){
File thisFile = aFileList.get(i);
MimeType thiFileMimeType = thisFile.getMimetype();
System.out.println("thisFile = " +thisFile.toString());
System.out.println("thisFile.getDescription() =" + thisFile.getDescription());
System.out.println("thisFile.getName() =" + thisFile.getName());
System.out.println("thisFile.getId() =" + thisFile.getId());
System.out.println("thisFile.getSize() =" + thisFile.getSize());
System.out.println("thisFile.getCreatedOn() =" + thisFile.getCreatedOn());
System.out.println("thisFile.getMimetype() =" + thisFile.getMimetype());
try {
aFileAPI.downloadFile(thisFile.getId(), new java.io.File("C:/Users/alisa/Desktop/"+ thisFile.getName()), null);
}
catch (IOException e) {
e.printStackTrace();
}
I think the API is creating the file without regard to MIME and I don't see anywhere to set it. Please help!!

LiveCycle dynamic PDF - how to enforce Acrobat version?

I have a dynamic PDF that doesn't display correctly in Firefox, Chrome, or lower versions of Adobe. Is there a way to show blank page with error message when the user opens it with anything less than Acrobat version X?
I tried searching on this site and Googling but couldn't find anything..
Help much appreciated!!
This can be achieved with a PDF cover page but can also be achieved with your own subform combo and a bit of script. Creating a cover page that is hidden only to reveal your form content if a script executes correctly and is inside a full feature XFA form viewer is one way to tackle this.
function detect(){
//Sample platform detection
var viewerType = xfa.host.appType;
var versionNo = xfa.host.version;
var variation = xfa.host.variation;
var plugIns = app.plugIns;
var nplugIns = plugIns.length;
var msg = "";
if((viewerType == "Reader") && (nplugIns > 0)){
msg = "This PDF was opened in Reader " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else if((viewerType == "Exchange") && (nplugIns > 0)){
msg = "This PDF was opened in Acrobat " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else if((viewerType == "Exchange-Pro") && (nplugIns > 0)){
msg = "This PDF was opened in Acrobat Pro " + versionNo + ", " + variation + ", and loaded " + nplugIns + " plug-ins.";
form1.Top.Cover.presence = "hidden";
form1.Top.Content.presence = "visible";
}
else{
msg = "This PDF was opened in an unrecognized platform";
}
xfa.host.messageBox(msg); //Throw prompt.
form1.Top.Content.TextField1.rawValue = msg; //Write message to form.
}
Most of the function above relies on xfa.host.appType but some PDF viewers developped using the Adobe Acrobat code base will return valid platform values but will not load any plug-ins which is a way to detect and unsupported platform.

SharePoint 2010 Wiki Template Script Issue

I'm looking for a way to give my SharePoint users a way to create new wiki pages from an existing template. In the process of researching I found a great walkthrough that seems to fit the need (http://www.mssharepointtips.com/tip.asp?id=1072&page=2), but I'm having trouble getting it to work. The problem seems to lie in the assignment of a path to PATHTOWIKI-- if I use "/Weekly Update Wiki", the script returns an error of "There is no Web named '/Weekly Update Wiki'." If I use "Weekly Update Wiki" without the forward slash, I instead get an error of "There is no Web named '/sites/[parentSite]/[childSite]/Weekly Update Wiki/Weekly Update Wiki'."
Any ideas about what I'm not understanding here?
function myCreateProject() {
// Configure these for your environment
// include no slashes in paths
var PATHTOWIKI = "Weekly Update Wiki";
var PATHTOPAGES = "Pages";
// file name only for template page, no extension
var TEMPLATEFILENAME = "Template";
var myPathToWiki = encodeURIComponent(PATHTOWIKI);
var myPathToPages = PATHTOPAGES + "%2f";
var myTemplateFileName = encodeURIComponent(TEMPLATEFILENAME) + "%2easpx";
var EnteredProject = document.getElementById("NewProjName");
var myNewName = EnteredProject.value;
if(myNewName == "") {
alert('Please enter a name for the new project page');
} else {
myNewName = encodeURIComponent(myNewName) + "%2easpx"
$.ajax({
url: PATHTOWIKI + "/_vti_bin/_vti_aut/author.dll",
data: ( "method=move+document%3a14%2e0%2e0%2e4730&service%5fname="
+ myPathToWiki +
"&oldUrl=" + myPathToPages + myTemplateFileName +
"&newUrl=" + myPathToPages + myNewName +
"&url%5flist=%5b%5d&rename%5foption=nochangeall&put%5foption=edit&docopy=true"
),
success: function(data) {
var rpcmsg1 = getMessage(data, "message=", "<p>");
$("#myInfo").append("<br />" + rpcmsg1);
if(rpcmsg1.indexOf("successfully") < 0) {
// get error info
var rpcmsg2 = getMessage(data, "msg=", "<li>");
$("#myInfo").append("<br />" + rpcmsg2 + "<br />");
} else {
$("#myInfo").append("<br />Go to new page<br />");
}
},
type: "POST",
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("X-Vermeer-Content-Type",
"application/x-www-form-urlencoded");
}
});
}
}
Update: I figured out what needed to happen in my case. Since I couldn't get a grasp on the relative approach, I just went with the absolute path for PATHTOWIKI and slightly modified the append in the ajax call.
PATHTOWIKI:
var PATHTOWIKI = "https://[domain]/sites/[parentSite]/[childSite]";
append:
$("#myInfo").append("<br />Go to new page<br />");
The change in the latter line of code is subtle; since I used an absolute path in PATHTOWIKI, I just removed the leading forward slash in the anchor tag, so that <a href=\"/" became <a href=\"". This renders the script slightly less portable, but since it's a one-off effort I'll stick with this unless anything comes along to expand the scope.

is there any more standard way to resume function from jQuery ajax call?

I am trying to write a big project which involves of a lot of code. That's why I want to separate functionalities from different files.
the first file, dataJS, I make an AJAX call to get data from a JSON file.
the second file, showJS I want to display the data obtained from the dataJS file.
When it comes to implementation, I realise that AJAX call takes longer time and even though I include dataJS and showJS in order, showJS will still get a null data
therefore I made a function called continueFromDataJS() in showJS file
and call continueFromDataJS() at the end of the AJAX success function.
I think it's a rather makedo solution. Is there any standard way to do it?
In addition, all intellisense in my Visual Studio is gone. Despite separate files, is there any way to make visual studio get intellisense from the dataJS?
Thank you
sorry, I don't know how to add a follow up question
this is the code
for simplicity I rename some of the files and only take some part out of it. Hope that helps
code in html
code in dataJS.js
var planets = [];
var jsonData = null;
$(function () {
$.getJSON("Scripts/planetData.js", function (data) {
//planets[0] = new planet("uranus", "career", 45, 700, 400, 0.1, 5, 3);
jsonData = data;
for (var i = 0; i < data.planets.length; i++) {
var curPlanet = data.planets[i];
planets[i] = new planet(curPlanet.graphic, i, curPlanet.field, curPlanet.planetInitialAngle, curPlanet.distanceFromStar, curPlanet.planetRadius, curPlanet.planetRevolvingSpeed, curPlanet.planetRotationSpeed, curPlanet.contents.length);
$("#result").append("<p>" + curPlanet.graphic + " " + curPlanet.field + " " + curPlanet.planetInitialAngle + " " + curPlanet.distanceFromStar + " " + curPlanet.planetRadius + " " + curPlanet.planetRevolvingSpeed + " " + curPlanet.planetRotationSpeed + " " + curPlanet.contents.length + "</p>");
}
callDisplayScript(); //**continue from showJS.js file is that the way to do this?**
});
});
// more functions below in dataJS.js
showJS.js
function callDisplayScript() { **// this is the ugly part. What's the proper way to do it?**
$("#display #close").click(function () {
$("#display").fadeOut('slow');
});
$article = $("#display article");
$article.empty();
var data = jsonData.planets[pID].contents; // **this line won't get jsonData if it's out this curly brace.**
for (var i = 0; i < data.length; i++) {
$article.append(data[i].title);
$article.append(data[i].content);
}
$("#display").fadeIn('slow');
};
don't forget to answer my intellisense question. I want in datajs.js automatically hint planets and jsonData declared in datajs.js
is it possible?