页面导出到Microsoft Word失败,Applescript

时间:2019-10-20 21:56:16

标签: applescript iwork applescript-numbers

我目前正在尝试使用简单的applescript脚本将iWork .pages文件导出到Microsoft Word .docx文件。

on run {path, fileName}

tell application "Pages"
set theDoc to open (path & "/" & fileName)

set theDocName to name of theDoc
export theDoc as Microsoft Word to file ((path & "/" & theDocName & ".docx") as text)

close theDoc

end tell
end run

我希望将文档导出为Microsoft Word文档,但是我收到以下错误:

Pages got an error: The document “1” could not be exported as “/Users/joshgrimmett/Desktop/pages2docs/in/1”. (6)

1 个答案:

答案 0 :(得分:0)

我设法使用以下脚本将Pages文档导出到Word:

smooth_loss_GAN=smooth_loss(gen_label)//gen_label is a 512*512*3 tensor
def smooth_loss(src): #
    transform=np.array([[1,0,1],[0,1,1],[0,0,1]])

    dst=np.zeros((512,512,3),dtype=np.float32)
    for m in range(3):
        for i in range(512):
            for j in range(512):
                src_pos=np.array([i-0,j-0,1])
                [x,y,z]=np.dot(transform,src_pos)

                if x>=512 or y>=512 or x<0 or y<0:
                    dst[i][j][m]=1
                else:
                    dst[i][j][m]=src[x][y][m]
return tf.reduce_mean(tf.abs(src - dst))  

通过调用脚本on run(_dirname, _filename) tell application "Pages" set theDoc to open (_dirname & _filename) set theDocName to name of theDoc set dst to (_dirname & theDocName & ".docx") export theDoc to POSIX file dst as Microsoft Word close theDoc end tell end run /Users/joshgrimmett/Desktop/pages2docs/in/(或任何其他支持Pages的扩展)作为参数。 我认为问题在于将foo.pages(在AS中是保留关键字)用作变量,而不是指定目标类(因为我们使用的是POSIX路径而不是别名,所以它是{{1} }。