Skip to content

Instantly share code, notes, and snippets.

@adamdyson
Created July 29, 2015 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamdyson/852291b64a98fd287554 to your computer and use it in GitHub Desktop.
Save adamdyson/852291b64a98fd287554 to your computer and use it in GitHub Desktop.
prince http://127.0.0.1/phantomjs/index.php --javascript -o generated.pdf
RESULT:
prince: https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.9.23/paper-core.js:181: error: TypeError: object is not a function
prince: http://127.0.0.1/phantomjs/index.php:8: error: TypeError: undefined value is not an object
<html>
<head>
<meta charset="utf-8">
<title>Modify SVG</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/paper.js/0.9.23/paper-core.js"></script>
<style type="text/css">
html
{
width: 100%;
height: 100%;
}
body
{
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
}
</style>
</head>
<body>
<div id="container">
</div>
</body>
<script>
(function($)
{
// Create a canvas element
var canvas = document.createElement('canvas');
// Create a paper scope object
var scope = new paper.PaperScope();
// Set up an empty project and default layer
scope.setup(canvas);
// Set the view size
scope.view.viewSize = new scope.Size(377.952755906, 793.700787402); // 100mm x 210mm
// Retrieve the default layer
var surface = scope.project.activeLayer;
// Rename the default layer
surface.name = 'surface';
var size = scope.view.viewSize;
var position = new scope.Point(0, 0);
var rectangle = new scope.Rectangle(position, size);
var path = new scope.Path.Rectangle(rectangle);
path.fillColor = '#FF00FF';
$('#container').append(scope.project.exportSVG());
}
)(jQuery);
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment