DavBfr / dart_pdf

Pdf creation module for dart/flutter
https://pub.dev/packages/pdf
Apache License 2.0
1.42k stars 632 forks source link

Printing long POS receipt #683

Closed Maged12 closed 3 years ago

Maged12 commented 3 years ago

Describe the bug when i try to printing a log POS receipt it only print the first part of it

To Reproduce Code snippet to reproduce the behavior:

await Printing.directPrintPdf( printer: Printer(url: usbPrinter), onLayout: (PdfPageFormat format) async => _pdf.save(), dynamicLayout: false, format: PdfPageFormat.roll80);

Expected behavior it should print all the pdf because when i use my browser to print it ,it printing all of it not only a small part as this package

Screenshots

WhatsApp Image 2021-05-08 at 9 35 30 PM

Flutter Doctor

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

DavBfr commented 3 years ago

I don't have a POS printer.

luis901101 commented 3 years ago

I have a similar problem here, the thing in my case is that directPrintPdf is ignoring the specified format. This is my code:

Printing.directPrintPdf(
  printer: selectedPrinter,
  onLayout: (format) => pdfBytes,
  format: PdfPageFormat(3.15 * PdfPageFormat.inch , 6.62 * PdfPageFormat.inch),
  dynamicLayout: true,
);

The output is not taking into account the width/height specified in format but the printer page size format. If I try with dynamicLayout: false, then output is blank and format remains the same as printer page size format. Note: I'm testing with Printer Simulator cause I don't have a physical AirPrint printer at hand Is this problem because of using Printer Simulator?, or custom format can't be specified in directPrintPdf for all printers? How to know when I can set custom format for directPrintPdf or is this not possible?

DavBfr commented 3 years ago

@luis901101 the format here is just a hint for the platform, but in the end, only the real paper format is used. Your issue is certainly because of the simulator, but you can use a different paper format with the simulator.

anandsubbu007 commented 2 years ago

facing same issue may i know how to print a long POS Receipt?

Maged12 commented 2 years ago

it is just because of the format so i had searched for a suitable format and i made it like that : format: const PdfPageFormat(204, 842), and it works pretty well for me so you can try it and tell me

anandsubbu007 commented 2 years ago

still facing same issue

it is just because of the format so i had searched for a suitable format and i made it like that : format: const PdfPageFormat(204, 842), and it works pretty well for me so you can try it and tell me

Fearripper commented 2 years ago

hey , I would like to know how you achieved USB thermal printing did u use any external package ? it will be helpful for me as i am implementing this package on Linux desktop flutter.

techttiru commented 2 years ago

still facing same issue

it is just because of the format so i had searched for a suitable format and i made it like that : format: const PdfPageFormat(204, 842), and it works pretty well for me so you can try it and tell me

@anandsubbu007 I tried the below setting for thermal printer (USB) and its aligned to default settings.

i just took the default setting of PdfPageFormat.roll80 and adjusted the right side margin based on the need because i saw truncation on the right side alone when we print in real device. Since this setting had default margin of 5 * mm in all side. so adjusted the right side margin alone 15 times instead of 5 times.

    const double inch = 72.0;
    const double mm = inch / 25.4;

      pageFormat: const PdfPageFormat(80 * mm, double.infinity,
              marginTop: 5 * mm,
              marginBottom: 5 * mm,
              marginLeft: 5 * mm,
              marginRight: 15 * mm),
techttiru commented 2 years ago

How to connect the USB POS printer? I dont want to connect via ip address. if USB printer is connect in widows system, then i should be able to send the print to default assigned printer. is that possible in flutter web application?

techttiru commented 2 years ago

usbPrinter

@Maged12 Hi, in my flutter web app, i am unable to connect the USB printer. can you share how did you connect the USB printer in your applications? how did you find the url for USB printer? my printer does not support anything other than USB interface. I see the below in your post but how did you find the URL for USB printer? printer: Printer(url: usbPrinter),

Can we connect USB printer in flutter web app?

Doublelae commented 6 months ago

I found solution for long slip voucher =>

await Printing.layoutPdf(onLayout: (PdfPageFormat format) async => doc.save(),format:is80? PdfPageFormat.roll80: PdfPageFormat.roll57);

20240524-154814 20240524-154830

shobhit207200 commented 6 months ago

I found solution for long slip voucher =>

await Printing.layoutPdf(onLayout: (PdfPageFormat format) async => doc.save(),format:is80? PdfPageFormat.roll80: PdfPageFormat.roll57);

20240524-154814 20240524-154830

Hi, Im using pageFormat: PdfPageFormat.roll80, this as well but my paper print size is less. What exactly did you use? Could you share your code snipet?

Doublelae commented 5 months ago

@shobhit207200

first create doc with PdfPageFormat.roll80 then add follow code await Printing.layoutPdf(onLayout: (PdfPageFormat format) async => doc.save(),format: PdfPageFormat.roll80);