Answers.Body: <p>Bit of a late reply (But hope you can use this!), but I created a plugin to output barcodes within Craft templates via Twig:</p>
  
  <p><a href="https://github.com/madebyshape/barcode" rel="nofollow noreferrer">https://github.com/madebyshape/barcode</a></p>
  
  <p>I created it because one of our clients required a barcode to be output in to a generated PDF that got sent to their customers.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-06T17:38:27.350Z
Answers.LastActivityDate: 2016-11-06T17:38:27.350Z
Answers.UserDisplayName: Jason Mayo
Answers.Body: <p>For reference, I highly recommend reading the Craft plugin docs: <a href="https://craftcms.com/docs/plugins" rel="nofollow">https://craftcms.com/docs/plugins</a></p>
  
  <p>You can certainly use a <a href="https://craftcms.com/docs/plugins/models" rel="nofollow">Model</a>, but it depends on how you want to architect the rest of your plugin.  I like to think of a Model as a convenient way of transporting objects/data across the different layers of your plugin (<a href="https://craftcms.com/docs/plugins/variables" rel="nofollow">Template Variables</a>, <a href="https://craftcms.com/docs/plugins/services" rel="nofollow">Services</a>, <a href="https://craftcms.com/docs/plugins/controllers" rel="nofollow">Controllers</a>, etc.).</p>
  
  <p>That plugin currently will just generate the image and <a href="https://github.com/rlt3/php-barcode/blob/master/ean.php#L167" rel="nofollow">output it directly to the browser</a>, which may or may not be what you want from a template.  What you may want to do is take that image and save it to the file system (in a temporary or permanent public place) and have your Twig template reference that file directly.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-25T22:26:37.023Z
Answers.LastActivityDate: 2016-07-25T22:26:37.023Z
Answers.UserDisplayName: Brad Bell
Body: <p>The project that I'm working on requires that I generate an EAN13 barcode for display on vouchers. </p>
  
  <p>I'm attempting to implement the following as a Craft Plugin: <a href="https://github.com/rlt3/php-barcode" rel="nofollow">https://github.com/rlt3/php-barcode</a></p>
  
  <p>The part that I am unclear about is how exactly to define my Model to return an image to the calling template. Do I even need a Model ? </p>
  
Tags: <plugin-development>
Title: Generate EAN13 barcode
ThreadText: # Generate EAN13 barcode
  
  (Asked by: username_0 on 2016-07-21)
  
  The project that I'm working on requires that I generate an EAN13 barcode for display on vouchers.
  
  I'm attempting to implement the following as a Craft Plugin: <https://github.com/rlt3/php-barcode>
  
  The part that I am unclear about is how exactly to define my Model to return an image to the calling template. Do I even need a Model ?
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-11-06. Score: 2
  
  Bit of a late reply (But hope you can use this!), but I created a plugin to output barcodes within Craft templates via Twig:
  
  <https://github.com/madebyshape/barcode>
  
  I created it because one of our clients required a barcode to be output in to a generated PDF that got sent to their customers.
  
  
  ---
  
  ### Answer by username_2 on 2016-07-25. Score: 1
  
  For reference, I highly recommend reading the Craft plugin docs: <https://craftcms.com/docs/plugins>
  
  You can certainly use a [Model](https://craftcms.com/docs/plugins/models), but it depends on how you want to architect the rest of your plugin. I like to think of a Model as a convenient way of transporting objects/data across the different layers of your plugin ([Template Variables](https://craftcms.com/docs/plugins/variables), [Services](https://craftcms.com/docs/plugins/services), [Controllers](https://craftcms.com/docs/plugins/controllers), etc.).
  
  That plugin currently will just generate the image and [output it directly to the browser](https://github.com/rlt3/php-barcode/blob/master/ean.php#L167), which may or may not be what you want from a template. What you may want to do is take that image and save it to the file system (in a temporary or permanent public place) and have your Twig template reference that file directly.
  
  
  ---
  
  