Browse Source

Margin for PDF output can now be defined as an object allowing different margins to be applied to each edge of PDF - https://github.com/jonnnnyw/php-phantomjs/issues/113

Jonny Wenmoth 9 years ago
parent
commit
0baec84ed6

+ 3 - 3
src/JonnyW/PhantomJs/Http/PdfRequest.php

@@ -52,7 +52,7 @@ class PdfRequest extends CaptureRequest
     /**
      * Margin
      *
-     * @var string
+     * @var string|array
      * @access protected
      */
     protected $margin;
@@ -221,7 +221,7 @@ class PdfRequest extends CaptureRequest
      * Set margin.
      *
      * @access public
-     * @param  string $margin
+     * @param  string|array $margin
      * @return void
      */
     public function setMargin($margin)
@@ -233,7 +233,7 @@ class PdfRequest extends CaptureRequest
      * Get margin.
      *
      * @access public
-     * @return string
+     * @return string|array
      */
     public function getMargin()
     {

+ 1 - 1
src/JonnyW/PhantomJs/Resources/procedures/page_paper_size.partial

@@ -5,7 +5,7 @@
         paperHeight      = '{{ input.getPaperHeight() }}',
         paperFormat      = '{{ input.getFormat() }}',
         paperOrientation = '{{ input.getOrientation() }}',
-        paperMargin      = '{{ input.getMargin() }}',
+        paperMargin      = {{ input.getMargin()|json_encode(constant('JSON_FORCE_OBJECT')) }},
         header           = {{ input.getRepeatingHeader()|json_encode(constant('JSON_FORCE_OBJECT')) }},
         footer           = {{ input.getRepeatingFooter()|json_encode(constant('JSON_FORCE_OBJECT')) }};