Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,408 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
Barcodes Reference | ||
================== | ||
|
||
**New on 0.4** | ||
|
||
The BarCode element is just one, and it is used to show barcodes of many types | ||
on the report. | ||
|
||
This element is inherited from **geraldo.graphics.Graphic** | ||
|
||
BarCode | ||
------- | ||
|
||
.. currentmodule:: geraldo.barcodes | ||
.. class:: BarCode | ||
|
||
Path: **geraldo.barcodes.BarCode** | ||
|
||
This is the once class you can use to show bar codes. It supports the following | ||
bar code types, supplied by **ReportLab** barcodes library: | ||
|
||
* Codabar | ||
* Code11 | ||
* Code128 | ||
* EAN13 | ||
* EAN8 | ||
* Extended39 | ||
* Extended93 | ||
* FIM | ||
* I2of5 | ||
* MSI | ||
* POSTNET | ||
* Standard39 | ||
* Standard93 | ||
* USPS_4State | ||
|
||
**Attributes** | ||
|
||
- **name** - Default: None | ||
- **visible** - Default: True | ||
|
||
Set to **False** if you want to make it not visible. | ||
|
||
- **height** - Default: 1.5*cm | ||
- **width** - Default: 0.03*cm | ||
|
||
This attribute **does not set the barcode width**, but the **bar width**, | ||
what means it is the width of the minimum bar of a barcode. You should set | ||
values like 0.02*cm or something like that (i.e. never 5*cm). | ||
|
||
- **attribute_name** - Default: None | ||
|
||
As same as **geraldo.widgets.ObjectValue**, this attribute reffers to an | ||
attribute, attribute path or method to get the barcode value. | ||
|
||
- **checksum** - Default: 0 | ||
|
||
Most of barcode types supports you set the number of digits for checksum. | ||
|
||
- **routing_attribute** - Default: None | ||
|
||
Useful only for **USPS_4State** barcodes. Works like **attribute_name**, but | ||
**routing** attribute of barcode. | ||
|
||
**Rendering attributes** | ||
|
||
They are read-only attributes you can use at render time. | ||
|
||
- **instance** - current object being rendered | ||
- **generator** - generator instance | ||
- **report** - report instance this element is in | ||
- **band** - band this element is in | ||
- **page** - current page | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
Showing BarCodes | ||
================ | ||
|
||
Bar codes are really important on labels, bills, tickets, etc. | ||
|
||
This example demonstrates how to show barcodes of all supported types on a report. | ||
|
||
There are many different types of bar codes and we will support those ReportLab | ||
already does. | ||
|
||
**BarCode element** | ||
|
||
**geraldo.barcodes.BarCode** is the graphic class that generates the bar codes of | ||
all supported types. It is an inheritance from Graphic element. | ||
|
||
Supported bar code types: | ||
|
||
- Codabar | ||
- Code11 | ||
- Code128 | ||
- EAN13 | ||
- EAN8 | ||
- Extended39 | ||
- Extended93 | ||
- FIM | ||
- I2of5 | ||
- MSI | ||
- POSTNET | ||
- Standard39 | ||
- Standard93 | ||
- USPS_4State | ||
|
||
The code:: | ||
|
||
import os | ||
cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
from geraldo.utils import A4, cm, TA_CENTER, TA_RIGHT | ||
|
||
from geraldo import Report, ReportBand, Label, ObjectValue, SystemField,\ | ||
FIELD_ACTION_COUNT, BAND_WIDTH | ||
from geraldo.barcodes import BarCode | ||
|
||
class SimpleListReport(Report): | ||
title = 'Demonstration of BarCodes' | ||
|
||
class band_page_header(ReportBand): | ||
height = 1*cm | ||
elements = [ | ||
SystemField(expression='%(report_title)s', top=0.1*cm, left=0, width=BAND_WIDTH, | ||
style={'fontName': 'Helvetica', 'fontSize': 14, 'alignment': TA_CENTER}), | ||
] | ||
borders = {'bottom': True} | ||
|
||
class band_page_footer(ReportBand): | ||
height = 0.5*cm | ||
elements = [ | ||
Label(text='Created with Geraldo Reports', top=0.1*cm, left=0), | ||
SystemField(expression='Page # %(page_number)d of %(page_count)d', top=0.1*cm, | ||
width=BAND_WIDTH, style={'alignment': TA_RIGHT}), | ||
] | ||
borders = {'top': True} | ||
|
||
class band_detail(ReportBand): | ||
height = 15*cm | ||
elements = [ | ||
ObjectValue(attribute_name='name', style={'fontSize': 12}), | ||
Label(text='Code:', style={'fontSize': 12}, left=6.5*cm), | ||
ObjectValue(attribute_name='code', style={'fontSize': 12}, left=8*cm), | ||
|
||
Label(text='Codabar', top=0.6*cm), | ||
BarCode(type='Codabar', attribute_name='code', top=1.2*cm, height=1.5*cm), | ||
|
||
Label(text='Code11', top=0.6*cm, left=6*cm), | ||
BarCode(type='Code11', attribute_name='code', top=1.2*cm, left=6*cm, height=1.5*cm), | ||
|
||
Label(text='Code128', top=0.6*cm, left=12*cm), | ||
BarCode(type='Code128', attribute_name='code', top=1.2*cm, left=12*cm, height=1.5*cm), | ||
|
||
Label(text='EAN13', top=3.2*cm), | ||
BarCode(type='EAN13', attribute_name='code', top=3.8*cm, height=1.5*cm), | ||
|
||
Label(text='EAN8', top=3.2*cm, left=6*cm), | ||
BarCode(type='EAN8', attribute_name='code', top=3.8*cm, left=6*cm, height=1.5*cm), | ||
|
||
Label(text='Extended39', top=3.2*cm, left=12*cm), | ||
BarCode(type='Extended39', attribute_name='code', top=3.8*cm, left=12*cm, height=1.5*cm), | ||
|
||
Label(text='Extended93', top=5.8*cm), | ||
BarCode(type='Extended93', attribute_name='code', top=6.4*cm, height=1.5*cm), | ||
|
||
Label(text='USPS FIM (code: "A")', top=5.8*cm, left=6*cm), | ||
BarCode(type='FIM', attribute_name='code', top=6.4*cm, left=8*cm, height=1.5*cm, | ||
get_value=lambda inst: 'A'), | ||
|
||
Label(text='I2of5', top=5.8*cm, left=12*cm), | ||
BarCode(type='I2of5', attribute_name='code', top=6.4*cm, left=12*cm, height=1.5*cm), | ||
|
||
Label(text='MSI', top=8.4*cm), | ||
BarCode(type='MSI', attribute_name='code', top=9*cm, height=1.5*cm), | ||
|
||
Label(text='POSTNET', top=8.4*cm, left=6*cm), | ||
BarCode(type='POSTNET', attribute_name='code', top=9*cm, left=6*cm, height=1.5*cm), | ||
|
||
Label(text='Standard39', top=8.4*cm, left=12*cm), | ||
BarCode(type='Standard39', attribute_name='code', top=9*cm, left=12*cm, height=1.5*cm), | ||
|
||
Label(text='Standard93', top=11*cm), | ||
BarCode(type='Standard93', attribute_name='code', top=11.6*cm, height=1.5*cm), | ||
|
||
Label(text='USPS_4State / code: 01234567094987654321 / routing:', top=11*cm, | ||
left=6*cm, width=10*cm), | ||
ObjectValue(attribute_name='routing', top=11.5*cm, left=14*cm), | ||
BarCode(type='USPS_4State', attribute_name='code', top=11.6*cm, left=6*cm, | ||
height=1.5*cm, routing_attribute='routing', | ||
get_value=lambda inst: '01234567094987654321'), | ||
] | ||
borders = {'bottom': True} | ||
|
||
Creating a list of objects we are going to list on on the report | ||
|
||
>>> objects_list = [ | ||
... dict(id=1, name='Arduino Duemilanove', code='123456789', routing='01234567891'), | ||
... dict(id=2, name='Arduino Diecimila', code='000000000', routing='01234567891'), | ||
... dict(id=3, name='Robotduino', code='111111111', routing='01234567891'), | ||
... ] | ||
|
||
Creating an instance of the report | ||
|
||
>>> report = SimpleListReport(queryset=objects_list) | ||
|
||
PDF generation | ||
|
||
>>> from geraldo.generators import PDFGenerator | ||
>>> report.generate_by(PDFGenerator, filename=os.path.join(cur_dir, 'output/report-with-barcodes.pdf')) | ||
|
||
The Result | ||
|
||
- http://geraldo.svn.sourceforge.net/viewvc/geraldo/examples/report-with-barcodes.pdf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,5 @@ source code. | |
in-multiprocessing | ||
using-events | ||
additional-fonts | ||
barcodes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ Content | |
basic | ||
widgets | ||
graphics | ||
barcodes | ||
generators | ||
caching | ||
utils | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.