harbour-seaprint/qml/pages/utils.js

51 lines
1 KiB
JavaScript
Raw Normal View History

2019-12-01 22:27:00 +03:00
function supported_formats(printer)
{
return _formats(printer).supported;
}
function format_filters(printer)
{
return _formats(printer).filters;
}
function _formats(printer)
{
var formats = printer.attrs["document-format-supported"].value;
var supported = [];
var filters = [];
if(has(formats, "application/pdf"))
{
supported.push("PDF");
filters.push("*.pdf");
}
if(has(formats, "image/jpeg"))
{
supported.push("JPEG");
filters.push("*.jpg");
filters.push("*.jpeg");
}
2019-12-08 15:55:56 +03:00
if(supported.length == 0)
{
supported.push("No relevant formats supported")
}
2019-12-01 22:27:00 +03:00
return {supported: supported.join(" "), filters: filters};
}
function has(arrayish, what)
{
for(var i in arrayish)
{
if(arrayish[i] == what)
return true
}
return false
}
function can_print(printer, fileName)
{
// Move to ippprinter?
return format_filters(printer).indexOf("*."+fileName.split('.').pop()) != -1;
}