使用Ruby和Node.js将图像错误显示为pdf

时间:2018-06-29 15:23:16

标签: node.js ruby rubygems base64 prawn

我在node.js和ruby中做一个后端,应用程序执行写操作,从base64生成jpg图像,然后ruby使用该图像生成带有大虾的报告!但是当执行ruby代码时,我得到了,该如何解决? (我声明javascript文件和ruby都在同一个文件夹中)

错误: 来自/Users/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/images.rb:92:in {{1 }}“图片”来自report.rb:75:位于{/myuser/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2中的build_image_object' from /myuser/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/images.rb:71:in instance_eval”中。 2 / lib / prawn / document.rb:236:在block (3 levels) in ' from /myuser/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/document.rb:236:in新文件中来自/myuser/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2 .2 / lib / prawn / document.rb:142:in initialize' from /myuser/myuser/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/document.rb:142:in块(2个级别)中 'from report.rb:19:in generate' from report.rb:49:in block in

分两个阶段总结程序:

  1. Node.js生成jpg
  2. Ruby生成PDF

Ruby代码:

synchronize' from report.rb:19:in

Node.js:

require "prawn"
require "prawn/table"
require "thread"
require "date"

mutex = Mutex.new

a = Thread.new {
  mutex.synchronize {

logo=Dir.pwd+"/logo.jpg"
tecnicofirma=Dir.pwd+"/firmatecnico.jpg"
d=ARGV[0]
a=ARGV[1]
b=ARGV[2]
c=ARGV[3]
e=ARGV[4]
f=ARGV[5]
g=ARGV[6]
k="x"
l="x"

b= []
a = []
c = []


#get date
date = Date.today
stringDate = "#{date.day}-#{date.month}-#{date.year}"

#make pdf
Prawn::Document.generate("my.pdf") do
  image logo,:width=>540,:height=>50
 # text "x ",:align=>:right
  move_down 20
  #text "\n"+x, :align => :right
  text "x:      "
  move_down 10
  text "x x: "
  move_down 10
  text "x:  "+x
  move_down 10
  text "x:  "+x
  move_down 10
  text "x:  "+x
  move_down 15
  text "Note: "+d
  move_down 23
  #end 
  table([
  ["x / x", "x", "x"],
  *[a,b, c]
  .transpose
  ], :width => 550)
  move_down 50
  text "x:", :align => :left
  text "x:", :align => :right

  image tecnicofirma,  :width=>130, :height=>70, :position => :right
 end


 }
}
a.join();

0 个答案:

没有答案