Replace landscape option through orientation
This commit is contained in:
parent
b6683840ca
commit
fa00761d3c
@ -95,7 +95,7 @@ The list of possible options depend on the platform, the content type and the ca
|
|||||||
| copies | The number of copies for the print task. | Number | iOS<br>Windows |
|
| copies | The number of copies for the print task. | Number | iOS<br>Windows |
|
||||||
| pageCount | Limits the pages to print even the document contains more.<br>To skip the last n pages you can assign a negative value on iOS. | Number | iOS<br>Android |
|
| pageCount | Limits the pages to print even the document contains more.<br>To skip the last n pages you can assign a negative value on iOS. | Number | iOS<br>Android |
|
||||||
| duplex | Either double-sided on short site (duplex:'short'), double-sided on long site (duplex:'long') or single-sided (duplex:'none'). | String | all |
|
| duplex | Either double-sided on short site (duplex:'short'), double-sided on long site (duplex:'long') or single-sided (duplex:'none'). | String | all |
|
||||||
| landscape| The orientation of the printed content, portrait or landscape. | Boolean | all |
|
| orientation | The orientation of the printed content, `portrait` or `landscape`. | String | all |
|
||||||
| monochrome | If your application only prints black text, setting this property to _true_ can result in better performance in many cases. | Boolean | all |
|
| monochrome | If your application only prints black text, setting this property to _true_ can result in better performance in many cases. | Boolean | all |
|
||||||
| photo | Set to _true_ to change the media type to photography for higher quality. | Boolean | iOS<br>Windows |
|
| photo | Set to _true_ to change the media type to photography for higher quality. | Boolean | iOS<br>Windows |
|
||||||
| autoFit | Set to _false_ to disable downscaling the image to fit into the content aread. | Boolean | Android |
|
| autoFit | Set to _false_ to disable downscaling the image to fit into the content aread. | Boolean | Android |
|
||||||
|
@ -33,10 +33,14 @@
|
|||||||
NSString* jobName = spec[@"name"];
|
NSString* jobName = spec[@"name"];
|
||||||
long copies = MAX([spec[@"copies"] longValue], 1);
|
long copies = MAX([spec[@"copies"] longValue], 1);
|
||||||
|
|
||||||
if ([spec[@"landscape"] boolValue])
|
if ([spec[@"orientation"] isEqualToString:@"landscape"])
|
||||||
{
|
{
|
||||||
info.orientation = UIPrintInfoOrientationLandscape;
|
info.orientation = UIPrintInfoOrientationLandscape;
|
||||||
}
|
}
|
||||||
|
else if ([spec[@"orientation"] isEqualToString:@"portrait"])
|
||||||
|
{
|
||||||
|
info.orientation = UIPrintInfoOrientationPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
if ([spec[@"monochrome"] boolValue])
|
if ([spec[@"monochrome"] boolValue])
|
||||||
{
|
{
|
||||||
|
@ -33,18 +33,23 @@ var Printing = Windows.Graphics.Printing,
|
|||||||
*
|
*
|
||||||
* @return [ Void ]
|
* @return [ Void ]
|
||||||
*/
|
*/
|
||||||
exports.check = function (success, fail, args) {
|
exports.check = function (success, fail, args)
|
||||||
|
{
|
||||||
var item = args[0],
|
var item = args[0],
|
||||||
supported = PrintManager.isSupported();
|
supported = PrintManager.isSupported();
|
||||||
|
|
||||||
if (!item || !supported) {
|
if (!item || !supported)
|
||||||
|
{
|
||||||
success(supported);
|
success(supported);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item[0] === '<') {
|
if (item[0] === '<')
|
||||||
|
{
|
||||||
supported = true;
|
supported = true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
supported = item.match(/[a-z0-9]:\/\//) === null;
|
supported = item.match(/[a-z0-9]:\/\//) === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +65,8 @@ exports.check = function (success, fail, args) {
|
|||||||
*
|
*
|
||||||
* @return [ Void ]
|
* @return [ Void ]
|
||||||
*/
|
*/
|
||||||
exports.types = function (success, fail, args) {
|
exports.types = function (success, fail, args)
|
||||||
|
{
|
||||||
success([]);
|
success([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,11 +79,13 @@ exports.types = function (success, fail, args) {
|
|||||||
*
|
*
|
||||||
* @return [ Void ]
|
* @return [ Void ]
|
||||||
*/
|
*/
|
||||||
exports.print = function (success, fail, args) {
|
exports.print = function (success, fail, args)
|
||||||
|
{
|
||||||
var content = args[0],
|
var content = args[0],
|
||||||
page = document, body;
|
page = document, body;
|
||||||
|
|
||||||
if (content && content.length > 0) {
|
if (content && content.length > 0)
|
||||||
|
{
|
||||||
page = document.createDocumentFragment();
|
page = document.createDocumentFragment();
|
||||||
body = document.createElement('html');
|
body = document.createElement('html');
|
||||||
|
|
||||||
@ -102,7 +110,8 @@ exports.print = function (success, fail, args) {
|
|||||||
*
|
*
|
||||||
* @return [ Void ]
|
* @return [ Void ]
|
||||||
*/
|
*/
|
||||||
exports.onPrintTaskRequested = function (event) {
|
exports.onPrintTaskRequested = function (event)
|
||||||
|
{
|
||||||
var config = exports._args,
|
var config = exports._args,
|
||||||
task, spec;
|
task, spec;
|
||||||
|
|
||||||
@ -112,37 +121,46 @@ exports.onPrintTaskRequested = function (event) {
|
|||||||
|
|
||||||
spec = task.options;
|
spec = task.options;
|
||||||
|
|
||||||
if (config.monochrome) {
|
if (config.monochrome)
|
||||||
|
{
|
||||||
spec.colorMode = Printing.PrintColorMode.grayscale;
|
spec.colorMode = Printing.PrintColorMode.grayscale;
|
||||||
} else {
|
|
||||||
spec.colorMode = Printing.PrintColorMode.color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.landscape) {
|
if (config.orientation == 'landscape')
|
||||||
|
{
|
||||||
spec.orientation = Printing.PrintOrientation.landscape;
|
spec.orientation = Printing.PrintOrientation.landscape;
|
||||||
} else {
|
}
|
||||||
|
else if (config.orientation == 'portrait')
|
||||||
|
{
|
||||||
spec.orientation = Printing.PrintOrientation.portrait;
|
spec.orientation = Printing.PrintOrientation.portrait;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.duplex == 'long') {
|
if (config.duplex == 'long')
|
||||||
|
{
|
||||||
spec.duplex = Printing.PrintDuplex.twoSidedLongEdge;
|
spec.duplex = Printing.PrintDuplex.twoSidedLongEdge;
|
||||||
} else
|
}
|
||||||
if (config.duplex == 'short') {
|
else if (config.duplex == 'short')
|
||||||
|
{
|
||||||
spec.duplex = Printing.PrintDuplex.twoSidedShortEdge;
|
spec.duplex = Printing.PrintDuplex.twoSidedShortEdge;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
spec.duplex = Printing.PrintDuplex.oneSided;
|
spec.duplex = Printing.PrintDuplex.oneSided;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.photo) {
|
if (config.photo)
|
||||||
|
{
|
||||||
spec.printQuality = Printing.PrintQuality.photographic;
|
spec.printQuality = Printing.PrintQuality.photographic;
|
||||||
spec.mediaType = Printing.PrintMediaType.photographic;
|
spec.mediaType = Printing.PrintMediaType.photographic;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.margin === false) {
|
if (config.margin === false)
|
||||||
|
{
|
||||||
spec.bordering = Printing.PrintBordering.borderless;
|
spec.bordering = Printing.PrintBordering.borderless;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.paper && config.paper.name) {
|
if (config.paper && config.paper.name)
|
||||||
|
{
|
||||||
spec.mediaSize = Printing.PrintMediaSize[config.paper.name] || Printing.PrintMediaSize.default;
|
spec.mediaSize = Printing.PrintMediaSize[config.paper.name] || Printing.PrintMediaSize.default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ var exec = require('cordova/exec'),
|
|||||||
exports._defaults = {
|
exports._defaults = {
|
||||||
// name: 'unknown',
|
// name: 'unknown',
|
||||||
|
|
||||||
// duplex: 'none',
|
// duplex: 'none',
|
||||||
// landscape: false,
|
// orientation: 'landscape',
|
||||||
// monochrome: false,
|
// monochrome: false,
|
||||||
// photo: false,
|
// photo: false,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user