0
I have a system where I need to print a PDF by clicking the button.
The url is built according to the shipment ID, so dynamically, I use an iframe that will load the data and, when loaded, I call a function to print what is in the iframe.
I’m doing like this:
$scope.imprimir = function imprimir (protocolo_id) {
    if (imprimir.carregando) return;
    var url_protocolo = '/protocolos/imprimir/' + protocolo_id;
    imprimir.carregando = true;
    angular.element('#imprimir_protocolo').attr('src', url_protocolo).on('load', function () {
        var frame = $window.frames['imprimir_protocolo'];
        frame.focus();
        frame.print();
        delete imprimir.carregando;
        $scope.$apply();
    })
}
On the line where I make the call from frame.focus(), when I use Firefox, the following error appears:
Permission denied to access Property "print"
Aff, this problem of behaving different in each browser! To almost thinking of leaving a link opening the PDF :p
– Wallace Maxters
@Wallacemaxters find a good way, especially for mobiles :)
– Guilherme Nascimento