Skip to content

[iOS] Can't print a PDF with printPdfFile #109

@liammdowney

Description

@liammdowney

Hello,

I've got an issue printPdfFile in that is doesn't print the PDF file,. I can print an image using printImage though.

I get the error code 6, and the code name of ERROR_COMMUNICATION_ERROR

Here's my steps:

  • Make sure the device (RJ-4250WB) is connected in Settings->Bluetooth.
  • In the app select the printer from a list.
  • Press print.
  • PDF is generated in the temp directory (e.g. var/mobile/Containers/Data/Application/046DCC97-9A44-4A3D-A306-3D65373CD092/Library/Caches/generated.pdf)
  • Call printer.printPdfFile(pdf, 1);
  • Print Fails.
  • Look at Settings->Bluetooth and the printer has been disconnected.

The PDF is correct (I've looked at it from within the container), and it also loaded in a preview before printing.

The strange thing is, if I comment out the pdf print, and use the image print (so try and print the pdf one time, then try and print an image the next), the image prints over the PDF. The PDF is in the background of the image.

Here's a code snippet:

var printerInfo = await settings.printerSettings.selectedPrinter?.getPrinterInfo();
var printerUtils = PrinterUtils();
var pdf = await printerUtils.getPdfPreviewPath( widget.ticket, printerInfo?.customPaperWidth ?? 153 );

//fails with the error code above
 var result = await settings.printerSettings.selectedPrinter?.printPdfFile(pdf, 1);

// Works:                             
// var logoAsset = await loadImage('assets/images/print_test/account_logo.png');
// await settings .printerSettings.selectedPrinter?.printImage(logoAsset);

Where am I going wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions