Question: what are known limitation for running code in headless worksheet?

I just spend 2 hrs trying to make this work in headless worksheet, but it does not work. I have A worksheet, which calls B worksheet. The call all go through OK and I set it all correctly. Set up the section in worksheet B and document property, etc.. as described in help.

So the call works OK and arguments are passed correctly from A to B.

The problem is that in worksheet B, I wanted to generate a plot in order to save it to postscript file.  This did not work. Nothing gets exported, even  though the plot is actually generated correctly in B.  How do I know this? Becaue B returns the plot back to A, and I can see the plot was correctly generated.  The file .ps never gets created. I look at the folder these worksheets are in, and there is no .ps file created.

But it was not saved to .ps file.  The same code works ok in standard worksheet and plot is saved correctly to .ps file using same code.

I also could not export the plot to JPEG file from worksheet B.  Only thing that worked is exporting some text to .TXT file from B.  

Any one knows of limitation to calling one worksheet from another?  It seems somethings work in headless worksheet and some things do not. Which does not make it useful.

You might ask, why Am I doing this? Because I wanted to call that B worksheet later on (if it worked) from a script to do the plot exporting, as the quality is better when in a "worksheet" vs. command line).

But since this does not even work when calling the worksheet from another worksheet, then there is no point of trying it from the command line.

Attached A and B. To try it, please save both worksheets in same folder and simply open and run it. It will call  

This is the first time I used documentTools package. I did not even know one can call one worksheet from another before.

I suspect it had to do with print(); call becoming inactive in headless worksheet, which causes nothing to be send to the postscript file. But I am not sure. Without print(); one can't export the plot.

I do not understand why is it so hard in Maple to export a plot to a PDF. Why is there not a simple export command to export a plot to PDF like with all the other software out there in the world?  This is the year 2021, not 1980. How many decades does Maplesoft needs to implement export to PDF?

This is on windows 10. Maple 2021.1

This is


p:=DocumentTools[RunWorksheet]( "" , [the_function=sin(x),the_variable=x]  ):
print("Back from calling worksheet B. Here is the result");


"Back from calling worksheet B. Here is the result"



This is







return p;




Please Wait...