CodeMinion / another_brother

Another Brother Flutter SDK
BSD 3-Clause "New" or "Revised" License
21 stars 21 forks source link

Print multi page PDF on Android and iOS #89

Open alaindeseine opened 4 months ago

alaindeseine commented 4 months ago

Hi @CodeMinion,

I'm back with a problem!

I need to print a pdf which has more than one page. like this one: 1d03fb0559d2ea414911ab699d15a4fb.pdf

The print printPdfFile function prototype permit to indicate a page number (int) to print.

When i check the Brother SDK documentation, i see that (for Android, i have not yet see for iOs) the printPDF function has 3 prototypes:

The first prototype permit to print all the pages of a PDF file.

When i look at your implementation it seems that you don't implement it. Am i right ?

Do you think it is possible to implement it ? or Not ?

Best regards

Alain Deseine.

CodeMinion commented 4 months ago

Hi @alaindeseine ,

Thanks for reaching out about this. You are right, I just looked at the implementation as well and that path is not implemented.

I'll set some time aside this weekend and add it and let you know once the new version is out.

Thanks again for reaching out about this and letting me know of the missing implementation,

alaindeseine commented 4 months ago

Hi @CodeMinion Thanks a lot! Tell me if i can help. Regards.

SoCaliOS commented 4 months ago

I add the following and it works:

  // Loop through each page and print it
  int totalPageCount = pageCount ?? 1;
  for (int pageNumber = 1; pageNumber <= totalPageCount; pageNumber++) {
    brother.PrinterStatus printResult = await printer.printPdfFile(filepath, pageNumber);
    await processPrinting(printResult, context);
  }
alaindeseine commented 4 months ago

@SoCaliOS

You're right, but there is an API in Brother's SDK that handle printing of all PDF pages. Using it, in my case, will save me from opening the PDF to count the pages.

My application operates in production conditions in the food industry and any second saved is precious.

CodeMinion commented 4 months ago

Hi @alaindeseine ,

Apologies for the delay. Unfortunately on a second pass I noticed that the APIs mentioned are part of version 4 of the Brother mobile SDK while another_brother was built on top of version 3. The two versions use very different ways of printing so currently until we do a major rewrite of the Android implementation the only way to accomplish the multi page print is by using the suggestion from @SoCaliOS.

alaindeseine commented 4 months ago

Hi @CodeMinion

I understand.

Have you already planned to upgrade to V4 or not at all?

I had already practiced as @SoCaliOS suggests to get around the problem earlier last June. But I preferred to wait for the modification before using this workaround.

So I'm going to implement it while waiting for the transition to V4.

Thank you again for your support.

Best regards,

CodeMinion commented 4 months ago

Hi @alaindeseine ,

Updating to v4 is in the cards, though currently one of the main elements holding back the upgrade is that the v4 for Android does not support the full set of features of the v3 (or at least that was the case last I looked into it). The other is having a slice of spare time large enough to perform the update.

Thanks again for all your support,