Answers.Body: <p>Following the Digital download docs you may need the file path, so in order to get the file path in Enupal Snapshot you may need to return the <a href="https://enupal.com/craft-plugins/enupal-snapshot/docs/advanced/return-asset-model" rel="nofollow noreferrer">asset model</a> of the PDF:</p>
  
  <pre><code>{%  set settings = {
          filename: 'my-first-pdf.pdf',
          inline: false,
          asModel: true
      }
  %}
  
  {% set assetModel = craft.enupalsnapshot.displayTemplate("reports/pdf-report", settings) %}
  
  {# Digital Download code #}
  {% set token = craft.digitalDownload.createToken(assetModel, options) %}
  
  &lt;a href="{{ craft.digitalDownload.url(token) }}"&gt;{{ assetModel.filename}}&lt;/a&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-27T13:55:31.757Z
Answers.Text: Hi @LindseyD - no thoughts on this?
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-28T14:57:30.637Z
Answers.Text: Hi @DanLee are you sure you're passing the following settings?
  
  inline: false,
  asModel: true
Answers.UserDisplayName: Andre L.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-28T15:22:13.293Z
Answers.Text: Hi @DanLee I also updated the example the filePath is not needed. We just need to pass the assetModel instead.
Answers.UserDisplayName: Andre L.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-29T10:01:04.740Z
Answers.Text: @AndreL. I am using the settings - see my code above. I made the changes regarding the filePath as you suggest. I now get an error that says "Variable "options" does not exist."
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-01T21:37:59.800Z
Answers.Text: @DanLee What are your Craft CMS and Snapshot versions?
Answers.UserDisplayName: Andre L.
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-03T11:35:10.743Z
Answers.Text: Craft 3.3.9 and the latest version of Snapshot
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-03T20:27:54.383Z
Answers.Text: @DanLee `options` does not exist because you didn't specify a value for it. You can either specify an [array of options](https://www.doublesecretagency.com/plugins/digital-download/docs/creating-a-token), or remove that parameter from your `createToken` call.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-04T11:15:20.750Z
Answers.Text: Thanks that worked! If you want to update your answer I will accept it.
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T16:22:05.673Z
Answers.Text: Thanks for the support Andre - unfortunatly I get a "Impossible to invoke a method ("getPath") on a string variable"  highlighting {% set filePath = assetModel.getPath() %}
  
  I have updated my full code above.
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T22:28:59.130Z
Answers.Text: Hi @DanLee, author of Digital Download here. I've (belatedly) replied to you [on Github](https://github.com/doublesecretagency/craft-digitaldownload/issues/5#issuecomment-555745226). If Enupal Snapshot is generating a real Asset, then you should be able to use Digital Download normally.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T09:17:50.817Z
Answers.Text: Thanks @LindseyD - I think Andre has picked up the same thing. I believe I'm almost there with the soloution - I just need to get the implimentation right.Any suggestions Andre on the error I'm getting above?
Answers.UserDisplayName: Dan Lee
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-19T13:39:08.233Z
Answers.LastActivityDate: 2019-11-28T15:20:59.943Z
Answers.LastEditDate: 2019-11-28T15:20:59.943Z
Answers.UserDisplayName: Andre L.
Body: <p>I recently purchased the Digital Download plugin for Craft.</p>
  
  <p>I'm wanting to secure a PDF download generated by another plugin called Enupal Snapshot. Reviewing the <a href="https://www.doublesecretagency.com/plugins/digital-download/docs/displaying-a-link" rel="nofollow noreferrer">Digital Download documentation</a> I'm not entirely sure how I would do that using the following code which generates the PDF on the fly?</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>Advice has been given that we need to provide the file path. In order to get the file path in Enupal Snapshot you need to return the asset model of the PDF.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>The code was changed to reflect asset model requirment. Unfortunatly I get a "<strong>Impossible to invoke a method ("getPath") on a string variable</strong>" highlighting <code>{% set filePath = assetModel.getPath() %}</code> in the code.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>{% set pdfName = 'now'|date('Y-m-d') ~ '-' ~ date().timestamp ~ '-evaluation-' ~ companyName ~ '-' ~ firstName ~ '-' ~ lastName ~ '-' ~ submissionId ~ random(50, 500) ~ '.pdf' %}
  
  {% set assetFolderRef = evaluationSettings.evaluationAssetRef %}
  {%
      set settings = {
          filename: pdfName,
          inline: false,
          overrideFile: true,
          asModel: true,
          singleUploadLocationSource: assetFolderRef,
          cliOptions: {
              'header-html': 'evaluation-tools/evaluation/pdf-header',
              'footer-html': 'evaluation-tools/evaluation/pdf-footer',
              'orientation': 'Portrait',
              'page-size': 'A4',
              'title': 'Evaluation for ' ~ companyName,
          },
          variables: {
              passSubmissionId: submissionId,
          }
      }
  %}
  
  {% set assetModel = craft.enupalsnapshot.displayTemplate("evaluation-tools/evaluation/pdf-report", settings) %}
  {% set token = craft.digitalDownload.createToken(assetModel, options) %}
  
  &lt;a href="{{ craft.digitalDownload.url(token) }}" class="f6 link white bg-animate bg-teal hover-bg-white hover-teal br-pill bn w-auto ph4 pv3 tc b pointer mb3"&gt;
      &lt;i class="fas fa-file-download"&gt;&lt;/i&gt; Download Report
  &lt;/a&gt;
  </code></pre>
  
Tags: <craft3><plugin-digitaldownload>
Title: Securing a Generated PDF
ThreadText: # Securing a Generated PDF
  
  (Asked by: username_0 on 2019-11-19)
  
  I recently purchased the Digital Download plugin for Craft.
  
  I'm wanting to secure a PDF download generated by another plugin called Enupal Snapshot. Reviewing the [Digital Download documentation](https://www.doublesecretagency.com/plugins/digital-download/docs/displaying-a-link) I'm not entirely sure how I would do that using the following code which generates the PDF on the fly?
  
  **Update 1**
  
  Advice has been given that we need to provide the file path. In order to get the file path in Enupal Snapshot you need to return the asset model of the PDF.
  
  **Update 2**
  
  The code was changed to reflect asset model requirment. Unfortunatly I get a "**Impossible to invoke a method ("getPath") on a string variable**" highlighting `{% set filePath = assetModel.getPath() %}` in the code.
  
  **Code**
  
  ```
  {% set pdfName = 'now'|date('Y-m-d') ~ '-' ~ date().timestamp ~ '-evaluation-' ~ companyName ~ '-' ~ firstName ~ '-' ~ lastName ~ '-' ~ submissionId ~ random(50, 500) ~ '.pdf' %}
  
  {% set assetFolderRef = evaluationSettings.evaluationAssetRef %}
  {%
      set settings = {
          filename: pdfName,
          inline: false,
          overrideFile: true,
          asModel: true,
          singleUploadLocationSource: assetFolderRef,
          cliOptions: {
              'header-html': 'evaluation-tools/evaluation/pdf-header',
              'footer-html': 'evaluation-tools/evaluation/pdf-footer',
              'orientation': 'Portrait',
              'page-size': 'A4',
              'title': 'Evaluation for ' ~ companyName,
          },
          variables: {
              passSubmissionId: submissionId,
          }
      }
  %}
  
  {% set assetModel = craft.enupalsnapshot.displayTemplate("evaluation-tools/evaluation/pdf-report", settings) %}
  {% set token = craft.digitalDownload.createToken(assetModel, options) %}
  
  <a href="{{ craft.digitalDownload.url(token) }}" class="f6 link white bg-animate bg-teal hover-bg-white hover-teal br-pill bn w-auto ph4 pv3 tc b pointer mb3">
      <i class="fas fa-file-download"></i> Download Report
  </a>
  
  ```
  
  **Tags:** craft3, plugin-digitaldownload
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-19. Score: 2
  
  Following the Digital download docs you may need the file path, so in order to get the file path in Enupal Snapshot you may need to return the [asset model](https://enupal.com/craft-plugins/enupal-snapshot/docs/advanced/return-asset-model) of the PDF:
  
  ```
  {%  set settings = {
          filename: 'my-first-pdf.pdf',
          inline: false,
          asModel: true
      }
  %}
  
  {% set assetModel = craft.enupalsnapshot.displayTemplate("reports/pdf-report", settings) %}
  
  {# Digital Download code #}
  {% set token = craft.digitalDownload.createToken(assetModel, options) %}
  
  <a href="{{ craft.digitalDownload.url(token) }}">{{ assetModel.filename}}</a>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for the support username_1 - unfortunatly I get a "Impossible to invoke a method ("getPath") on a string variable"  highlighting {% set filePath = assetModel.getPath() %}  I have updated my full code above.  
  > **username_2**: Hi @username_0, author of Digital Download here. I've (belatedly) replied to you [on Github](https://github.com/doublesecretagency/craft-digitaldownload/issues/5#issuecomment-555745226). If Enupal Snapshot is generating a real Asset, then you should be able to use Digital Download normally.  
  > **username_0**: Thanks @username_2 - I think username_1 has picked up the same thing. I believe I'm almost there with the soloution - I just need to get the implimentation right.Any suggestions username_1 on the error I'm getting above?  
  > **username_0**: Hi @username_2 - no thoughts on this?  
  > **username_1**: Hi @username_0 are you sure you're passing the following settings?  inline: false, asModel: true  
  > **username_1**: Hi @username_0 I also updated the example the filePath is not needed. We just need to pass the assetModel instead.  
  > **username_0**: @AndreL. I am using the settings - see my code above. I made the changes regarding the filePath as you suggest. I now get an error that says "Variable "options" does not exist."  
  > **username_1**: @username_0 What are your Craft CMS and Snapshot versions?  
  > **username_0**: Craft 3.3.9 and the latest version of Snapshot  
  > **username_2**: @username_0 `options` does not exist because you didn't specify a value for it. You can either specify an [array of options](https://www.doublesecretagency.com/plugins/digital-download/docs/creating-a-token), or remove that parameter from your `createToken` call.  
  > **username_0**: Thanks that worked! If you want to update your answer I will accept it.  
  
  ---
  
  