Barcode Plugin Development: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
==Simple tasks==
==Simple tasks==


* Switch from the monolithic flavour of BWIPP to the monolithic-package flavour which is functionally equivalent, more suited to distribution and DSC-conforming. Has been tested by replacing the existing barcode.ps and works as expected. Description of the available flavours [http://bwipp.terryburton.co.uk/#download here].
* Hexify the data and options string input from Scribus to BWIPP to prevent PostScript injection by means of unescaped ")" or otherwise. See this discussion [https://bitbucket.org/whosaysni/elaphe/issue/18/make-codestring-optionstring-hexilified here]. [https://github.com/bwipp/scribus NOW MERGED]
* Hexify the data and options string input from Scribus to BWIPP to prevent PostScript injection by means of unescaped ")" or otherwise. See this discussion [https://bitbucket.org/whosaysni/elaphe/issue/18/make-codestring-optionstring-hexilified here]. [https://github.com/bwipp/scribus IN PROGRESS]
* Add an advanced textbox that allows the user to directly provide the options string to the library for advanced users who follow the [https://github.com/bwipp/postscriptbarcode/wiki BWIPP reference]. [https://github.com/bwipp/scribus NOW MERGED]
* Add an advanced checkbox that allows the user to directly provide the options string to the library for advanced users who follow the [https://github.com/bwipp/postscriptbarcode/wiki BWIPP reference]. [https://github.com/bwipp/scribus IN PROGRESS]
* Locking the aspect ratio of the imported object could be advantageous.


==Moderate tasks==
==Moderate tasks==


* Add support for the remaining barcode symbologies that are supported by BWIPP: [https://github.com/bwipp/scribus IN PROGRESS]
* Add support for the remaining barcode symbologies that are supported by BWIPP: [https://github.com/bwipp/scribus NOW MERGED]
** Point of Sale: ISMN, ISSN
* To make the presentation of the list of barcode formats manageable we should sort the list of barcodes in the same/similar way as the web-based generator [http://www.terryburton.co.uk/barcodewriter/generator/ here]. [https://github.com/bwipp/scribus PARTIAL]
** GS1 DataBar: GS1 DataBar Omnidirectional, GS1 DataBar Stacked, GS1 DataBar Stacked Omnidirectional, GS1 DataBar Truncated, GS1 DataBar Limited, GS1 DataBar Expanded, GS1 DataBar Expanded Stacked
  * The list is still long and may be unworkable on certain platforms. Consider a multi-combo approach or other.
** Supply Chain: SSCC-18, EAN-14, GS1 DataMatrix
* Extract descriptions, example data and example options from the barcode.ps metadata by scanning for DESC, EXAM and EXOP stanzas within BEGIN/ENCODER ENCODER blocks. [https://github.com/bwipp/scribus NOW MERGED]
** Common 2D symbols: Data Matrix,  Aztec Code, PDF417, MicroPDF417
** Common 1D symbols: Code 39 Full ASCII, Code 93, Code 93 Full ASCII
** Postal symbols: USPS PLANET, USPS Intelligent Mail, USPS FIM, Royal TNT Post, Japan Post, Australia Post, Deutsche Post Identcode, Deutsche Post Leitcode, MaxiCode
** Pharmaceutical symbols: Pharmacode, Two-track Pharmacode, Code 32, Pharmazentralnummer
** Less-used 2D symbols: Codablock F, Code 16K, Code 49, Code One
** Less-used 1D symbols: Code 11, Codabar, Telepen, Channel Code, PosiCode, BC412
** GS1 Composite symbols: EAN-13 Composite, EAN-8 Composite, UPC-A Composite, UPC-E Composite, GS1 DataBar Omnidirectional Composite, GS1 DataBar Stacked Composite, GS1 DataBar Stacked Omnidirectional Composite, GS1 DataBar Truncated Composite, GS1 DataBar Limited Composite, GS1 DataBar Expanded Composite, GS1 DataBar Expanded Stacked Composite, GS1-128 Composite
** HIBC symbols: HIBC Codablock F, HIBC Code 128, HIBC Code 39, HIBC Data Matrix, HIBC PDF417, HIBC MicroPDF417, HIBC QR Code
* To make the presentation of the list of barcode formats manageable we should sort the list of barcodes in the same/similar way as the web-based generator [http://www.terryburton.co.uk/barcodewriter/generator/ here]. [https://github.com/bwipp/scribus IN PROGRESS]
* Use the BWIPP error reporting mechanism to provide specific error messages to users so that they can understand why a given input is invalid. For example, the following PS procedure can be used to invoke barcode.ps and on error will halt with the descriptive text of the error (e.g. "BWIPP ERROR: EAN-13 must be 12 or 13 digits") written to STDERR which Scribus can display in the GUI:
* Use the BWIPP error reporting mechanism to provide specific error messages to users so that they can understand why a given input is invalid. For example, the following PS procedure can be used to invoke barcode.ps and on error will halt with the descriptive text of the error (e.g. "BWIPP ERROR: EAN-13 must be 12 or 13 digits") written to STDERR which Scribus can display in the GUI:
   %!PS
   %!PS
Line 55: Line 44:
*** /usr/share/libpostscriptbarcode/barcode.ps (Debian's libpostscriptbarcode package)
*** /usr/share/libpostscriptbarcode/barcode.ps (Debian's libpostscriptbarcode package)
** In either case, if barcode.ps is not found, prompt the user by showing the dialog with PATH_TO_BWIPP=USER pre-selected.
** In either case, if barcode.ps is not found, prompt the user by showing the dialog with PATH_TO_BWIPP=USER pre-selected.
* Allow the barcode plugin to be driven from ScripterNG.


==Harder tasks==
==Harder tasks==


* Support new barcode formats automatically by scanning the barcode.ps metadata for BEGIN/END ENCODER blocks. [https://github.com/bwipp/scribus IN PROGRESS]
* Create a new type of Scribus Barcode Item:
* Extract descriptions, example data and example options from the barcode.ps metadata by scanning for DESC, EXAM and EXOP stanzas within BEGIN/ENCODER ENCODER blocks. [https://github.com/bwipp/scribus IN PROGRESS]
  * A vector item that cannot be ungrouped
 
  * Initially fixed aspect ratio
Example barcode.ps metadata for an encoder:
  * Stores the value behind the created barcode: codeEdit, optionsEdit, lnColor, bgColor, txtColor (Checkbox states unnecessary as encoded in optionsEdit)
 
  * Ideally, double-clicking on such an item would bring up the barcode dialogue (not the Group Tab of the PP), so that a user can change the data, and the barcode drawing would be updated after clicking an "Update" button. This would, obviously, require some extensions to the Scribus core, as well as changes to the file format.
  % --BEGIN ENCODER ean8--
* Render the preview in a background QThread so that updating the preview image doesn't snatch attention away from the UI. See [http://lists.scribus.net/pipermail/scribus-dev/2015-February/002487.html here].
  % --REQUIRES preamble raiseerror renlinear ean5 ean2--
* Allow the barcode plugin to be driven from ScripterNG.
  % --DESC: EAN-8
  % --EXAM: 02345673
  % --EXOP: includetext guardwhitespace
  % --RNDR: renlinear
  ... PostScript resource definition here ...
  % --END ENCODER ean8--
 
* Create a new type of Scribus Item (a vector item that cannot be ungrouped) that also stores the value behind the created barcode (e.g. a URL). Ideally, double-clicking on such an item would bring up the barcode dialogue (not the Group Tab of the PP), so that a user can change the data, and the barcode drawing would be updated after clicking an "Update" button. This would, obviously, require some extensions to the Scribus core, as well as changes to the file format.
* Render the preview in a background QThread so that updating the preview image doesn't snatch attention away from the UI for each action. See [http://lists.scribus.net/pipermail/scribus-dev/2015-February/002487.html here].


==Collaborative tasks==
==Collaborative tasks==
Line 80: Line 59:
The following tasks require some degree of coordination between Scribus and [[User:Terryburton|Terry Burton]], the author of BWIPP.
The following tasks require some degree of coordination between Scribus and [[User:Terryburton|Terry Burton]], the author of BWIPP.


* Extend the barcode.ps metadata to describe the options that are available for each encoder so that any frontends such as the Scribus plugin can be light on compiled in data and enhanced by simply replacing the barcode.ps file.
* Extend the barcode.ps metadata to describe the options that are available for each encoder so that any frontends such as the Scribus plugin can be light on compiled in data and enhanced with new format by simply replacing the barcode.ps file.
* Mentor a GSOC student on this barcode plugin.
* Mentor a GSOC student on this barcode plugin.

Revision as of 14:23, 14 August 2015

This article is part of the Ongoing Discussions series.
Installation Usability MacOS Fonts Other

The barcode plugin does not currently provide all of the functionality that is available in the underlying library, Barcode Writer in Pure PostScript (BWIPP).

The BWIPP wiki provides some recommendations for frontends.

This page is intended to provide a collaboration point to coordinate improvements to the barcode plugin. Please extend, debate and discuss as appropriate.

Simple tasks

  • Hexify the data and options string input from Scribus to BWIPP to prevent PostScript injection by means of unescaped ")" or otherwise. See this discussion here. NOW MERGED
  • Add an advanced textbox that allows the user to directly provide the options string to the library for advanced users who follow the BWIPP reference. NOW MERGED

Moderate tasks

  • Add support for the remaining barcode symbologies that are supported by BWIPP: NOW MERGED
  • To make the presentation of the list of barcode formats manageable we should sort the list of barcodes in the same/similar way as the web-based generator here. PARTIAL
 * The list is still long and may be unworkable on certain platforms. Consider a multi-combo approach or other.
  • Extract descriptions, example data and example options from the barcode.ps metadata by scanning for DESC, EXAM and EXOP stanzas within BEGIN/ENCODER ENCODER blocks. NOW MERGED
  • Use the BWIPP error reporting mechanism to provide specific error messages to users so that they can understand why a given input is invalid. For example, the following PS procedure can be used to invoke barcode.ps and on error will halt with the descriptive text of the error (e.g. "BWIPP ERROR: EAN-13 must be 12 or 13 digits") written to STDERR which Scribus can display in the GUI:
 %!PS
 errordict begin
 /handleerror {
   $error begin
   errorname dup length string cvs 0 6 getinterval (bwipp.) eq {
     (%stderr) (w) file
     dup (\nBWIPP ERROR: ) writestring
     dup errorname dup length string cvs writestring
     dup ( ) writestring
     dup errorinfo dup length string cvs writestring
     dup (\n) writestring
     dup flushfile end quit
   } if
   end //handleerror exec
 } bind def
 end
 % If necessary, set up anything specific to the environment here.
 (barcode.ps) run
  • Allow the location of the barcode.ps file to be configured by the user so that non-admins users can provide a local version and distributions that deprecate bundled libraries can provide a separately packaged version. One way to do this is to provide a configuration dialog with PATH_TO_BWIPP=USER|DEFAULT.
    • Use the user supplied path if PATH_TO_BWIPP=USER.
    • Apply the following search order if PATH_TO_BWIPP=DEFAULT:
      • ~/.scribus/plugins/barcode.ps (user replacement)
      • [%APP_INSTALL_DIR%]/share/scribus/plugins/barcode.ps (bundled version)
      • /usr/share/postscriptbarcode/barcode.ps (Fedora's postscriptbarcode package)
      • /usr/share/libpostscriptbarcode/barcode.ps (Debian's libpostscriptbarcode package)
    • In either case, if barcode.ps is not found, prompt the user by showing the dialog with PATH_TO_BWIPP=USER pre-selected.

Harder tasks

  • Create a new type of Scribus Barcode Item:
 * A vector item that cannot be ungrouped
 * Initially fixed aspect ratio
 * Stores the value behind the created barcode: codeEdit, optionsEdit, lnColor, bgColor, txtColor (Checkbox states unnecessary as encoded in optionsEdit)
 * Ideally, double-clicking on such an item would bring up the barcode dialogue (not the Group Tab of the PP), so that a user can change the data, and the barcode drawing would be updated after clicking an "Update" button. This would, obviously, require some extensions to the Scribus core, as well as changes to the file format.
  • Render the preview in a background QThread so that updating the preview image doesn't snatch attention away from the UI. See here.
  • Allow the barcode plugin to be driven from ScripterNG.

Collaborative tasks

The following tasks require some degree of coordination between Scribus and Terry Burton, the author of BWIPP.

  • Extend the barcode.ps metadata to describe the options that are available for each encoder so that any frontends such as the Scribus plugin can be light on compiled in data and enhanced with new format by simply replacing the barcode.ps file.
  • Mentor a GSOC student on this barcode plugin.