Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have combined two pdf files as follows

pdf = CombinePDF.new
pdf << CombinePDF.parse(Net::HTTP.get_response(URI.parse(@task.assignable.pdf_file.try(:file).try(:url))).body, allow_optional_content: true)
pdf << CombinePDF.load(file1_path) # one way to combine, very fast.
pdf.save "combined.pdf"

I can check and see my combined file by downloading as follows:

send_data pdf.to_pdf, filename: "combined.pdf", type: "application/pdf"

This all working fine but I want to store this pdf in @signed_pdf record.

It is allowing to to store the pdf in my record as follow:

@signed_pdf.signed_file = pdf.to_pdf

but it seems not to good approach. I want to store it as object.

@signed_pdf.signed_file = pdf

but in this case using @signed_pdf.signed_file.to_pdf for downloading purpose or any other purpose showing the error:

undefined method `to_pdf' for "#<CombinePDF::PDF:0x000000000dabd5d0>":String Did you mean? to_f to_d

What would be the beeter way to store combined pdf in my record?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
184 views
Welcome To Ask or Share your Answers For Others

1 Answer

I think you need to store the pdf on files system or a block storage provider (Amazon S3) and save the path to the db instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...