Highly concurrent, extensively configurable, necessarily stable export server 👻
- PDFtk 1 >= 2.x - only required for merging bulk pdf request into a single pdf
1: this dependency must be either (1) available directly in your path OR (2) the absolute path to the executable provided in the config
git clone https://github.com/brandon93s/spectre.git
cd spectre
npm install
// start spectre
npm start
// run tests
npm test
// screenshot of github.com
GET /?url=github.com
// custom viewport size
GET /?url=github.com&width=700&height=450
// non-default file type
GET /?url=github.com&format=pdf
// delay rendering 3 seconds
POST /
{
"url":"github.com",
"mode":"delay",
"delay":3000
}
// bulk request
POST /
{
"format":"pdf",
"width":1920,
"height":750,
"paperSize":{
"format":"Letter",
"orientation":"landscape",
"margin":"1cm"
},
"items":[
{
"url":"github.com"
},
{
"url":"atom.io",
"mode":"delay",
"delay":350
},
{
"url":"travis-ci.org",
"width":1000
}
]
}
// todo
Required
Type: string
The url to request.
Type: string
Default: 'png'
The file format of the export.
Possible Values: 'png'
'jpg'
'gif'
'pdf'
Type: int
Default: 1366
The width of the viewport at the time of rendering.
Type: int
Default: 768
The height of the viewport at the time of rendering.
Type: object
Defines the size of the web page when rendered as a PDF. If no paperSize is defined the size is defined by the web page.
Supported dimension units are: mm
cm
in
px
. No unit means px
.
Supported formats are: 'A3'
'A4'
'A5'
'Legal'
'Letter'
'Tabloid'
.
Supported orientations are: 'landscape'
'portrait'
. Default is 'portrait'
.
paperSize accepts objects in the following two formats:
// width, height, margin
{
width: '400px',
height: '900px',
margin: '1cm'
}
// format, orientation, margin
{
format: 'Letter',
orientation: 'landscape',
margin: '30px'
}
Type: int
Default: 100
The quality of the rendered output. Option not available for format === 'png'
.
Possible Values: 1
- 100
Type: string
Default: 'auto'
The triggering mode that controls when to begin rendering.
Possible Values:
'auto'
- render immediately when the dom is ready'delay'
- render after a user-defined amount of time'trigger'
- trigger rendering from the page itself (w.i.p.)
Type: int
When mode === 'delay'
this value represents the amount of time to delay rendering in ms.
Type: string
Default: PhantomJS default userAgent
The user agent string to send with the request.
Type: bool
Default: true
Whether or not to load JavaScript in the target page.
Type: bool
Default: true
Whether or not to load inlined images in the target page.
Type: object
string
The data to send with the web page request.
Note: When data is present, the web page request is currently always a POST request.
Type: string
Default: 'urlencoded'
Defines the type of data to send with the web page request.
Possible Values: 'urlencoded'
'json'
Note: Data is currently not converted to the correct type. This sets the correct headers for the request. Because of this 'urlencoded'
expects a pre-formatted string and 'json'
an object.
Type: array
An array of cookie objects with the following properties:
Required
Type: string
Required
Type: string
, number
, object
Required
Type: string
Type: string
Type: bool
Type: bool
Type: string
Type: string
The user name used for HTTP Authentication
Type: string
The password used for HTTP Authentication
// todo
##### headers - custom KVP headers
##### timeout - web page request timeout
##### requestMethod - allow user to choose GET, POST, PUT, etc.
MIT © Brandon Smith