Created
August 31, 2020 21:54
-
-
Save ThreePointSquare/b23e83248dc963cbfd33f7792bb4658a to your computer and use it in GitHub Desktop.
Eurion PDF create PDF with Eurion watermarks // source https://jsbin.com/sepitalenu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Eurion PDF</title> | |
<meta name="description" content="create PDF with Eurion watermarks"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous"></script> | |
<style id="jsbin-css"> | |
html, body { | |
box-sizing: border-box; | |
margin: 0; | |
padding: .2em .2em 1em; | |
height: 100%; | |
background: #ccffcc; | |
} | |
form { | |
margin: 0 0 .2em; | |
} | |
iframe { | |
box-sizing: border-box; | |
width: 100%; | |
height: 100%; | |
border: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<form> | |
<select> | |
<option value="#000000">Black ⚫</option> | |
<option value="#ffff00">Yellow 🟡</option> | |
<option value="#ff00ff">Magenta 🟣</option> | |
<option value="#00ffff">Cyan</option> | |
<option value="#ff0000">Red 🔴</option> | |
<option value="#00ff00">Green 🟢</option> | |
<option value="#0000ff">Blue 🔵</option> | |
</select> | |
<button>Generate</button> | |
</form> | |
<iframe src="data:text/plain,Loading..."></iframe> | |
<script id="jsbin-javascript"> | |
var stars = [ | |
[0, 1.39734], | |
[2.6521683, 0], | |
[2.5652089, 5.97229], | |
[5.6232309, 2.98584], | |
[2.1902414, 2.23642] | |
]; | |
// A4 measures 210 × 297 | |
const A4Width = 210 | |
const A4Height = 297 | |
const A4Margin = 5 | |
setTimeout(generatePDF, 10); | |
document.querySelector('select').oninput = generatePDF; | |
document.querySelector('select').onchange = generatePDF; | |
document.querySelector('form').onsubmit = function(){setTimeout(generatePDF, 10); return false;} | |
function generatePDF() | |
{ | |
/* global jsPDF */ | |
var doc = new jsPDF(); | |
const color = document.querySelector('select').value; | |
console.log(color) | |
/* | |
doc.setFillColor(255, 255, 255); | |
doc.setLineWidth(1); | |
doc.setDrawColor(0,255,0); | |
doc.circle(120, 20, 5, "S"); | |
*/ | |
var points = generatePoints(200, 10, A4Margin, A4Width-A4Margin-6, A4Margin, A4Height-A4Margin-6); | |
for( var i=0; i<points.length; i++ ) | |
{ | |
drawEurion(points[i][0], points[i][1], Math.random()*2*Math.PI, color); | |
} | |
/* | |
for( var i=0; i<points.length; i++ ) | |
{ | |
console.log(points[i][0], points[i][1]) | |
for( var j=i+1; j<points.length; j++ ) | |
{ | |
var distance = Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) | |
if( distance<10 ) | |
console.log('d', i, j, Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) ) | |
} | |
} | |
*/ | |
//doc.save("eurion.pdf") | |
//pdf_test_harness_init(pdf, "Open in Reader (or Firefox) to see the PDF outline"); | |
//doc.output('datauri') //datauri | |
document.querySelector('iframe').src=doc.output('datauristring'); | |
function drawEurion(offsetX, offsetY, angle, color) | |
{ | |
doc.setDrawColor(color); | |
doc.setLineWidth(0.24834293); | |
const centreX = 2.6; | |
const centreY = 3; | |
for( var i=0; i<stars.length; i++ ) | |
{ | |
var x = offsetX + centreX + Math.cos(angle)*(stars[i][0]-centreX) + Math.sin(angle)*(stars[i][1]-centreY) | |
var y = offsetY + centreY - Math.sin(angle)*(stars[i][0]-centreX) + Math.cos(angle)*(stars[i][1]-centreY) | |
doc.circle(x, y, 0.36089846, "S"); | |
} | |
//doc.setDrawColor(0,255,0); | |
//doc.circle(offsetX+centreX, offsetY+centreY, 4.4, "S"); | |
} | |
function generatePoints(number, distance, minX, maxX, minY, maxY, ) | |
{ | |
var points = []; | |
var tries = 0; | |
while( points.length<number && tries<40 ) | |
{ | |
tries = 0; | |
var validPoint = false; | |
while( tries<40 && validPoint==false ) | |
{ | |
tries++; | |
var x = minX + Math.random()*(maxX-minX) | |
var y = minY + Math.random()*(maxY-minY) | |
validPoint = true | |
for( var i=0; i<points.length; i++ ) | |
{ | |
if( Math.sqrt(Math.pow(points[i][0]-x,2)+Math.pow(points[i][1]-y,2))<distance ) | |
//if( Math.abs(points[i][0]-x)<distance/2 || Math.abs(points[i][1]-y)<distance/2 ) | |
{ | |
validPoint = false; | |
break; | |
} | |
} | |
if( validPoint ) | |
points.push([x,y]) | |
} | |
} | |
return points | |
} | |
} | |
</script> | |
<script id="jsbin-source-css" type="text/css">html, body { | |
box-sizing: border-box; | |
margin: 0; | |
padding: .2em .2em 1em; | |
height: 100%; | |
background: #ccffcc; | |
} | |
form { | |
margin: 0 0 .2em; | |
} | |
iframe { | |
box-sizing: border-box; | |
width: 100%; | |
height: 100%; | |
border: 0; | |
}</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var stars = [ | |
[0, 1.39734], | |
[2.6521683, 0], | |
[2.5652089, 5.97229], | |
[5.6232309, 2.98584], | |
[2.1902414, 2.23642] | |
]; | |
// A4 measures 210 × 297 | |
const A4Width = 210 | |
const A4Height = 297 | |
const A4Margin = 5 | |
setTimeout(generatePDF, 10); | |
document.querySelector('select').oninput = generatePDF; | |
document.querySelector('select').onchange = generatePDF; | |
document.querySelector('form').onsubmit = function(){setTimeout(generatePDF, 10); return false;} | |
function generatePDF() | |
{ | |
/* global jsPDF */ | |
var doc = new jsPDF(); | |
const color = document.querySelector('select').value; | |
console.log(color) | |
/* | |
doc.setFillColor(255, 255, 255); | |
doc.setLineWidth(1); | |
doc.setDrawColor(0,255,0); | |
doc.circle(120, 20, 5, "S"); | |
*/ | |
var points = generatePoints(200, 10, A4Margin, A4Width-A4Margin-6, A4Margin, A4Height-A4Margin-6); | |
for( var i=0; i<points.length; i++ ) | |
{ | |
drawEurion(points[i][0], points[i][1], Math.random()*2*Math.PI, color); | |
} | |
/* | |
for( var i=0; i<points.length; i++ ) | |
{ | |
console.log(points[i][0], points[i][1]) | |
for( var j=i+1; j<points.length; j++ ) | |
{ | |
var distance = Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) | |
if( distance<10 ) | |
console.log('d', i, j, Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) ) | |
} | |
} | |
*/ | |
//doc.save("eurion.pdf") | |
//pdf_test_harness_init(pdf, "Open in Reader (or Firefox) to see the PDF outline"); | |
//doc.output('datauri') //datauri | |
document.querySelector('iframe').src=doc.output('datauristring'); | |
function drawEurion(offsetX, offsetY, angle, color) | |
{ | |
doc.setDrawColor(color); | |
doc.setLineWidth(0.24834293); | |
const centreX = 2.6; | |
const centreY = 3; | |
for( var i=0; i<stars.length; i++ ) | |
{ | |
var x = offsetX + centreX + Math.cos(angle)*(stars[i][0]-centreX) + Math.sin(angle)*(stars[i][1]-centreY) | |
var y = offsetY + centreY - Math.sin(angle)*(stars[i][0]-centreX) + Math.cos(angle)*(stars[i][1]-centreY) | |
doc.circle(x, y, 0.36089846, "S"); | |
} | |
//doc.setDrawColor(0,255,0); | |
//doc.circle(offsetX+centreX, offsetY+centreY, 4.4, "S"); | |
} | |
function generatePoints(number, distance, minX, maxX, minY, maxY, ) | |
{ | |
var points = []; | |
var tries = 0; | |
while( points.length<number && tries<40 ) | |
{ | |
tries = 0; | |
var validPoint = false; | |
while( tries<40 && validPoint==false ) | |
{ | |
tries++; | |
var x = minX + Math.random()*(maxX-minX) | |
var y = minY + Math.random()*(maxY-minY) | |
validPoint = true | |
for( var i=0; i<points.length; i++ ) | |
{ | |
if( Math.sqrt(Math.pow(points[i][0]-x,2)+Math.pow(points[i][1]-y,2))<distance ) | |
//if( Math.abs(points[i][0]-x)<distance/2 || Math.abs(points[i][1]-y)<distance/2 ) | |
{ | |
validPoint = false; | |
break; | |
} | |
} | |
if( validPoint ) | |
points.push([x,y]) | |
} | |
} | |
return points | |
} | |
}</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
box-sizing: border-box; | |
margin: 0; | |
padding: .2em .2em 1em; | |
height: 100%; | |
background: #ccffcc; | |
} | |
form { | |
margin: 0 0 .2em; | |
} | |
iframe { | |
box-sizing: border-box; | |
width: 100%; | |
height: 100%; | |
border: 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stars = [ | |
[0, 1.39734], | |
[2.6521683, 0], | |
[2.5652089, 5.97229], | |
[5.6232309, 2.98584], | |
[2.1902414, 2.23642] | |
]; | |
// A4 measures 210 × 297 | |
const A4Width = 210 | |
const A4Height = 297 | |
const A4Margin = 5 | |
setTimeout(generatePDF, 10); | |
document.querySelector('select').oninput = generatePDF; | |
document.querySelector('select').onchange = generatePDF; | |
document.querySelector('form').onsubmit = function(){setTimeout(generatePDF, 10); return false;} | |
function generatePDF() | |
{ | |
/* global jsPDF */ | |
var doc = new jsPDF(); | |
const color = document.querySelector('select').value; | |
console.log(color) | |
/* | |
doc.setFillColor(255, 255, 255); | |
doc.setLineWidth(1); | |
doc.setDrawColor(0,255,0); | |
doc.circle(120, 20, 5, "S"); | |
*/ | |
var points = generatePoints(200, 10, A4Margin, A4Width-A4Margin-6, A4Margin, A4Height-A4Margin-6); | |
for( var i=0; i<points.length; i++ ) | |
{ | |
drawEurion(points[i][0], points[i][1], Math.random()*2*Math.PI, color); | |
} | |
/* | |
for( var i=0; i<points.length; i++ ) | |
{ | |
console.log(points[i][0], points[i][1]) | |
for( var j=i+1; j<points.length; j++ ) | |
{ | |
var distance = Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) | |
if( distance<10 ) | |
console.log('d', i, j, Math.sqrt(Math.pow(points[i][0]-points[j][0],2)+Math.pow(points[i][1]-points[j][1],2)) ) | |
} | |
} | |
*/ | |
//doc.save("eurion.pdf") | |
//pdf_test_harness_init(pdf, "Open in Reader (or Firefox) to see the PDF outline"); | |
//doc.output('datauri') //datauri | |
document.querySelector('iframe').src=doc.output('datauristring'); | |
function drawEurion(offsetX, offsetY, angle, color) | |
{ | |
doc.setDrawColor(color); | |
doc.setLineWidth(0.24834293); | |
const centreX = 2.6; | |
const centreY = 3; | |
for( var i=0; i<stars.length; i++ ) | |
{ | |
var x = offsetX + centreX + Math.cos(angle)*(stars[i][0]-centreX) + Math.sin(angle)*(stars[i][1]-centreY) | |
var y = offsetY + centreY - Math.sin(angle)*(stars[i][0]-centreX) + Math.cos(angle)*(stars[i][1]-centreY) | |
doc.circle(x, y, 0.36089846, "S"); | |
} | |
//doc.setDrawColor(0,255,0); | |
//doc.circle(offsetX+centreX, offsetY+centreY, 4.4, "S"); | |
} | |
function generatePoints(number, distance, minX, maxX, minY, maxY, ) | |
{ | |
var points = []; | |
var tries = 0; | |
while( points.length<number && tries<40 ) | |
{ | |
tries = 0; | |
var validPoint = false; | |
while( tries<40 && validPoint==false ) | |
{ | |
tries++; | |
var x = minX + Math.random()*(maxX-minX) | |
var y = minY + Math.random()*(maxY-minY) | |
validPoint = true | |
for( var i=0; i<points.length; i++ ) | |
{ | |
if( Math.sqrt(Math.pow(points[i][0]-x,2)+Math.pow(points[i][1]-y,2))<distance ) | |
//if( Math.abs(points[i][0]-x)<distance/2 || Math.abs(points[i][1]-y)<distance/2 ) | |
{ | |
validPoint = false; | |
break; | |
} | |
} | |
if( validPoint ) | |
points.push([x,y]) | |
} | |
} | |
return points | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment