How-to: Print a PDF or ZPL file with PrintNode

How-to: Print a PDF or ZPL file with PrintNode

Minimum Requirements

  • Mobile WMS Extension version MOB5.63

  • Business Central 2020 release wave 1 (BC16)

  • Tasklet PrintNode Connector configured with API key and printers Set up Tasklet PrintNode

 

Overview

SendPrintJob() submits a print job from Business Central to PrintNode using a configured printer.

Use this function when your extension already has printable content (PDF or RAW/ZPL) and you want to send it directly to a known PrintNode printer using the Tasklet PrintNode Connector.

procedure SendPrintJob( _Title: Text; _Content: Text; _ContentType: Enum "MOB PrintNode Content Type"; _MobPrintNodePrinterSettings: Record "MOB PrintNode Printer Settings" ) Success: Boolean

 

Function signature

Parameter

Description

Parameter

Description

_Title

Name shown in PrintNode print history.

_Content

Payload to print:

  • Base64 data for `pdf_base64` and `raw_base64`

  • Public URI for `pdf_uri` and `raw_uri`

_ContentType

  • pdf_uri

  • pdf_base64

  • raw_uri

  • raw_base64

_MobPrintNodePrinterSettings

Printer record containing PrintNode printer ID and optional print options (paper size, tray, rotation).

When to use it

Use `SendPrintJob` when:

  1. PrintNode is your selected print channel.

  2. You already know the destination printer (`MOB PrintNode Printer Settings` record is resolved).

  3. Your payload is one of the supported formats:

  • PDF (URI or Base64)

  • RAW text, e.g. ZPL (URI or Base64)

Typical scenarios:

  • Print shipping labels (ZPL).

  • Reprint known documents from stored URI/Base64 content.

When it can’t / shouldn’t be used

Do not use `SendPrintJob` when:

  1. Content type is unsupported
    Only PDF and raw formats supported directly by the printer (e.g. ZPL, Postscript & PCL) can be printed, so for instance Word files are most likely not supported.

  2. You need guaranteed physical print completion
    The function only ensures PrintNode accepts the job. It doesn’t confirm if PrintNode is able to send the job to the printer or if the printer is able to print the content.

Examples

Send PDF from URI

procedure PrintPdfFromUri_Docs() var MobPrintNodePrinterSettings: Record "MOB PrintNode Printer Settings"; MobPrintNodeMgt: Codeunit "MOB PrintNode Mgt."; MobPrintNodeContentType: Enum "MOB PrintNode Content Type"; begin // Find or set the printer settings record for the printer you want to print to // In this example, we filter on paper size, but you can filter on other fields as needed to find the right printer settings record or even set the fields directly if you know the values to use MobPrintNodePrinterSettings.SetFilter("Paper Size", 'A4'); MobPrintNodePrinterSettings.FindFirst(); MobPrintNodeMgt.SendPrintJob('Test PDF from URI', 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', MobPrintNodeContentType::pdf_uri, MobPrintNodePrinterSettings); end;

 

Send PDF from Base64

procedure PrintPdfFromBase64_Docs() var MobPrintNodePrinterSettings: Record "MOB PrintNode Printer Settings"; MobPrintNodeMgt: Codeunit "MOB PrintNode Mgt."; MobBase64Convert: Codeunit "MOB Base64 Convert"; MobPrintNodeContentType: Enum "MOB PrintNode Content Type"; Client: HttpClient; Response: HttpResponseMessage; ResponseContent: HttpContent; PdfUri: Text; PdfInStream: InStream; PdfAsBase64: Text; begin // Find or set the printer settings record for the printer you want to print to // In this example, we filter on paper size, but you can filter on other fields as needed to find the right printer settings record or even set the fields directly if you know the values to use MobPrintNodePrinterSettings.SetFilter("Paper Size", 'A4'); MobPrintNodePrinterSettings.FindFirst(); // Get the PDF and convert to Base64 - in real life, you might already have the PDF content as Base64 or in a file or stream that // you can convert, so this step is just for demonstration purposes to get some actual PDF content to send to PrintNode PdfUri := 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'; if not Client.Get(PdfUri, Response) then Error('Unable to download PDF from %1. Error: %2', PdfUri, GetLastErrorText()); if not Response.IsSuccessStatusCode() then Error('Unable to download PDF from %1.\\Status code: %2.\\Reason: %3', PdfUri, Response.HttpStatusCode(), Response.ReasonPhrase()); ResponseContent := Response.Content(); ResponseContent.ReadAs(PdfInStream); PdfAsBase64 := MobBase64Convert.ToBase64(PdfInStream); MobPrintNodeMgt.SendPrintJob('Test PDF from Base64', PdfAsBase64, MobPrintNodeContentType::pdf_base64, MobPrintNodePrinterSettings); end;

 

Send ZPL (RAW) from Base64

procedure PrintZplFromBase64_Docs() var MobPrintNodePrinterSettings: Record "MOB PrintNode Printer Settings"; MobPrintNodeMgt: Codeunit "MOB PrintNode Mgt."; MobBase64Convert: Codeunit "MOB Base64 Convert"; MobPrintNodeContentType: Enum "MOB PrintNode Content Type"; ZplRaw: Text; ZplAsBase64: Text; begin // Find or set the printer settings record for the printer you want to print to // In this example, we filter on name, but you can filter on other fields as needed to find the right printer settings record or even set the fields directly if you know the values to use MobPrintNodePrinterSettings.SetFilter(Name, '@*ZPL*'); MobPrintNodePrinterSettings.FindFirst(); // Create some ZPL content and convert to Base64 - in real life, you might already have the ZPL content as Base64 or in a file or // stream that you can convert, so this step is just for demonstration purposes to get some actual ZPL content to send to PrintNode ZplRaw := '^XA^FO50,50^ADN,36,20^FDHello, World!^FS^XZ'; ZplAsBase64 := MobBase64Convert.ToBase64(ZplRaw); MobPrintNodeMgt.SendPrintJob('Test ZPL from Base64', ZplAsBase64, MobPrintNodeContentType::raw_base64, MobPrintNodePrinterSettings); end;


Version History

Version

Changes

Version

Changes

MOB5.63

Introduced

 

 

 

 

 

 

 

 

 

Overview