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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
@ -33,10 +33,14 @@
|
||||
NSString* jobName = spec[@"name"];
|
||||
long copies = MAX([spec[@"copies"] longValue], 1);
|
||||
|
||||
if ([spec[@"landscape"] boolValue])
|
||||
if ([spec[@"orientation"] isEqualToString:@"landscape"])
|
||||
{
|
||||
info.orientation = UIPrintInfoOrientationLandscape;
|
||||
}
|
||||
else if ([spec[@"orientation"] isEqualToString:@"portrait"])
|
||||
{
|
||||
info.orientation = UIPrintInfoOrientationPortrait;
|
||||
}
|
||||
|
||||
if ([spec[@"monochrome"] boolValue])
|
||||
{
|
||||
|
@ -33,18 +33,23 @@ var Printing = Windows.Graphics.Printing,
|
||||
*
|
||||
* @return [ Void ]
|
||||
*/
|
||||
exports.check = function (success, fail, args) {
|
||||
exports.check = function (success, fail, args)
|
||||
{
|
||||
var item = args[0],
|
||||
supported = PrintManager.isSupported();
|
||||
|
||||
if (!item || !supported) {
|
||||
if (!item || !supported)
|
||||
{
|
||||
success(supported);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item[0] === '<') {
|
||||
if (item[0] === '<')
|
||||
{
|
||||
supported = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
supported = item.match(/[a-z0-9]:\/\//) === null;
|
||||
}
|
||||
|
||||
@ -60,7 +65,8 @@ exports.check = function (success, fail, args) {
|
||||
*
|
||||
* @return [ Void ]
|
||||
*/
|
||||
exports.types = function (success, fail, args) {
|
||||
exports.types = function (success, fail, args)
|
||||
{
|
||||
success([]);
|
||||
};
|
||||
|
||||
@ -73,11 +79,13 @@ exports.types = function (success, fail, args) {
|
||||
*
|
||||
* @return [ Void ]
|
||||
*/
|
||||
exports.print = function (success, fail, args) {
|
||||
exports.print = function (success, fail, args)
|
||||
{
|
||||
var content = args[0],
|
||||
page = document, body;
|
||||
|
||||
if (content && content.length > 0) {
|
||||
if (content && content.length > 0)
|
||||
{
|
||||
page = document.createDocumentFragment();
|
||||
body = document.createElement('html');
|
||||
|
||||
@ -102,7 +110,8 @@ exports.print = function (success, fail, args) {
|
||||
*
|
||||
* @return [ Void ]
|
||||
*/
|
||||
exports.onPrintTaskRequested = function (event) {
|
||||
exports.onPrintTaskRequested = function (event)
|
||||
{
|
||||
var config = exports._args,
|
||||
task, spec;
|
||||
|
||||
@ -112,37 +121,46 @@ exports.onPrintTaskRequested = function (event) {
|
||||
|
||||
spec = task.options;
|
||||
|
||||
if (config.monochrome) {
|
||||
if (config.monochrome)
|
||||
{
|
||||
spec.colorMode = Printing.PrintColorMode.grayscale;
|
||||
} else {
|
||||
spec.colorMode = Printing.PrintColorMode.color;
|
||||
}
|
||||
|
||||
if (config.landscape) {
|
||||
if (config.orientation == 'landscape')
|
||||
{
|
||||
spec.orientation = Printing.PrintOrientation.landscape;
|
||||
} else {
|
||||
}
|
||||
else if (config.orientation == 'portrait')
|
||||
{
|
||||
spec.orientation = Printing.PrintOrientation.portrait;
|
||||
}
|
||||
|
||||
if (config.duplex == 'long') {
|
||||
if (config.duplex == 'long')
|
||||
{
|
||||
spec.duplex = Printing.PrintDuplex.twoSidedLongEdge;
|
||||
} else
|
||||
if (config.duplex == 'short') {
|
||||
}
|
||||
else if (config.duplex == 'short')
|
||||
{
|
||||
spec.duplex = Printing.PrintDuplex.twoSidedShortEdge;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
spec.duplex = Printing.PrintDuplex.oneSided;
|
||||
}
|
||||
|
||||
if (config.photo) {
|
||||
if (config.photo)
|
||||
{
|
||||
spec.printQuality = Printing.PrintQuality.photographic;
|
||||
spec.mediaType = Printing.PrintMediaType.photographic;
|
||||
}
|
||||
|
||||
if (config.margin === false) {
|
||||
if (config.margin === false)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ var exec = require('cordova/exec'),
|
||||
exports._defaults = {
|
||||
// name: 'unknown',
|
||||
|
||||
// duplex: 'none',
|
||||
// landscape: false,
|
||||
// duplex: 'none',
|
||||
// orientation: 'landscape',
|
||||
// monochrome: false,
|
||||
// photo: false,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user