'How to print bar code from Microsoft PowerApp

I'm working on a PowerApp which need to generate and print the barcodes. Currently, I've generated barcodes using web API which is returning me the barcode as a PNG image. Now, need to print this barcode from printer. I search much on this and couldn't find the solution yet , I found some posts like https://powerusers.microsoft.com/t5/PowerApps-Ideas/Printing/idi-p/846 , saying that printing is not available now. But, it is a old post, I need the latest update on printing and when it will be available. Also please let me know any other way around to achieve printing from the PowerApp, so I could instantly print the barcodes.



Solution 1:[1]

Its not a way to directly print, but you could:

  • Use Flow to call the barcode API and convert the .png to .pdf using the OneDrive Actions

  • Use Flow to call the bacrcode API and convert the .png to .pnf then email it to user so they can print.

Hope this helps!

Solution 2:[2]

Printing using pdf - But with more customization:

I'm using this to Tag Packets of Timber.

In Power Flow:

  1. Use Onedrive Upload file from URL to fetch your barcode:
    https://barcode.tec-it.com/barcode.ashx?data=MY_PACK_NUMBER&code=EANUCC128&height=20&hidehrt=True Onedrive Upload file from URL

  2. Get file content of image & Uri Encode it: Flow Get file and encode using dataUri

    dataUri(outputs('Get_file_content')?['body']) Code for converting image to Uri

  3. Using HTML, Craft the label: enter image description here

    <div style='font-family: Arial, Helvetica, sans-serif;height: 101.6mm;width:152.4mm;border-style: solid;overflow: hidden;'>
    
      <h1 style='font-size:50px;padding:10px;margin:0px;text-align: center;'>@{triggerBody()['text']}</h1>
      <img style='position:left;padding-left:50px' src="@{outputs('ImageEncoded')}" />
      <p style='padding-left:10px;font-size:40px;margin:0px;padding-top:10px;'>@{triggerBody()['text_1']}</p>
      <br>
      <table style='font-weight:bold;width:100%;padding:10px;border:none;margin-left: 10px;'>
        <tr>
          <td>LM:</td>
          <td>258.92</td>
          <td>M3:</td>
          <td>1.139</td>
          <td>13 Jan 22</td>
        </tr>
        <tr>
          <td>Tally:</td>
          <td colspan="3">1/1.52 12/1.83 4/2.13 93/2.44</td>
        </tr>
      </table>
    </div>
    Here is what my template looks like from the HTML above: Preview of HTML tag template

You could stop here and convert the HTML to PDF using Onedrive or a paid Service, But I need a Landscape PDF of a particular size for my Label Printer.

  1. Save HTML to file, Then Convert HTML to JPG: enter image description here
  2. Create a MS Word Fillable Template to accept inputs from our flow:
    HowTo: Guide to Create fillable Form in Word for use in Flow

Only First Section of linked guide is needed

I've changed the margins on my page, Added a single Picture content control, Changed to Landscape and added and resized sample image to match:

Adding Image Control to Word Template

It would be best to give the Control a Name, I didn't: enter image description here

  1. Save template in Onedrive, (mine is saved under /PDF)
  2. In Flow: Populate Template, Save it as new docx file then Convert to PDF: Populate word template, save then convert to PDF
  3. Lastly: Save your PDF: Save PDF to Drive End Result: - Landscape PDF, Custom Size with Barcode. End result

    I then submit this PDF to PrintNode API to get printed: - Tutorial: Print Using PrintNode PrintNode Example
    - Note: It takes about 10 seconds to run this flow.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SeaDude
Solution 2 p99will