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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Inserting a PI on opening a document

byork
17-Peridot

Inserting a PI on opening a document

I am looking for a way to insert a PI on opening a document and I'm not sure of the best way.

I have theacl function worked out but just can't get it to fired when opening a doc.

Any ideas would be welcomed.

Thanks in advance.

8 REPLIES 8


Brian,

Try calling the acl code from the instance.acl file.

Carolyn Herlin
ClayHelberg
17-Peridot
(To:byork)

Hi Brian--

You can probably do what you want using the doc_add_callback() function to attach your function as an event listener for documents. In particular, the "create" callback is probably most useful in this instance.

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

Carolyn,



I forgot to mention I need this to work with PE. The instance.acl won't
work on PE according to tech support.





Thanks,

Brian
byork
17-Peridot
(To:byork)

Clay,



I'm not really sure how to attempt this.



Brian




ClayHelberg
17-Peridot
(To:byork)

Hi Brian--

If you look in the online help, it has pretty good information on how to use callbacks. Look for the page on the doc_add_callback function (help 148 on the command line), and the general page on callback functions (help 762).

You can put the doc_add_callback() instruction in one of your startup ACL files. See Startup command files in the online help (help 5716).

Basically, to put it in a nutshell, you'll have something like this:

doc_add_callback(0,"create",your_function_name);

in one of your startup script files, either in your custom/init directory, or your doctype directory (if you only want it to apply to certain doctypes--in which case you'll also need to change the first parameter as described in the help). See the "Startup command files" help page cited above for help deciding where you should put this code.

--Clay

Let me add one caution here. The create callback is called whenever the
software creates the in memory structures for a document, not when
creating the disk file. As the software opens up various files, such as
the stylesheet just to name one, you may find the create callback being
called much more often than you were expecting. Just make sure that your
function gracefully handles the situation where it is called on
additional files, not just the one where you want to add the PI. You
probably want to check the top tag of the document just created to make
sure that it is yours before you do the insert.

John Dreystadt
Software Development Director
Arbortext - PTC
734-327-6079
-


byork
17-Peridot
(To:byork)

Thanks guys

John I am planning on this running on the PE side only so it should be
mostly called at the right times.

I will give it a try.

Thanks again.
byork
17-Peridot
(To:byork)

I thought I would give a short update on what we ended up doing on this.

Since we only needed this to fire when PE was creating a PDF we used the composepreprocesshook.

Thanks again.
Announcements