PDF Embedder - Version 1.0.3

Version Description

Download this release

Release Info

Developer danlester
Plugin Icon 128x128 PDF Embedder
Version 1.0.3
Comparing to
See all releases

Code changes from version 1.0.2 to 1.0.3

css/pdfemb-embed-pdf.css CHANGED
@@ -57,6 +57,24 @@ div.pdfemb-toolbar button {
57
  display: inline-block;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  div.pdfemb-errormsg {
61
  padding: 5px;
62
  text-align: center;
57
  display: inline-block;
58
  }
59
 
60
+ div.pdfemb-toolbar span {
61
+ margin: 6px 0 0 10px;
62
+ height: 25px;
63
+ font-family: sans-serif;
64
+ font-size: 10px;
65
+ padding: 5px;
66
+ text-align: center;
67
+ letter-spacing: normal;
68
+ word-spacing: normal;
69
+ line-height: 1;
70
+ text-transform: none;
71
+ text-indent: 0px;
72
+ text-shadow: none;
73
+ font-weight: normal;
74
+ display: inline-block;
75
+ color: lightgray;
76
+ }
77
+
78
  div.pdfemb-errormsg {
79
  padding: 5px;
80
  text-align: center;
js/all-pdfemb-basic.min.js CHANGED
@@ -1,5 +1,5 @@
1
- function pdfembGetPDF(b,a){a(b)};jQuery(document).ready(function(b){b.fn.pdfEmbedder=function(){this.each(function(a,h){var c=b(h);c.append(b("<canvas></canvas>",{"class":"the-canvas"}));var e=c.attr("data-pdf-url");pdfembGetPDF(e,function(a){PDFJS.getDocument(a).then(function(a){c.data("pdfDoc",a);b.fn.pdfEmbedder.addToolbar(c,!1);c.data("pageNum",1);c.data("pageNumPending",null);b.fn.pdfEmbedder.renderPage(c,1);b(window).resize(function(){b.fn.pdfEmbedder.queueRenderPage(c,c.data("pageNum"))})},function(a){c.empty().append(b("<div></div>",
2
- {"class":"pdfemb-errormsg"}).append(document.createTextNode(a.message)))})})});return this};b.fn.pdfEmbedder.renderPage=function(a,h){a.data("pageRendering",!0);a.data("pdfDoc").getPage(h).then(function(c){var e=a.find(".the-canvas"),f,g=c.getViewport(1);f=g.width;g=g.height;(0>=f||0>=g)&&a.empty().append(document.createTextNode("PDF page width or height are invalid"));var k=a.parent().width(),d=f,l=g;if("max"==a.data("width"))d=k;else if("auto"==a.data("width"))d=f;else if(d=parseInt(a.data("width"),
3
- 10),isNaN(d)||0>=d)d=k;0>=d&&(d=f);d>k&&0<k&&(d=k);f=d/f;l=g*f;d!=e.width()&&e.width(d);d!=a.width()&&a.width(d);d=parseInt(a.data("height"),10);!isNaN(d)&&0<d&&d<l&&(l=d);a.height()!=l+4&&a.height(l+4);e.height()!=g*f&&e.height(g*f);g=c.getViewport(f);e[0].height=g.height;e[0].width=g.width;e={canvasContext:e[0].getContext("2d"),viewport:g};c.render(e).promise.then(function(){a.data("pageNum",h);a.data("pageRendering",!1);null!==a.data("pageNumPending")&&(b.fn.pdfEmbedder.renderPage(a,a.data("pageNumPending")),
4
- a.data("pageNumPending",null))})})};b.fn.pdfEmbedder.queueRenderPage=function(a,h){a.data("pageRendering")?a.data("pageNumPending",h):b.fn.pdfEmbedder.renderPage(a,h)};b.fn.pdfEmbedder.addToolbar=function(a,h){var c=b("<div></div>",{"class":"pdfemb-toolbar "+(h?" pdfemb-toolbar-top":"pdfemb-toolbar-bottom")}),e=b("<button>Prev</button>",{"class":"pdfemb-prev"});c.append(e);var f=b("<button>Next</button>",{"class":"pdfemb-next"});c.append(f);h?a.prepend(c):a.append(c);e.on("click",function(c){1>=a.data("pageNum")||
5
- (a.data("pageNum",a.data("pageNum")-1),b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});f.on("click",function(c){a.data("pageNum")>=a.data("pdfDoc").numPages||(a.data("pageNum",a.data("pageNum")+1),b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});a.on("mouseenter",function(b){a.find("div.pdfemb-toolbar").show()});a.on("mouseleave",function(b){a.find("div.pdfemb-toolbar").hide()})};PDFJS.workerSrc=pdfemb_trans.worker_src;b(".pdfemb-viewer").pdfEmbedder()});
1
+ function pdfembGetPDF(b,a){a(b,!1)};jQuery(document).ready(function(b){b.fn.pdfEmbedder=function(){this.each(function(a,h){var e=b(h);e.append(b("<canvas></canvas>",{"class":"the-canvas"}));var c=e.attr("data-pdf-url");pdfembGetPDF(c,function(a,c){PDFJS.getDocument(a).then(function(a){e.data("pdfDoc",a);b.fn.pdfEmbedder.addToolbar(e,!1,c);e.data("pageNum",1);e.data("pageNumPending",null);b.fn.pdfEmbedder.renderPage(e,1);b(window).resize(function(){b.fn.pdfEmbedder.queueRenderPage(e,e.data("pageNum"))})},function(a){e.empty().append(b("<div></div>",
2
+ {"class":"pdfemb-errormsg"}).append(document.createTextNode(a.message)))})})});return this};b.fn.pdfEmbedder.renderPage=function(a,h){a.data("pageRendering",!0);a.data("pdfDoc").getPage(h).then(function(e){var c=a.find(".the-canvas"),g,f=e.getViewport(1);g=f.width;f=f.height;(0>=g||0>=f)&&a.empty().append(document.createTextNode("PDF page width or height are invalid"));var k=a.parent().width(),d=g,l=f;if("max"==a.data("width"))d=k;else if("auto"==a.data("width"))d=g;else if(d=parseInt(a.data("width"),
3
+ 10),isNaN(d)||0>=d)d=k;0>=d&&(d=g);d>k&&0<k&&(d=k);g=d/g;l=f*g;d!=c.width()&&c.width(d);d!=a.width()&&a.width(d);d=parseInt(a.data("height"),10);!isNaN(d)&&0<d&&d<l&&(l=d);a.height()!=l+4&&a.height(l+4);c.height()!=f*g&&c.height(f*g);f=e.getViewport(g);c[0].height=f.height;c[0].width=f.width;c={canvasContext:c[0].getContext("2d"),viewport:f};e.render(c).promise.then(function(){a.data("pageNum",h);a.data("pageRendering",!1);null!==a.data("pageNumPending")&&(b.fn.pdfEmbedder.renderPage(a,a.data("pageNumPending")),
4
+ a.data("pageNumPending",null))})})};b.fn.pdfEmbedder.queueRenderPage=function(a,h){a.data("pageRendering")?a.data("pageNumPending",h):b.fn.pdfEmbedder.renderPage(a,h)};b.fn.pdfEmbedder.addToolbar=function(a,h,e){var c=b("<div></div>",{"class":"pdfemb-toolbar "+(h?" pdfemb-toolbar-top":"pdfemb-toolbar-bottom")}),g=b("<button>Prev</button>",{"class":"pdfemb-prev"});c.append(g);var f=b("<button>Next</button>",{"class":"pdfemb-next"});c.append(f);e&&c.append(b("<span>Secure</span>"));h?a.prepend(c):a.append(c);
5
+ g.on("click",function(c){1>=a.data("pageNum")||(a.data("pageNum",a.data("pageNum")-1),b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});f.on("click",function(c){a.data("pageNum")>=a.data("pdfDoc").numPages||(a.data("pageNum",a.data("pageNum")+1),b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});a.on("mouseenter",function(b){a.find("div.pdfemb-toolbar").show()});a.on("mouseleave",function(b){a.find("div.pdfemb-toolbar").hide()})};PDFJS.workerSrc=pdfemb_trans.worker_src;b(".pdfemb-viewer").pdfEmbedder()});
js/pdfemb-basic.js CHANGED
@@ -1,7 +1,7 @@
1
 
2
  function pdfembGetPDF(url, callback) {
3
 
4
- callback(url);
5
 
6
  };
7
 
1
 
2
  function pdfembGetPDF(url, callback) {
3
 
4
+ callback(url, false);
5
 
6
  };
7
 
js/pdfemb-embed-pdf.js CHANGED
@@ -11,7 +11,7 @@ jQuery(document).ready(function ($) {
11
 
12
  var url = divContainer.attr('data-pdf-url');
13
 
14
- var callback = function(pdf) {
15
 
16
  /**
17
  * Asynchronously downloads PDF.
@@ -21,8 +21,7 @@ jQuery(document).ready(function ($) {
21
  divContainer.data('pdfDoc', pdfDoc_);
22
  //document.getElementById('page_count').textContent = this.pdfDoc.numPages;
23
 
24
- //$.fn.pdfEmbedder.addToolbar(divContainer, true);
25
- $.fn.pdfEmbedder.addToolbar(divContainer, false);
26
 
27
  // Initial/first page rendering
28
  divContainer.data('pageNum', 1);
@@ -158,13 +157,18 @@ jQuery(document).ready(function ($) {
158
  }
159
  };
160
 
161
- $.fn.pdfEmbedder.addToolbar = function(divContainer, atTop){
162
 
163
  var toolbar = $('<div></div>', {'class': 'pdfemb-toolbar '+(atTop ? ' pdfemb-toolbar-top' : 'pdfemb-toolbar-bottom')});
164
  var prevbtn = $('<button>Prev</button>', {'class': "pdfemb-prev"});
165
  toolbar.append(prevbtn);
166
  var nextbtn = $('<button>Next</button>', {'class': "pdfemb-next"});
167
  toolbar.append(nextbtn);
 
 
 
 
 
168
  //<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span></div>
169
 
170
  if (atTop) {
11
 
12
  var url = divContainer.attr('data-pdf-url');
13
 
14
+ var callback = function(pdf, showIsSecure) {
15
 
16
  /**
17
  * Asynchronously downloads PDF.
21
  divContainer.data('pdfDoc', pdfDoc_);
22
  //document.getElementById('page_count').textContent = this.pdfDoc.numPages;
23
 
24
+ $.fn.pdfEmbedder.addToolbar(divContainer, false, showIsSecure);
 
25
 
26
  // Initial/first page rendering
27
  divContainer.data('pageNum', 1);
157
  }
158
  };
159
 
160
+ $.fn.pdfEmbedder.addToolbar = function(divContainer, atTop, showIsSecure){
161
 
162
  var toolbar = $('<div></div>', {'class': 'pdfemb-toolbar '+(atTop ? ' pdfemb-toolbar-top' : 'pdfemb-toolbar-bottom')});
163
  var prevbtn = $('<button>Prev</button>', {'class': "pdfemb-prev"});
164
  toolbar.append(prevbtn);
165
  var nextbtn = $('<button>Next</button>', {'class': "pdfemb-next"});
166
  toolbar.append(nextbtn);
167
+
168
+ if (showIsSecure) {
169
+ toolbar.append($('<span>Secure</span>'));
170
+ }
171
+
172
  //<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span></div>
173
 
174
  if (atTop) {
pdf_embedder.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: PDF Embedder
5
  * Plugin URI: http://wp-glogin.com/pdf-embedder
6
  * Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
7
- * Version: 1.0.2
8
  * Author: Dan Lester
9
  * Author URI: http://wp-glogin.com/
10
  * License: GPL3
@@ -58,6 +58,21 @@ class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
58
  protected function pdfemb_options_submit() {
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  // AUX
62
 
63
  protected function my_plugin_basename() {
4
  * Plugin Name: PDF Embedder
5
  * Plugin URI: http://wp-glogin.com/pdf-embedder
6
  * Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
7
+ * Version: 1.0.3
8
  * Author: Dan Lester
9
  * Author URI: http://wp-glogin.com/
10
  * License: GPL3
58
  protected function pdfemb_options_submit() {
59
  }
60
 
61
+ protected function pdfemb_mainsection_text() {
62
+ parent::pdfemb_mainsection_text();
63
+ ?>
64
+ <h2>Protect your PDFs using PDF Embedder Secure</h2>
65
+ <p>Our premium PDF Embedder Secure plugin provides the same simple but elegant viewer for your website visitors, with the added protection that
66
+ it is difficult for them to download or print the original PDF document.</p>
67
+
68
+ <p>This means that your PDF is unlikely to be shared outside your site where you have no control over who views, prints, or shares it.</p>
69
+
70
+ <p>See our website <a href="http://wp-pdf.com/secure/?utm_source=PDF%20Settings&utm_medium=freemium&utm_campaign=Freemium">wp-pdf.com</a> for more
71
+ details and purchase options.
72
+ </p>
73
+ <?php
74
+ }
75
+
76
  // AUX
77
 
78
  protected function my_plugin_basename() {
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: danlester
3
  Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
4
  Requires at least: 3.3
5
  Tested up to: 4.1
6
- Stable tag: 1.0.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -19,6 +19,17 @@ The viewer currently has Next/Prev buttons to page through the document, and mor
19
 
20
  It uses a customized version of Mozilla's PDF.js project, but embeds it within your existing WordPress pages so we have full control over appearance. Other plugins may use similar technology, but they will insert the PDF itself into an 'iframe' which means they do not get the flexibility over sizing.
21
 
 
 
 
 
 
 
 
 
 
 
 
22
  = Usage =
23
 
24
  Once installed and Activated, click Add Media from any page or post, just like adding an image, but drag and drop a PDF file instead.
@@ -39,7 +50,7 @@ Resizing works as follows:
39
  * If width='auto' the width will be equal to the 'natural' width of the PDF document contents (i.e. however width the PDF says it should be by default).
40
  * If width is a number (e.g. width='500') then it will display at that number of pixels wide.
41
 
42
- **In all cases, if the parent container is narrower than the width calculated above, then the document width will be reduced to the size of the container.**
43
 
44
  The height will be calculated so that the document fits naturally, given the width already calculated.
45
 
@@ -55,13 +66,21 @@ The height will be reduced to fit if it is larger than needed to display the doc
55
 
56
  = How can I obtain support for this product? =
57
 
58
- Please feel free to email [support@wp-glogin.com](mailto:support@wp-glogin.com) with any questions (specifying PDF Embedder in the subject).
59
 
60
  Always include your full shortcode, plus links to the relevant pages, and screenshots if they would be helpful too.
61
 
62
  We may occasionally be able to respond to support queries posted on the 'Support' forum here on the wordpress.org
63
  plugin page, but we recommend sending us an email instead if possible.
64
 
 
 
 
 
 
 
 
 
65
  == Installation ==
66
 
67
  Easiest way:
3
  Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
4
  Requires at least: 3.3
5
  Tested up to: 4.1
6
+ Stable tag: 1.0.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
19
 
20
  It uses a customized version of Mozilla's PDF.js project, but embeds it within your existing WordPress pages so we have full control over appearance. Other plugins may use similar technology, but they will insert the PDF itself into an 'iframe' which means they do not get the flexibility over sizing.
21
 
22
+ = Secure PDF Embedder =
23
+
24
+ **Protect your PDFs with our premium version - PDF Embedder Secure**
25
+
26
+ Our premium PDF Embedder Secure plugin provides the same simple but elegant viewer for your website visitors, with the added protection that it is difficult for them to
27
+ download or print the original PDF document.
28
+
29
+ This means that your PDF is unlikely to be shared outside your site where you have no control over who views, prints, or shares it.
30
+
31
+ See our website [wp-pdf.com](http://wp-pdf.com/secure/?utm_source=PDF%20Readme&utm_medium=freemium&utm_campaign=Freemium) for more details and purchase options.
32
+
33
  = Usage =
34
 
35
  Once installed and Activated, click Add Media from any page or post, just like adding an image, but drag and drop a PDF file instead.
50
  * If width='auto' the width will be equal to the 'natural' width of the PDF document contents (i.e. however width the PDF says it should be by default).
51
  * If width is a number (e.g. width='500') then it will display at that number of pixels wide.
52
 
53
+ *In all cases, if the parent container is narrower than the width calculated above, then the document width will be reduced to the size of the container.*
54
 
55
  The height will be calculated so that the document fits naturally, given the width already calculated.
56
 
66
 
67
  = How can I obtain support for this product? =
68
 
69
+ Please feel free to email [contact@wp-pdf.com](mailto:contact@wp-pdf.com) with any questions.
70
 
71
  Always include your full shortcode, plus links to the relevant pages, and screenshots if they would be helpful too.
72
 
73
  We may occasionally be able to respond to support queries posted on the 'Support' forum here on the wordpress.org
74
  plugin page, but we recommend sending us an email instead if possible.
75
 
76
+ = Can I protect my PDFs so they are difficult for viewers to download directly? =
77
+
78
+ Not with the free version - it is relatively easy to find the link to download the file directly.
79
+
80
+ A premium version is available that encrypts the PDF during transmission, so it is difficult for a casual user to save or print the file for use outside your site.
81
+
82
+ See our website [wp-pdf.com](http://wp-pdf.com/secure/?utm_source=PDF%20Readme%20FAQ&utm_medium=freemium&utm_campaign=Freemium) for more details and purchase options.
83
+
84
  == Installation ==
85
 
86
  Easiest way: