手动编码 Postscript 时,Ghostscript 产生未定义错误

问题描述

我已经有大约 20 年没有手工编写 Postscript 了,所以我打开了 Bluebook,在名为 test.ps 的文件中输入了一些示例。这是一个这样的例子:

%!PS
/doACircle
{ 0 0 54 0 360 arc stroke } def
/doAnEllipse
{ 1 .75 scale
doACircle
stroke } def
300 500 translate doACircle
4 {0 −72 translate
doAnEllipse} repeat
showpage

我在 Debian Linux 系统上使用 Ghostscript 和 Imagemagick。两者在其他方面都做得很好。当我运行这样的命令时:

convert test.ps test.png

我收到一个错误一个转储:

Error: /undefined in �
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1992   1   3   %oparray_pop   1991   1   3   %oparray_pop   1979   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   3   --nostringval--   %repeat_continue   --nostringval--
Dictionary stack:
   --dict:727/1123(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 167
GPL Ghostscript 9.27: Unrecoverable error,exit code 1
Error: /undefined in �
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1992   1   3   %oparray_pop   1991   1   3   %oparray_pop   1979   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   3   --nostringval--   %repeat_continue   --nostringval--
Dictionary stack:
   --dict:727/1123(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 167
GPL Ghostscript 9.27: Unrecoverable error,exit code 1
convert-im6.q16: no images defined `test.png' @ error/convert.c/ConvertimageCommand/3258.

我知道我忘记了一些基本的东西——也许是一些与边界框相关的东西?

解决方法

这是节目流中的一个奇怪字符。我的猜测是 您使用的是 Macintosh 并且 出于某种原因,您的键盘处理程序正在用一些表面上 更合适的破折号字符替换连字符。这会创建一个格式错误的负数,该负数被解析为名称,然后……瞧……字典堆栈中没有定义这样的名称。

从错误消息中可以帮助解决类似问题的一些线索是:

  • /undefined 错误是字典查找失败的结果。这可能发生在 library(shinydashboardPlus) #UI------------------------------------------------------------------------------------------------- startUi <- function(id) { ns <- NS(id) tagList( fluidPage( #...shortened.... actionButton( inputId = ns("start_btn"),label = "Start",icon = icon("play-circle") ),plotOutput(ns("p1")) #...shortened.... )) } ### startServer--------------------------------------------------------------------------------------------- startServer <- function(id) { moduleServer(id,function(input,output,session) { output$p1 <- renderPlot(plot(cars)) #Confirm button reactive(input$start_btn) }) } ### runUi -------------------------- runUi <- function(id) { ns <- NS(id) tagList( checkboxInput(ns("start_check_promo"),"start check promo",TRUE),plotOutput(ns("norm")) #...shortened.... ) } ### runServer--------------------------------------------------------------------------------------------- runServer <- function(id,startbtn) { moduleServer(id,session) { ns <- session$ns observeEvent(startbtn(),{ output$norm <- renderPlot({hist(rnorm(500))}) if (input$start_check_promo == TRUE) { confirmSweetAlert( session = session,inputId = "start_confi_true",title = "Do you want to start the calculation?",type = "warning",btn_labels = c("No","Yes") ) } else confirmSweetAlert( session = session,inputId = "start_confi_false",title = "Please check the option side and try again",type = "error",btn_labels = c("Okay") ) }) }) } ui <- dashboardPagePlus( header <- dashboardHeaderPlus(),#...shortened.... sidebar <- dashboardSidebar( collapsed = TRUE,sidebarMenu( id = "navbar",menuItem("Start",tabName = "page_start",icon = icon("play")),menuItem("Second",tabName = "page_dashboard",icon = icon("home")),menuItemOutput("rend_dashboard") #...shortened.... ) ),body <- dashboardBody( #tags$script(HTML("$('body').addClass('fixed');")),tabItems( # Tab Start tabItem(tabName = "page_start",startUi("Start")),# Tab Dashboard tabItem(tabName = "page_dashboard",runUi("mod2") ),tabItem(tabName = "page_dashboard2",plotOutput("unif") ) #...shortened.... ) ) ) server <- function(input,session) { btn <- startServer("Start") runServer("mod2",btn) observeEvent(btn(),{ #Sidebar update output$rend_dashboard <- renderMenu({ menuItem( "Dashboard",tabName = "page_dashboard2",icon = icon("dashboard") ) }) }) output$unif <- renderPlot({hist(runif(500))}) #overviewServer("Overview") #...shortened.... } shinyApp(ui = ui,server = server) loadknown 或程序流中可执行文件名称的自动查找中。
  • 操作数堆栈转储显示单个 get,因此它必须发生在堆栈上只有一个 0 的地方。
  • 0 表明 GS 遇到了一个它不知道如何处理的字符。