Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/change orientation #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ domToPdf(element, options, function(pdf) {
* `proxyUrl` - string, e.g. `/api/proxyImage?url=`, a route in your app which renders images on your domain in order to avoid problems with CORS with the images on a DOM
* `compression` - string, compression of the generated image, can have the values 'NONE', 'FAST', 'MEDIUM' and 'SLOW'. (default is 'NONE')
* `scale` - number, increases an image's size before exporting to improve the image quality
* `pdfOptions` - Changing pdf settings orientation, unit , format (default orientation - 'p', unit - 'pt', format - 'a4')


## Support
Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ _isCanvasBlank = canvas => {
};

downloadPdf = (dom, options, cb) => {
const a4Height = 841.89;
const a4Width = 595.28;
let a4Height = 841.89;
let a4Width = 595.28;
let overrideWidth;
let container;
let containerCSS;
Expand All @@ -93,14 +93,19 @@ downloadPdf = (dom, options, cb) => {
let scaleObj;
let style;
const transformOrigin = 'top left';
const pdfOptions = {
let pdfOptions = {
orientation: 'p',
unit: 'pt',
format: 'a4'
};

({filename, excludeClassNames = [], excludeTagNames = ['button', 'input', 'select'], overrideWidth, proxyUrl, compression, scale} = options);
({filename, excludeClassNames = [], excludeTagNames = ['button', 'input', 'select'], overrideWidth, proxyUrl, compression, scale,pdfOptions} = options);

if (options.pdfOptions.orientation === 'l') {
a4Height = 595.28;
a4Width = 841.89;
}

overlayCSS = {
position: 'fixed',
zIndex: 1000,
Expand Down