Sorry for my delayed response for this but I wanted to share my script I came up with to accomplish this.
I also want to thank Clay for helping me get there.
So here it is. Note: I've left in my logging in as it may help anyone else trying to do something similar.
package emptyPartsCatalogPDF2
function emptyTextFile()
{
fid = open("C:/Data/hooklog.txt", "w+")
put(fid, "File opened \n"); # write to log or msg window
close(fid);
}
function writeToTextFile(msg)
{
fid = open("C:/Data/hooklog.txt", "a+")
#Error opening file
if (fid < 0)
{
response("Error opening file");
return;
}
put(fid, msg); # write to log or msg window
close(fid);
}
function emptyPartsCatalogPDF2(doc, type, where, params[]){
local oids[];
local i;
local pubType;
local p;
#emptyTextFile(); Don't do this because it iterated though this command multiple times.
writeToTextFile("doc " . doc . "\n" . "type " . type . "\n" . "where " . where . "\n" ."stylesheet " . params["stylesheet"] ."\n" . "outputFile " . params["outputFile"] . "\n" );
#Changing the stylsheet to facilitate a fast publish from PDMLink since we don't need this PDF anyways.
if(type == "pdf"){
oid_find_children(oid_root(), oids, "Pub", 1);
if(count(oids) == 1){
pubType = oid_attr(oids[1], "PublicationType");
writeToTextFile("PubType is a " . pubType . "\n");
if(pubType == "Parts Catalog"){
if (where == "initial"){
if (params["compose.composer"] != "e3"){
#check to see if output file is a PDF. MPA makes a .out file
if (match(params["outputFile"],".pdf")) {
writeToTextFile("--- Initial pass on a non-editor composed doc ---\n\n");
params["stylesheet"] = stylesheet_select("C:/Program Files/PTC/Arbortext PE/custom/doctypes/PartsCatalog/PartsCatalog-PDMLink2.style",1)
local $stylesheetchanged = params["stylesheet"];
writeToTextFile("--- Changed StyleSheet to " . $stylesheetchanged . " ---\n\n");
}
}
}
}
}
}
for (p in params) {
writeToTextFile(" params[" . p . "] = " . params[p] . "\n");
}
writeToTextFile("--- Checking to see it request is a PDF request ---\n\n");
if(type == "pdf"){
writeToTextFile("I saw it was a Type of PDF \n");
#Checking to see if this is an editor request
if (params["e3.serverComposition"] != "1"){
writeToTextFile("Not a publish from Editor. \n");
if(count(oids) == 1){
pubType = oid_attr(oids[1], "PublicationType");
writeToTextFile("PubType is a " . pubType . "\n");
if(pubType == "Parts Catalog"){
#On final pass we change the pdf to the blank PDF.
if(where == "final"){
#check to see if output file is a PDF
if (match(params["outputFile"],".pdf")) {
local $pdffileloc = params["outputFile"];
gsub('\\','/',$pdffileloc)
writeToTextFile("Changing outputFile " . $pdffileloc . "\n");
copy_file "c:/data1/empty.pdf" "$pdffileloc";
writeToTextFile("Changed outputFile\n");
}
}
else{
writeToTextFile("Not the final pass! \n");
}
}
}
}
}
writeToTextFile("---End of Loop---\n\n");
return 1;
}
add_hook('compositionframeworkhook', 'emptyPartsCatalogPDF2::emptyPartsCatalogPDF2');