Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 当一个pdf文件存储在s3存储桶上时,如何使用combine pdf gem组合pdf_Ruby On Rails_Pdf_Amazon S3 - Fatal编程技术网

Ruby on rails 当一个pdf文件存储在s3存储桶上时,如何使用combine pdf gem组合pdf

Ruby on rails 当一个pdf文件存储在s3存储桶上时,如何使用combine pdf gem组合pdf,ruby-on-rails,pdf,amazon-s3,Ruby On Rails,Pdf,Amazon S3,在我的任务表中,我可以访问存储在s3存储桶中的pdf文件@task&.assignable&.pdf_文件。 我可以使用@task&.assignable&.pdf_file.file.url访问它的url 我想在同一个pdf文件中添加一个新页面,因此我正在使用。它正在获取我用wicked\u pdf生成的file1的路径,但是是在线的 pdf << CombinePDF.load(@task&.assignable&.pdf_file.file.url) pdf.

在我的
任务
表中,我可以访问存储在s3存储桶中的pdf文件
@task&.assignable&.pdf_文件
。 我可以使用
@task&.assignable&.pdf_file.file.url访问它的url

我想在同一个pdf文件中添加一个新页面,因此我正在使用。它正在获取我用
wicked\u pdf
生成的
file1
的路径,但是是在线的

pdf << CombinePDF.load(@task&.assignable&.pdf_file.file.url)
pdf.pdf?<访问密钥>

file1_path = Rails.root.join('tmp', filename)
pdf = WickedPdf.new.pdf_from_string(
  render_to_string('patient_engagements/signed_page', layout: 'pdf', locals: { :@signed_pdf => @signed_pdf })
)
File.open(file1_path, 'wb') do |file|
  file << pdf
end

pdf = CombinePDF.new
pdf << CombinePDF.load(file1_path) # one way to combine, very fast.
pdf << CombinePDF.load(@task&.assignable&.pdf_file.file.url)
pdf.save "combined.pdf"
file1\u path=Rails.root.join('tmp',文件名)
pdf=WickedPdf.new.pdf\u from\u字符串(
呈现到字符串(“患者预约/签名页面”,布局:'pdf',本地:{:@signed\u pdf=>@signed\u pdf})
)
打开(file1_路径,'wb')do|文件|

文件不能对远程文件使用加载,请改用


从at CombinePDF文档中提取。

您不能对远程文件使用加载,请改用


摘自at CombinePDF docs。

您能接受答案吗?我想你认为我的答案是正确的,所以,请接受它。你能接受这个答案吗?我想你会认为我的回答是正确的,所以,请接受它。
require 'combine_pdf'
require 'net/http'

url = "https://example.com/my.pdf"
pdf = CombinePDF.parse Net::HTTP.get_response(URI.parse(url)).body