Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
fillpdf
Commits
d3f7b6cc
Commit
d3f7b6cc
authored
5 years ago
by
wizonesolutions
Committed by
Kevin Kaland
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2883481 by wizonesolutions, ovi.indrei, carstenG: PDF file gets downloaded as HTML file
parent
b5a016b6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/FillPdfActionPlugin/FillPdfDownloadAction.php
+2
-0
2 additions, 0 deletions
src/Plugin/FillPdfActionPlugin/FillPdfDownloadAction.php
tests/src/Functional/HandlePdfControllerTest.php
+7
-0
7 additions, 0 deletions
tests/src/Functional/HandlePdfControllerTest.php
with
9 additions
and
0 deletions
src/Plugin/FillPdfActionPlugin/FillPdfDownloadAction.php
+
2
−
0
View file @
d3f7b6cc
...
@@ -35,6 +35,8 @@ class FillPdfDownloadAction extends FillPdfActionPluginBase {
...
@@ -35,6 +35,8 @@ class FillPdfDownloadAction extends FillPdfActionPluginBase {
$this
->
configuration
[
'filename'
]
$this
->
configuration
[
'filename'
]
);
);
$response
->
headers
->
set
(
'Content-Disposition'
,
$disposition
);
$response
->
headers
->
set
(
'Content-Disposition'
,
$disposition
);
$response
->
headers
->
set
(
'Content-Type'
,
'application/pdf'
);
$response
->
headers
->
set
(
'Content-Length'
,
strlen
(
$this
->
configuration
[
'data'
]));
return
$response
;
return
$response
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Functional/HandlePdfControllerTest.php
+
7
−
0
View file @
d3f7b6cc
...
@@ -4,6 +4,7 @@ namespace Drupal\Tests\fillpdf\Functional;
...
@@ -4,6 +4,7 @@ namespace Drupal\Tests\fillpdf\Functional;
use
Drupal\Core\Url
;
use
Drupal\Core\Url
;
use
Drupal\file\Entity\File
;
use
Drupal\file\Entity\File
;
use
Symfony\Component\HttpFoundation\ResponseHeaderBag
;
/**
/**
* @coversDefaultClass \Drupal\fillpdf\Controller\HandlePdfController
* @coversDefaultClass \Drupal\fillpdf\Controller\HandlePdfController
...
@@ -35,6 +36,8 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
...
@@ -35,6 +36,8 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
/**
/**
* Tests DownloadAction.
* Tests DownloadAction.
*
* @throws \Behat\Mink\Exception\ExpectationException
*/
*/
public
function
testDownloadAction
()
{
public
function
testDownloadAction
()
{
$this
->
uploadTestPdf
(
'fillpdf_test_v3.pdf'
);
$this
->
uploadTestPdf
(
'fillpdf_test_v3.pdf'
);
...
@@ -58,6 +61,10 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
...
@@ -58,6 +61,10 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
$maybe_pdf
=
$this
->
getSession
()
->
getPage
()
->
getContent
();
$maybe_pdf
=
$this
->
getSession
()
->
getPage
()
->
getContent
();
static
::
assertEquals
(
'application/pdf'
,
$this
->
getMimeType
(
$maybe_pdf
),
'The file has the correct MIME type.'
);
static
::
assertEquals
(
'application/pdf'
,
$this
->
getMimeType
(
$maybe_pdf
),
'The file has the correct MIME type.'
);
// Ensure the headers are set to make the PDF download.
$this
->
assertSession
()
->
responseHeaderContains
(
'Content-Disposition'
,
ResponseHeaderBag
::
DISPOSITION_ATTACHMENT
);
$this
->
assertSession
()
->
responseHeaderContains
(
'Content-Type'
,
'application/pdf'
);
$this
->
assertSession
()
->
responseHeaderContains
(
'Content-Length'
,
(
string
)
strlen
(
file_get_contents
(
$this
->
getTestPdfPath
(
'fillpdf_test_v3.pdf'
))));
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment