Ask Your Question
0

Print bar code label from libre base form

asked 2017-10-23 20:29:03 +0100

nd08 gravatar image

Hello,

I have a libre base form, from which I would like to print a barcode label for the ID whose record is displayed on the screen.

for example: person id 1234567A (print barcode label for this id from the form)

Any help/suggestion would be appreciated.

Many thanks.

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

answered 2017-10-23 22:20:33 +0100

nd08 gravatar image

Thank you for the quick response.

I have created simple data entry forms in libre base but nothing fancy and I do not have enough knowledge of programming or writing a macro.

I like the idea of printing the barcode label immediately by pressing a button on the form. This is what I had in mind. But don’t know how to do that.

Any help on how to do this would be very welcome.

edit flag offensive delete link more

Comments

Please use comments to reply to an answer.

Ratslinger gravatar imageRatslinger ( 2017-10-23 22:29:01 +0100 )edit
0

answered 2017-10-24 11:29:32 +0100

Henk C. Meerhof gravatar image

IMO the easiest and best way to solve this problem is to install a barcode font. Then the only thing you have to figure out is: 1) which kind of barcode to use (fx. Code 39) 2) which character size it has to be so your scanner(s) can read the result of your printer(s)

This way you are able to generate barcodes in all software under your OS, not only LO Base. Also you are completely free to add readable elements to the same label by switching to a human readable typeface.

edit flag offensive delete link more
0

answered 2017-10-23 21:29:50 +0100

Ratslinger gravatar image

updated 2017-10-25 02:41:29 +0100

How to do this depends a lot upon what you know and how you want this to be actually done.

Are you going to print this using Report Builder or Writer or even something else? Do you want this to print immediately by, let's say, pressing a button on the form? Are you knowledgable in programming macros?

You can add a boolean field to the record for print selection. Then create a query to select all records with this field ON and use that for wherever the printing will occur. After printing, the flag must be cleared.

Instead of setting a new field, possibly use a table filer record to store the data for this ID & base the query upon that.

In a macro, the button could activate the writing of this data to a temp file which is passed on to the printing program and the process started by the macro.

There are probably other possibilities but again it depends upon just how you want it to work and your abilities to complete this, especially concerning macro coding.

Edit:

Having presented multiple ways in my answer to print, it is not clear why you posted the comment.

Just to be clear, printing directly from the form would require you to create a macro. Since you state you don't have any macro experience, the next easiest way is to print based on a parameter input for a query. The query is used as input to Report Builder (and again no mention of how you actually wanted to print even after asking in answer).

The report on the sample is simply printing the bar code field. There is no specific format since the label type and such are determined by you. To run the demo, there have been two records entered into the table - ID = 0 & ID = 1. In the Reports section, double click on BarcodeLabel. A Parameter Input dialog will pop up. In the Value field, enter 0 or 1 (record ID to select). On selecting OK button (Enter will do) the "Label" will pop up ready to be printed.

All of this is in the LO Base documentation found here.

Sample: BarcodePrintSample.odb

I did forget to mention - the odb does not carry the special bar code font with it. So first edit the Report and chage the field containing the bar code to use the font you installed on your system. The same can be said of the form I have on the sample.

Edit:

To avoid possible confusion, this next sample is the same as the first except where bar codes appear in the first, this one displays actual text.

Sample 2 - BarcodePrintSample (copy).odb

edit flag offensive delete link more

Comments

Without the ability to write the code (which you need to understand in order to make future modifications) printing immediately from a button can't be done.

I believe you first task would actually get LO to print a bar code label with fictitious data. I believe you will need to use an extension or special character set to do so. This is not a built in function.

Ratslinger gravatar imageRatslinger ( 2017-10-23 22:36:31 +0100 )edit

Here is a possible extension - click here.

Another - click here.

Ratslinger gravatar imageRatslinger ( 2017-10-23 22:39:04 +0100 )edit

Thank you all for your suggestions/ideas.

I have managed to download free barcode fonts and I am able to see them in the base form. I still need to print just the barcode for the record being displayed on screen. Any ideas on how to do this?

Many thanks

nd08 gravatar imagend08 ( 2017-10-24 21:16:32 +0100 )edit
0

answered 2018-05-11 11:15:31 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

There are two distinct jobs: 1. Create a barcode label based on some info 2. Print that label

SUB all_in_one()
    DIM sText AS STRING
    DIM oDoc AS OBJECT
    sText = "12345678"
    oDoc = CreateADoc()
    PrintTextInDoc(sText, oDoc)
    PrintDocToPrinter(oDoc)
    oDoc.close(False)'Do not save it
END SUB

REM create here the label
SUB PrintTextInDoc(sText AS STRING, oDoc AS OBJECT)
    DIM oNewDocVC AS OBJECT
    oNewDocVC = oDoc.CurrentController.getViewCursor    'Create View Cursor for this document
    'HERE you can change the font to some barcodefont if you want
    'Or make the barcode font the default font...

    '"Poke" the text to document 
    oNewDocVC.String = sText
END SUB

FUNCTION CreateADoc() AS OBJECT
    Dim FileProperties(0) As New com.sun.star.beans.PropertyValue
    DIM oDoc AS OBJECT
    FileProperties(0).Name = "Hidden"
    FileProperties(0).Value = FALSE 'True to create a hidden doc
    'load a doc with barcode font as default font
    'defaultdoc = "C:\mypathtodefaults\barcode.odt"
    'sURLofDOC = ConvertToURL(defaultdoc)
    'oDoc = starDesktop.loadComponentFromURL(sURLofDOC, "_blank", 0, FileProperties())
    'OR load an empty doc
    oDoc = starDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, FileProperties())
    'Return oDoc
    CreateADoc = oDoc
END FUNCTION

SUB PrintDocToPrinter(oDoc AS OBJECT)
    Dim printopts(0) As New com.sun.star.beans.PropertyValue
    printopts(0).Name = "Wait"
    printopts(0).Value = True
    'Will print directly to default printer
    oDoc.print(printopts)
END SUB
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

3 followers

Stats

Asked: 2017-10-23 20:29:03 +0100

Seen: 545 times

Last updated: May 11 '18