cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Use a different stylesheet with PDMLink publishing

byork
17-Peridot

Use a different stylesheet with PDMLink publishing

Is it possible to use a different stylesheet when generating a PDF for PDMlink vs. generating the PDF from other sources?


7 REPLIES 7
byork
17-Peridot
(To:byork)

So I have a related question?

I need to know how or if I can switch a stylesheet after the job has already been submitted to the Publishing Engine. I suspect I can by using the composepreprocesshook, but I am unsure how.

Thanks in advance!

I suspect the WVS (windchill visualisation services) configuration can be adjusted to set a stylesheet. Have you looked into that?

-Gareth


----- Reply message -----

Hi Brian--

You would want to write a compositionframeworkhook function to modify the params[] array. There will be a stylesheet entry there, simply update the value to the desired location, something like this:

function switch_stylesheet_hook(doc, type, where, params[]) {
if ((type=="pdf") & (where=="preprocessing_complete")) {
params["stylesheet"] = $my_stylesheet;
}
}

add_hook("compositionframeworkhook","switch_stylesheet_hook");

HTH

--Clay
byork
17-Peridot
(To:byork)

Clay,

I will give that a try. Can $my_stylesheet be a .style? Also do you happen to know what params might tell me where the job came from? Like a manual compose or a publish from PDMlink.

Thanks,
Brian

Hi Brian--

Sure, you can use a .style file, in fact that's the default assumed in 6.0. As for the params, I'm not sure exactly what you should look for, but you can get hints by turning on debug logging for composition, which will write the parameters to the log (or the log window if you're publishing from Editor). Then you can try both ways of publishing and compare the parameters to see what you can check to determine the type of publish.

To turn on composition debugging, add this line to you init.acl file:

$compose::debug=1

HTH

--Clay
byork
17-Peridot
(To:byork)

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');



Cool, thanks for sharing your script, Brian.
Announcements

Top Tags