Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print function in ionic 3 #189

Closed
ikishanoza opened this issue Aug 13, 2018 · 11 comments
Closed

Print function in ionic 3 #189

ikishanoza opened this issue Aug 13, 2018 · 11 comments

Comments

@ikishanoza
Copy link

Hello,

I am using PDFMake for creating the pdf with my predefined Document definition. In my old ionic 1 project I am passing encoded string to print function which works fine. here is the code for old ionic 1

var dd = $scope.createDocumentDefinition();
            $timeout(function () {
                var pdf = pdfMake.createPdf(dd);
                pdf.getBase64(function (encodedString) {
                    console.log(encodedString);
                    $ionicLoading.hide();
                    window.plugins.PrintPDF.print({
                        data: encodedString,
                        type: 'Data',
                        title: 'Print Document',
                        success: function () {
                            console.log('success');
                        },
                        error: function (data) {
                            data = JSON.parse(data);
                            console.log('failed: ' + data.error);
                        }
                    });
                });
            }, 1000);

Now I am upgrading my project to Ionic 3 so I tried same thing but output is different here is my new ionic 3 code . printer open but instead of printing as per my document definition it just print the encoded string.

let printer_ = this.printer;
    var dd = this.createDocumentDefinition();
    var pdf = pdfMake.createPdf(dd);
    pdf.getBase64(function (_encodedString) {
      let options: PrintOptions = {
        name: 'MyDocument'
      };
      console.log(JSON.stringify(pdf));
      printer_.print(_encodedString, options).then((msg)=>{
        console.log("Success",msg);
      },(error)  => {
        console.log("Error", error);
      });
      });

Any idea how to use this in ionic 3 ??

@ikishanoza
Copy link
Author

@katzer please help me out

@ikishanoza
Copy link
Author

@katzer Please help me out

@ikishanoza
Copy link
Author

Look here bpampuch/pdfmake#1464 , they say that "pdfmake library is for generate pdf files; not for html or other, for this use different library." Since your plugin is in official documentation of ionic , plugin should support input as one of these threes(base64, buffer or blob).

@ikishanoza
Copy link
Author

@kentongray @janpio @nehresma @nkjf5 @ErikWallin can u please look into this.

@janpio
Copy link
Contributor

janpio commented Aug 22, 2018

No and mentioning random people is highly inappropriate.
Feel free to hire someone for money, then you can just call them with whatever problem you have.

@ikishanoza
Copy link
Author

You are one of the contributor and I thought you can help me on this that's why I mention you here my friend and Its not always about money :) we all are here for helping each other If you can't just ignore.

Have a nice day

@janpio
Copy link
Contributor

janpio commented Aug 22, 2018

I am a random person that did 1 README change in this project. I am also not your friend.
Just accept that mentioning random people in Github issues not appropriate and back down.

@ikishanoza
Copy link
Author

I didn't know what you commit OK and this is totally too rude the way you talk. Fine this is not the place for discussion. I accept, happy now ? Does this makes you feel happy then fine I don't have any issue.

@uokivan
Copy link

uokivan commented Jan 5, 2019

@KishanIos007 did u fix it now ? or use other plugin ?

@katzer
Copy link
Owner

katzer commented Feb 4, 2019

The ionic wrapper might not be up to date but the feature to print PDF files has been added (currently in dev branch). Just wait for the next release.

@katzer katzer closed this as completed Feb 4, 2019
@selmo47
Copy link

selmo47 commented Feb 24, 2019

Waiting excitely for the new release.
You can now use : https://github.com/sarahgoldman/cordova-print-pdf-plugin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants