Giter Club home page Giter Club logo

cordova-plugin-printer's People

Contributors

erikwallin avatar filipe-nunes avatar janpio avatar katzer avatar kentongray avatar leibale avatar maubic avatar mzealey avatar nehresma avatar nkoded avatar pknittel avatar simastuzinas avatar ubahnverleih avatar vomatec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-printer's Issues

Borderless Printing / Fit size

All the prints came out with borders in the simulator (I don't mean the yellow borders).
Is it possible to include a way to choose borderless papers.
For example when you print on mac directly, you can choose DIN A4 (ohne Rand)/(Borderless).

Renaming Output PDF file

Hi there,

I am able to print PDF generated from the app using this plugin but When user click on the Print Button app automatically defaults the name of pdf to 'Webview.pdf".

Is there any way to rename the PDF file name ? Coz I am not able to print directly from within app.
I must save as a pdf then print from the manufacturer's app.

Version 0.7.0 for Phonegap Build

Any idea when this version 0.7.0 is released for phonegap build, it now says that this version is not compatible, and I realy need to print an external webpage (pdf) or generated html

Doesn't work on iPad with iOS8

The plugin worked nicely before. Now upgraded all of our build systems (cordova, plugins, Xcode version upgrade). Since the upgrade the plugin works only on iPone/iPod but not on iPad. The Xcode log says

WARNING: Calling -[UIPrintInteractionController presentAnimated:completionHandler:] on iPad

Which seems to be correct as making the call device type aware and calling presentFromRect for iPad it is working again. I have tested it with the code below.

if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    [controller presentFromRect:CGRectMake(10, 10, 0, 0) inView:self.webView animated:YES completionHandler:
     ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
         CDVPluginResult* pluginResult =
         [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

         [self.commandDelegate sendPluginResult:pluginResult
                                     callbackId:_callbackId];
     }];
}
else {
    [controller presentAnimated:YES completionHandler:
     ^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
         CDVPluginResult* pluginResult =
         [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

         [self.commandDelegate sendPluginResult:pluginResult
                                     callbackId:_callbackId];
     }];
}

I didn't for it and add this change because the fix positioning isn't really nice. So posted here hoping someone got better solution for this.

"0.5.3" version have some issue

when I use these code in "0.5.3" version by PGB

window.plugin.printer.isServiceAvailable(function(isAvailable, installedAppIds)
 {
  if(isAvailable == true)
  {
  alert("true")
  }
  if(isAvailable == false)
  {
  alert("false")
  }
 });

in Android that it will alert "false"
but in iOS that it will trigger nothing (nothing happened,just nothing)

Border in CSS

I have a table with borders set in the columns (tr) but the borders are not printed in my document. In the application, the borders are displayed.

Also, the background is not properly printed in the PDF.

In the image htmlGenerated, it is possible to see the correct version, that is shown in the browser and in the mobile application. In the pdfGenerated.png, you can see the printed document with problems.

Is there a way to print the borders in the PDF?

.trHeader {
vertical-align: middle;
text-align: center;
border-style: solid;
border-width: 1px;
background: #DDD9C4;
}

                <td class="tdHeader">
                <span> EXAMPLE </span>
                </td>
                <td style="width: 25%">
                <img src="img/example2.png">
                </td>
            </tr>

pdfgenerated
htmlgenerated

Correct way to style a document

What is the correct way to apply CSS to a piece of content? At the moment I have to do inline and that's obviously undesirable :) Thanks!

No Print preview in Android for Remote PDF files

Hello,
I have tried using this plugin example and changed the file name to a remote PDF file but there is no print preview and even if i try printing an empty sheet is coming out of my printer ,but instead if I try using an remote XML file its shown in the print preview.
Is there anyway to print remote PDF files using this plugin??

Method isAvailable seem not work

Hello everybody , I am new to phone gap development and plugin.
I have follow the instruction of cordova-plugin-printer ,
After install plugin by CLI and add <gap:plugin name="de.appplant.cordova.plugin.printer" />
to my file config xml. after that
I have add method

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() { 
            alert("ready");
            cordova.plugins.printer.isAvailable(function (available) {
                  alert(available); 
            });
        }

to my index page.
I noted that document.addEventListener is work normally.
but
cordova.plugins.printer.isAvailable method seem not work.
I think I have follow all step of instruction

But still can not print page or just alert message

So anybody can tell me what I am doing wrong?

and So for my bad English.

Cordova print plugin does not print google web fonts

Google web fonts used in the app display correctly inside the cordova app. However when the app page (or a div on the page) is printed using this cordova print plugin , the web fonts do not display and revert to the browser default font. Is there a solution or workaround to this problem? Thanks in advance.

how can i add css

Hello

I am using this plugin jquerymobile+phonegap. I have all html in a single page. when i use it always print the tree structure of html. can anybody please tell me how can i add css for that.

Thanks
Avneet

isServiceAvailable returns False IOS

Hi ,
i'm trying to use your plugin on IOS and the isServiceAvailable always returns false my test environment is below:

IOS 7
IPhone 4
Cordova 3.4.0-0.1.3

also has the same behaviour in the iOS simulator under IOS7 maybe i'm doing something stupid?

Cheers
Brett

Printing apps are not able to receive data

I have been working on implementing printing in my app on android. Though this plugin helps me in launching third party apps. But they are not able to receive any content to print.

for ex. HP ePrint app gives "SDCard not accessible arror"
Star Print - gives no content etc

Is there any other plugin or permission that I need to give.

I have already given WRITE_EXTERNAL_STORAGE.

Thanks in advance

Not able to install in my app

Hi there,

I tried your example and it is working great. But when I tried to install this plugin in my app it fails to install the plugin.

-Suraj

App crash when trying to print

We're trying to use the 0.6.x branch to print some html, it works on emulator (4.4.2 API 19 Google APIs), but crashes the app on LG Flex (4.4.2) and N7 (4.4.4), the log is:

10-16 10:14:23.818: E/AndroidRuntime(6756): FATAL EXCEPTION: pool-1-thread-1
10-16 10:14:23.818: E/AndroidRuntime(6756): Process: <our app id>, PID: 6756
10-16 10:14:23.818: E/AndroidRuntime(6756): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/html flg=0x1 pkg=com.google.android.apps.cloudprint (has clip) (has extras) }
10-16 10:14:23.818: E/AndroidRuntime(6756):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1632)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at android.app.Activity.startActivityForResult(Activity.java:3424)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at android.app.Activity.startActivityForResult(Activity.java:3385)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:859)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at de.appplant.cordova.plugin.printer.Printer.printViaGoogleCloudPrintApp(Printer.java:198)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at de.appplant.cordova.plugin.printer.Printer.access$300(Printer.java:46)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at de.appplant.cordova.plugin.printer.Printer$2$1.onContentReady(Printer.java:133)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at de.appplant.cordova.plugin.printer.Printer$ContentClient$1.run(Printer.java:337)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-16 10:14:23.818: E/AndroidRuntime(6756):     at java.lang.Thread.run(Thread.java:841)
10-16 10:14:23.818: W/ActivityManager(503):   Force finishing activity <our app id>
10-16 10:14:23.838: D/CordovaActivity(6756): Paused the application!
10-16 10:14:23.838: D/CordovaWebView(6756): Handle the pause

We tried this using the latest code in google-cloud-print branch and 0.6.1, both produces this crash, but 0.6.0 and 0.7.0 works.

Using plugin prevents openDatabase() on Android

Database access is prevented after using the plugin due to a weirdness in WebView. If newly instantiated WebView's don't enable database access then they block database access to other WebViews's. Adding

page.getSettings().setDatabaseEnabled(true);

after

page.getSettings().setJavaScriptEnabled(false);

resolves the problem for me.

Unable to use this plugin on phonegap android

01-28 07:43:57.617: E/Web Console(785): Uncaught TypeError: Cannot call method 'print' of undefined at file:///android_asset/www/index.html:30
01-28 07:51:14.347: E/Web Console(785): Uncaught TypeError: Cannot call method 'print' of undefined at file:///android_asset/www/index.html:30

Not printing on zebra.android.zebrautilities

Hello!
I'm trying to implement the plugin, did the following steps, but still don't print anything.

  1. download zebra utilities from google play store. works fine.
  2. from the demo app, I did connect the bluetooth printer and print a test page. works fine.
  3. from the CLI:
    cordova plugin add https://github.com/katzer/cordova-plugin-printer.git. works fine.
  4. after deviceready event fires the window.plugin.printer.isServiceAvailable and returns me: com.zebra.android.zebrautilites. works fine.

function setupprinter()
{
try
{
gPrinterIsAvailable = 0;
window.plugin.printer.isServiceAvailable(
function (isAvailable, installedAppIds)
{
//alert('The following print apps are installed on your device: ' + installedAppIds.join(', '));
gPrintingServer = installedAppIds[0];
gPrinterIsAvailable = 1;
}
);
} catch (e) { notify(e.message); }
}

  1. when a button is touched, execute the following function:

function printinvoice()
{
try
{
var strToPrint = "";
strToPrint = " "
strToPrint = strToPrint + " <style>@media print "
strToPrint = strToPrint + " {h1 {page-break-before:always;}} "
strToPrint = strToPrint + " </style>Hola mundo "
if (gPrinterIsAvailable == 1)
{
alert('going to print...');
window.plugin.printer.print(strToPrint);
} else { notify("ERROR, Printer is unavailable."); }

} catch (e) { notify(e.message); }

}

  1. nothing happen, didn't print and never goes to catch.

Will appreciate any light on this.

Android Uncaught TypeError

Android
Everything is installed according to the instructions. The message appears when testing
Uncaught TypeError: Can not read property 'printer'

The statement in the HTML is:
window.plugin.printer.isServiceAvailable (
function (isavailable, installedAppIds) {
alert ('The following print apps are installed on your device:' + installedAppIds.join (','));
}
);

This is the complete html:

<title>Device Properties Example</title>
<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="js/device.js"></script>
<script type="text/javascript" charset="utf-8" src="js/printer.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// device APIs are available
//
function onDeviceReady() {

    var element = document.getElementById('deviceProperties');
    element.innerHTML = 'Device Model: '    + device.model    + '<br />' +
                        'Device Platform: ' + device.platform + '<br />' +
                        'Device UUID: '     + device.uuid     + '<br />' +
                        'Device Version: '  + device.version  + '<br />';
    window.plugin.printer.isServiceAvailable(
            function (isAvailable, installedAppIds) {
                alert('The following print apps are installed on your device: ' + installedAppIds.join(', '));
            }
    );
}

function doPrint()
{
    alert('Platform:' + device.platform);
    /*window.plugin.printer.isServiceAvailable(
            function (isAvailable) {
        alert(isAvailable ? 'Service is available' : 'Service is NOT Available');
        }
    );*/


    window.plugin.Printer.isServiceAvailable(
            function (isAvailable, installedAppIds) {
                alert('The following print apps are installed on your device: ' + installedAppIds.join(', '));
            }
    );

    var page = document.body.innerHTML;
    window.plugin.printer.print(page);
    alert('functie werkt print');
}

function doAlert()
{
    var page = document.body.innerHTML;
    //window.plugin.printer.print(page);
    alert('functie werkt alert');
}

</script>

Loading device properties...

The Device-plugin works!

Print input fields?

How do I get this plugin to print the values in the input fields as well?

App crashes when trying to print

I have attached a screenshot from my logcat.
var page = '

Hello Document

';

cordova.plugins.printer.print(page, 'index.html', function () {
alert('printing finished or canceled')
});

I'm using this code to print. index.html is the page that I have in my application but I couldn't see any reason for this name to be required even though I'm just trying to print a string. Can you help?
Thanks
screenshot from 2015-02-02 03 44 19

Exception in takeScreenshot method

I am trying to print the page via HP ePrint. Illegal ArgumentException: 'width and height must be > 0' is thrown at takeScreenshot method. Am I doing anything wrong?

This is the code I have in the js file...

onDeviceReady: function() {
//app.receivedEvent('deviceready');
window.plugin.printer.print(document.documentElement, { appId: 'com.hp.android.print' });
},

iOS 8.2 update breaks plugin

Since updating my devices to 8.2, this plugin fails to bring up the Printer Options dialog.

Services are available when checking, but no Print Dialog and failure after ~8 seconds of waiting. Still works on 8.1 for me.

Anyone else experiencing this?

Script prints empty page after first print

When I pre-set the printer-ID I can print the content once, but when I want to print some other content in the same Script the page is empty.

I'm using iOS 8.3, a Brother QL-720NW (it's the same behavior with the printer simulator) and IPP for the connection

IOS - printing w/o dialog

Should it be possible to print w/o the airprint dialog (should be possible since IOS 8 from what I've read?) using the options (json object: { printerId: 'printername' } ?

I keep getting the dialog even though I specify the printerId.

Documentation recommends code which sometimes doesn't fire, causing confusing

documentation should be changed from this:

window.plugin.printer.isServiceAvailable(
function (isAvailable, installedAppIds) {
window.alert('The following print apps are installed on your device: ' + installedAppIds.join(', '));
}
);

to this:

window.plugin.printer.isServiceAvailable(
function (isAvailable, installedAppIds) {
window.alert(isAvailable ? 'Service is available' : 'Service NOT available');
if (installedAppIds) {
window.alert('Printers available' + installedAppIds.join(', '));
} else {
window.alert('No printers available');
}
}
);

Does not print image tag with base64 data as src

It seems that the print method is not capable of printing an image that has a src attribute as base 64 data. A normal window.print method from browser prints perfect this kind of content.

Here some sample code.

    var qr = document.getElementById("printable-card-qr").getElementsByTagName("canvas")[0];;
    var qrURL = qr.toDataURL();

    var doc = "<html><body>A little qr image";
    doc = doc + '<img src="'+qrURL+'"/>';
    doc = doc + "</body></html>";

    if(window.cordova){

      // WHILE THIS DO NOT PRINTS THE IMAGE
      $cordovaPrinter.print(doc);

    }else{

      var printWin = window.open("","processPrint");
      printWin.document.open();
      printWin.document.write(doc);
      printWin.document.close();

      // THIS PERFECTLY DOES
      printWin.print();

    }

Samsung Mobile Print - Invalid Intent

trying to print to Samsung Mobile Print on Android 4.2.2. The Samsung mobile print app launches then displays the error "invalid intent".
Any ideas?

At the end print a blank page in iOS 8

First at all, this is a really great plugin!
I know that iOS 8 its very new. But I just want make you know about this bug.

I'm using Phonegap Build to use this plugin. And I've tested in iOS 6, iOS 7 and iOS 8.0.2, and works great, but just in iOS 8 at the end print a blank page. It's not a big deal, but can be fixed.

App crashes whenever plugin is called in ios

I added the printer plugin to may corodova app. Now, whenever I print from my application on ios the app crashes. The crash log states that this is the problem:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xa0020010

From stack overflow, the way to debug such an issue is to run the app through xcode and turn on nszombie. However, when I run the app through xcode, even on an iPad, the app does not crash.

Has anyone else had this issue? Does anyone know a solution?

Thanks,
Eli

Wrong mime type

When you try to open a specific app, for example: window.plugin.printer.print('Hello world', { appId: 'com.dynamixsoftware.printhand.premium' });
It will automatically set "image/png" as the mime type.

It would be great if you could specify your own mime type in the javascript for phonegap build

[Kitkat] Print content issue.

Hi,
I want to use this plugin only to print a special div.
I'm doing as follow :

  1. var page = document.getElementById("my-div").innerHTML;
  2. window.plugin.printer.print(page);
  3. then : cordova.exec(null, null, 'Printer', 'print', [page, options]);
    At this point page still contain only "my-div" content.
  4. It opens HP ePrint plugin, I save my content as PDF.
  5. I open my PDF and it contain ALL my view, not just "my-div" content.

Is it the normal behavior of the plugin or an issue of the Kit Kat's one?

Specify printer in configuration on Android

This may be a limitation of Android Printing framework itself, I'd like for a user to be able to specify their default printer for X type of content and when they print X type of content it uses printer A, content Y can be set as default printer for printer B.

It appears this is possible w/ iOS using Printer ID function but I need NFC functionality too so iOS isn't an option for me.

So is there a way to accomplish what I want or does Android limit this functionality?

Plugin crash App build with Intel XDK

On my Nexus 4 with Android 4.4.4 my generated app crash until the print function was called. ServiceIsAvailable does not crash. App was created with Intel XDK.

Some Information
Q A
OS Android
OS Version 4.4.4
Device Nexus 4
Builder Intel XDK
Cordova Version 3.3
Enabled Cordova Plugins Device, Splashscreen
Enabled Intel XDK Plugins Base
Third Party Plugins Cordova Print Plugin
Third Party Plugins Include way by PluginId (de.appplant.cordova.plugin.printer) over Apache Cordova Plugins Registry
Extra Added Permissons none
Test Environments Tested with Crosswalk and without
Enabled Print Services Google Cloud Print, HP Print Plugin, Epson Print
Code
cordova.plugins.printer.isAvailable(
    function (isAvailable) {
        if (isAvailable) {
            $('.print-btn').show();
            $('.print-btn').click(function() {
                var page = document.body;
                // crash when call print
                cordova.plugins.printer.print(page, 'index.html', function () {
                });  
            });
         }
    }
);

any ideas how I can fix it to get it work with Intel XDK?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.