You do not need to use attachment with a question ; it can stand on its own, and it will be evaluated when docassemble needs the definition of the variable indicated by a variable name within the attachment block. The variable indicated by variable name will be defined as an object of class DAFileCollection. An object of this type will have attributes for each file type generated, where each atttribute is an object of type DAFile.
A DAFile has the following attributes:. You limit the file formats that are generated by attachment. To hide the PDF file, set valid formats to docx only. The code needs to refer to a Python expression e. The expression can return:. You can also set it to Python code. If the code evaluates to a True value, a tagged PDF will be produced. If you want the PDF file produced by an attachment to be protected with a password, you can set a password , and the PDF file will be encrypted.
The password can be specified in the following ways:. If your template file uses encryption, you can set a template password to the password of the PDF template so that it can be decrypted. If you get an encryption error when trying to use a PDF, it might be the case that your PDF is encrypted with the empty string. In this case, it might help to do:.
When you are using docx template file , you can insert hyperlinks into your assembled file using the Markdown format for a hyperlink. If you are using Microsoft Word , your document may not contain a character style called Hyperlink. The character style is not created by default when you create a new file in Microsoft Word.
However, it is easy to cause the style to be added: edit your template in Microsoft Word, add a hyperlink manually any hyperlink will do , save the file, and then delete the hyperlink. When you create the link, Microsoft Word will create the character style Hyperlink and it the character style will persist even after you delete the hyperlink. If you want to manually specify a character style to be used for hyperlinks, you can set a hyperlink style. If there is no hyperlink style and no character style called Hyperlink or InternetLink , then underlined blue text will be used for hyperlinks.
For example, if your user is Spanish-speaking, but you need to produce an English language document, you may find that a word or two in the English language document has been translated into Spanish. You can remedy this by defining a language for the attachment. Without language: en , the output would be:. The value of language must be plain text like en or fr ; it cannot be a Mako expression.
If you want to use docassemble to assemble text files, set raw: True and use a content file. If you use variable name , the result will be a DAFileCollection object with the attribute raw set to a DAFile object representing the assembled text file. By default, access to documents is limited to the user who created it and to any other users who have joined the interview session.
Access to files can be managed using the methods. You can also control the permissions on files using specifiers under attachment. By default, any file that a user uploads during a session will be deleted when that session is deleted.
If you want the file to continue to exist after the session is deleted, you can set the persistent specifier to True. The modifier also accepts Python code; if the code evaluates to a true value, the file will persist. This has the same effect as calling the. By default, any file that a user uploads will only be downloadable by a session user or by an administrator. If you want the file to be accessible to anyone, set the field modifier private to False.
The modifier also accepts Python code; if the code evaluates to a false value, the file will be available to anyone. If you set private: False , then the file is available to anyone, including non-logged in users. Even a bot that guesses URLs could download the file. If you want to share with particular users, you can indicate specific users using the allow users specifier.
If allowed users refers to a YAML list, the list is expected to be a list of e-mail addresses of users or integers indicating the numeric user IDs of users. If allow users refers to text, the text is treated as a single item. If allow users refers to a YAML dictionary, the single key of which is code , you can define the list with Python code. The code is expected to evalute to an e-mail address, an integer user ID, an Individual with the email attribute set, or a list or DAList of any of the above.
You can also use the. Instead of granting access to specific other users, you can grant access to categories of users by referencing privileges by name, such as user , developer , or advocate. If the allow privileges specifier refers to a YAML list, the list items are expected to be text items like user or developer.
If allow privileges refers to a string, it is treated as a single item. If it refers to a YAML dictionary, the single key of which is code , you can define the privileges using Python code, which is expected to evaluate to text e. If you want to assemble a document but redact certain pieces of information from it, you can use the redact function on the parts you want redacted, and the text will be replaced with black rectangles.
If you want to produce an unredacted version of the same document, assemble it with redact: False. For more information about this feature, see the documentation for the redact function. The list of attachments shown in a question can be generated by Python code that returns a list of DAFileCollection objects. If attachment code is included in the question, the value will be evaluated as Python code. In the following example, the Python code returns an array of three DAFileCollection objects, each of which was generated with a separate attachment block.
As a result, in most cases you will need to edit your Configuration in order for e-mailing to work. The easiest and most effective way to enable e-mailing is to use the Mailgun API which is free , but you can also use an external SMTP server hosted by Mailgun or another provider. If you want to customize the subject and body of the e-mail, you can use the email template modifier:. The email template modifier needs to refer to a Python expression referring to a template.
Instead of setting email template , you can use the modifiers email subject and email body. You can use Mako and Markdown in these modifiers. The email subject and email body modifiers take precedence over the parts of the template indicated by email template.
If you would like to set another default value, you can use the email address default modifier. Mako and Markdown can be used. If the result does not look like an e-mail address, it will be ignored.
The attachment interface is simple and exists only to allow an end user to e-mail a document to an address of their own choosing. By default, if an attachment includes a PDF version along with an editable version, such as a DOCX file, the user will have an option of including the editable version in the e-mail or download.
If you want the editable documents to always be included, set always include editable files to True. When attachments are included in a question , the user will be given an option to e-mail the documents to an e-mail address. If you would like to disable this feature, set allow emailing to False.
Including allow emailing: False will disable this:. You can also use a Python expression instead of True or False. If you would like users to be able to download all of the attachments as a single ZIP file , set allow downloading to True. By default, this feature is disabled. You can customize the name of the ZIP file by setting a zip filename :. To omit this tab bar, set include download tab to False.
There are alternatives to using attachment or attachment code for displaying assembled files to the user. If you use variable name within an attachment to create a DAFileCollection object that represents the assembled file, you can use this variable to provide the file to the user in the context of a question in a number of different ways:.
If a DAFile is inserted into a template e. If a DAFileCollection object is inserted into a template, each file type is inserted. If you use valid formats to limit the file types created, only the specified file types will be inserted. Since document assembly can take the server a long time, docassemble uses caching to avoid assembling the same document more than once. In most situations, document caching is a welcome feature because users do not have to wait as long.
However, it might not always be what you want. For example, if you present the same document in two different question s using attachment code , the same document that was assembled for the first question will be presented in the second question , even if changes were made to the underlying variables in the interim. To force the re-assembly of the document, you can use code to delete the variable that represents the document.
Here is an example:. If you want to turn off document caching entirely for a given interview, see the cache documents feature. Docassemble Demo Documentation Download Deploy. Markdown files are text plain text files which can contain text inline symbols for formating the text e. MD files are also often used by version control systems like GitHub e. CloudConvert is your Swiss army knife for file conversions. We support nearly all audio, video, document, ebook, archive, image, spreadsheet, and presentation formats.
Use the File Open dialog box to locate the document. Word cannot open the document: user does not have access privileges. Word cannot open this document template. Word was unable to read the document. It may be corrupt. Word document is corrupted. Microsoft Word has encountered a problem and needs to close. We are sorry for the inconvenience. Please tell Microsoft about this problem. The document caused a serious error the last time it was opened. Would you like to continue opening it? There is not enough memory or disk space to complete the operation.
This document may be corrupt. The file appears to be corrupted. The file is corrupt and cannot be opened. This files format turns a plain-text format into a formatted document. It supports almost all the Operating Systems. It can contain large amount of text, data, charts, table, image etc.
CloudConvert is your Swiss army knife for file conversions.
0コメント