Comments (3)
The only way I know of to get the signed version of the PDF would be to get it in the docusign_response action where we know the document has actually been signed. When you're in the embedded_signing action they have the ability to refuse to sign or decide to do it later, etc. The PDF you're generating in that action is explicitly the unsigned one, which is why you're seeing that when pulling it up. below is some code from the app I use inside the docusign_response action. Note, I'm storing the envelope_id in the db so I can reference it later. This would theoretically allow you to pull up the PDF at any other time, but I store it locally to limit API calls.
cf (campaign_firm) refers to a model association that links the two users signing the contract
# get the PDF and store it locally so both parties can reference it
fn = "#{SecureRandom.urlsafe_base64(7)}.pdf"
save_path = Rails.root.join("docusign_docs/#{fn}").to_s
client.get_document_from_envelope(
envelope_id: cf.envelope_id,
document_id: 1,
local_save_path: save_path
)
# Store the filename so we can reference it later. Note: I intentionally
# did not store the full file path in case we need to move where the
# files are stored
cf.update_attributes(pdf_name: fn)
from docusign_rest.
Thanks! Persisting the envelope_id in the database as a model attribute what I ended up doing in the meantime, though I wasn't sure if it was optimal, so glad to see you confirm it.
I also didn't have the pdf filename security that you included here; great idea, and I'll make sure to include that also.
from docusign_rest.
Using SecureRandom like that could still technically lead to file name conflicts (aka it's possible SecureRandom could generate the same name twice) and that would be bad. I have a module that I include in any controller that uses Docusign to deal with some of the repeated code. Feel free to use this as-is or pull out a piece of it if you like.
module PDFGenerator
def generate_pdf_name(attrs)
file_dir = attrs[:file_dir]
file_name_prefix = attrs.fetch(:file_name_prefix, '')
begin
name = "#{file_name_prefix}#{SecureRandom.urlsafe_base64(7)}"
end while File.exists?("#{file_dir}/#{name}.pdf")
name
end
def generate_pdf(attrs)
view_template = attrs[:view_template]
locals = attrs[:locals]
file_dir = attrs[:file_dir]
file_name_prefix = attrs.fetch(:file_name_prefix, '')
html = render_to_string(
partial: view_template,
locals: locals,
layout: false
)
kit = PDFKit.new(html)
css_file_path = "#{Rails.root}/app/assets/stylesheets/pdf.css"
kit.stylesheets << css_file_path if css_file_path
FileUtils.mkdir_p(file_dir)
fn = "#{generate_pdf_name(file_name_prefix: file_name_prefix,
file_dir: file_dir)}.pdf"
fp = Rails.root.join("#{file_dir}/#{fn}").to_s
kit.to_file(fp)
{file_name: fn, file_path: fp}
end
end
from docusign_rest.
Related Issues (20)
- Version Needs Bumped HOT 1
- INVALID_ANCHOR_TAB_STRING on example HOT 2
- Regarding your note HOT 1
- Composite template method errors HOT 2
- Gem Version HOT 2
- Sending value to custom field HOT 3
- baseUrl HOT 5
- Roadmap
- Adding an attachment to an envelope HOT 6
- INVALID_CONTENT_TYPE with create_envelope_from_document HOT 2
- Embedded signing and also send the Envelope to signers email HOT 2
- Typo when checking presence of :wet_sign option HOT 2
- Can we enable :require_sign_on_paper option from create_envelope_from_document? HOT 1
- No recipients HOT 2
- Carbon Copy Recipients in Composite Templates HOT 2
- Inline Signers in Composite Template HOT 1
- Missing README documentation for signer -> `:routing_order`
- event notification status HOT 2
- Custom fields per signer not showing up in document
- Trying to add expiration and reminder details for an envelope but the gem is not considering them, is there any way to add expirations and reminder details while creating an envelope?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docusign_rest.