假设我将以下(编辑过的)代码片段输入 Mathematica。
manip = Manipulate[x, {x, 0, 1}];
nb = Developer`UseFrontEnd[
CreateDocument[manip, ShowCellBracket -> False,
Visible -> False]];
nbTest = ExportString[nb, "NB"] =!= $Failed;
cdfTest = ExportString[nb, "CDF"] =!= $Failed;
version = First[StringSplit[SystemInformation["Kernel", "ReleaseID"]]];
{{nbTest, cdfTest},version}
我发现 nbTest 和 cdfTest 都是 True。如果我从 webMathematica 中运行相同的命令,nbTest 为 True 但 cdfTest 为 False。你可以在这里看到结果:
http://www.cs.unca.edu:8082/webMathematica/generateCDF.jsp
您可以在此处查看生成该结果的代码:
http://www.cs.unca.edu:8082/webMathematica/generateCDF.jsp.txt
我搜索了 webMathematica 的安全配置以找到启用 CDF 导出的方法,但没有找到。有谁知道启用此功能的方法?当然,在这种情况下它可能会被故意禁用。
我的目的是提供从通过 HTML 表单访问的 JSP 页面动态生成的 CDF 文档。这应该允许良好的 CDF 交互与文本输入相结合。
编辑:我已经在我们的服务器上更新了 Mathematica 的版本,并更新了上面的代码,以便显示完整的版本字符串。因此,我们可以看到它是 8.0.1 版本。问题仍然存在。
最佳答案
马克,
您能否尝试将 ExportString[ ..., "CDF"] 包装在 UsingFrontEnd 中,看看是否有帮助?
C:\Users\arnoudb>math.exe
Mathematica 8.0 for Microsoft Windows (64-bit)
Copyright 1988-2011 Wolfram Research, Inc.
In[1]:= nb = CreateDocument[ Manipulate[x,{x,0,1}] ] // UsingFrontEnd
Out[1]= -NotebookObject-
In[2]:= ExportString[ nb, "CDF" ]
FrontEndObject::notavail:
A front end is not available; certain operations require a front end.
Export::nofe: A front end is not available; export of CDF
requires a front end.
Out[2]= $Failed
In[3]:= ExportString[ nb, "CDF" ] // UsingFrontEnd // Head
Out[3]= String
In[4]:= $Version
Out[4]= 8.0 for Microsoft Windows (64-bit) (October 7, 2011)
In[5]:= $ReleaseNumber
Out[5]= 4
关于wolfram-mathematica - 从 webMathematica 提供 CDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5876191/