Ghini / ghini.desktop

plant collections manager (desktop version)
http://ghini.github.io/
GNU General Public License v2.0
24 stars 14 forks source link

Generating labels for an engraver #129

Closed mfrasca closed 8 years ago

mfrasca commented 8 years ago

From @RoDuth on December 20, 2015 6:20

Have been using printed labels for some time now and are looking to go to engraved plastic labels very soon. I have been speaking to the local engravers and would prefer to be able to use the reporting system to generate a file the engraver can use directly with his CNC engraver. I can proof it before sending it off to make sure everything looks right. No risk of human error. I can design the label styles I want and make the choice myself as to which accession gets which style etc. etc. Have been playing with the XSL formatter and the sample templates but have run into a couple of issues.

  1. The engravers have asked for an .eps file so I used pdftops with the -eps switch to convert from the .pdf output of the xsl formatter. Now he says he needs the fonts to be paths (vectors). I'm sure there is some way to get GIMP to do the paths part but cant work it out (haven't used GIMP in years) and keep thinking there must be an easier way with less manual steps.
  2. He wants it to be 1 label at a time, not sure whether this means per file or page within the file?? (do .eps files have pages?) The extent of my playing with the style sheet is just swapping things around so I don't really know what I'm doing here.
  3. Due to the fact the style sheets use the ABCD FullScientificNameString I have no control of the formatting in regards to italics etc.

Would be nice to power our own CNC engraver straight from the database one day. (open source hardware maybe?)

Any ideas?

Copied from original issue: Bauble/bauble.classic#227

mfrasca commented 8 years ago

@HubelSB aquí se habla de hardware “our own CNC engraver”, me parece le pueda interesar! :fire: http://www.instructables.com/id/Arduino-Laser-Engraver/ ?

mfrasca commented 8 years ago

From @RoDuth on December 21, 2015 7:34

That's it!! Been toying with the idea of an Arduino project for a while now...

mfrasca commented 8 years ago

an other idea is that eps files are just text files, so if we would have just a couple of valid files for your CNC engravers, producing just any label of the correct size and with the right fonts, then we might convert these files into a mako template. not a big deal, this last part.

mfrasca commented 8 years ago

From @RoDuth on December 23, 2015 9:28

Will this work? His concern was that they needed to be vector files not text files. (i.e. you needed to outline the text with paths to get a path for the engraver to follow). After the silly season is over I'll go speak to the engraver and get a better idea of exactly what he wants and the formats that he can work with. (didn't know mako could generate .eps files)

mfrasca commented 8 years ago

»PostScript (PS) is a computer language for creating vector graphics« wikipedia, so I guess yes it will work. your engraver will probably tell you that the eps files you passed him had raster fonts (he already told you »he needs the fonts to be paths«.) it's quite some time since I last played with postscript programs, I kind of recall there was a fonts definition part, a page definition part, then the placing of (groups of) letters on the page. can you put here one of your labels (in eps format, zipped), that your engraver refused?

mfrasca commented 8 years ago

From @RoDuth on January 15, 2016 10:28

@mfrasca see the attached example of what the engraver is looking for. They said it was hard to get their system to export an example of what they would like as input but this would be a format that they could take. The finished size is 120x70mm which I think is demarked by the red lines. (in case you are wondering NATIVE CQCB is the "Label distribution" field of the species) Label.pdf

mfrasca commented 8 years ago

nope. I can use a .ps file (it's an ascii thing and it is a program), I cannot look inside of a pdf (binary) file. if it is not possible for them, then too bad, but you should insist in PostScript format. or I should go back to studying postscript myself and produce one with the characteristics of the pdf you posted here. and with a vectorial font, which is what your engraver says they need.

mfrasca commented 8 years ago

From @RoDuth on January 15, 2016 23:38

Dang blasted proprietary systems! From what I gather they would prefer the post script as the input anyway. I just think that pdf was all they could generate as an output from their software.

I'll attach the .eps file I generated from a .pdf using pdftops -eps that they said was close to being usable, except for the fact that they only wanted 1 label at a time and the vector fonts. I generated the .pdf from an xsl template which I'll also add to the zip file. Don't laugh at my butchery of the original labels template!!

I just want to be able to generate a report that I can proof then send to the printers so they can print... Sounds so simple! So frustrating!

I'll speak to them again about the formats and see if they can give us something a little more usable.

Labels.zip

mfrasca commented 8 years ago

From @RoDuth on January 15, 2016 23:43

Just a thought but what about putting their .pdf through pdftops -eps? Surely that will work?

EPSLabel.zip

mfrasca commented 8 years ago

is this note relevant?

mfrasca commented 8 years ago

well, I think it's a bit complicated but doable. if I print from libreoffice a document that contains nothing more than all the letters you might want to ever use, using as font LiberationSerif, I get a ps where the glyphs are defined and numbered. ... then you have sequences of:

162 208 moveto
<0102030405060708090A0B0C0D0E0F101112131415161718191A>
[23 25 22 25 23 15 26 25 14 13 26 13 39 24 26 25 25 17 19 14 26 24 37 25 24 0]
xshow

where you first move to 162, 208, then show the gliphs 01-1A which have the widths as specified in the second parameter. it's almost RPN, like old HP calculators.

mfrasca commented 8 years ago

can you ask your engraver if they would be able to print this one? test.zip (if you do not like the font... we choose it later, let's first see if this is acceptable to the engraver.) (the postscript code here looks quite different than the eps you posted before)

mfrasca commented 8 years ago

pfffffffff you also want bold and italic! :scream: I don't know... it is possible to produce it programmatically directly from Mako, but it's quite a bit of preparation almost by hand. maybe there are tools to do this easier. however, once programmed, it would be very lightweight, no more dependencies than Mako itself. but one font.


having the sample, with your desired vector font, page size correctly set, and some text already in place, the task would be trivial. ... and no, transforming a pdf into postscript would not transform the raster pdf into a vector ps.

mfrasca commented 8 years ago

From @RoDuth on January 16, 2016 4:11

Of course!! Don't want to make things too easy :smile:

Will speak to them early next week. Just tried to open your file with everything I have here that will take .ps and all I get is a blank page with this at the top?: screenshot from 2016-01-16 14 03 41 Am I doing something wrong?

mfrasca commented 8 years ago

did you expect me to produce already a real label ? :open_mouth: before tomorrow, it might be, but at the moment I do not even know how to tell libreoffice to produce a custom sized page. and you should also ask your engraver if the 120×70 is the black frame or the red one, or if they need some extra millimetres margin outside the 120×70.

mfrasca commented 8 years ago

still not sure about page size, nor of the printed effect, nor whether the position of the parts are to your liking, but this does sort of print labels for the species in your selection. rough.zip

mfrasca commented 8 years ago

Mako is really powerful. very nice choice @brettatoms .

mfrasca commented 8 years ago

From @RoDuth on January 17, 2016 4:56

Wow looks great! Just had a go with the template. A few minor issues (e.g. doesn't do the infraspecific parts) but before anything, let me contact the engravers next week and make sure that it IS the sort of file they are looking for first.

Out of curiosity, in your opinion, Mako is better than the xsl formatter? I have not used the Mako formatter. Guess I should learn :fearful:

mfrasca commented 8 years ago

I'm on the opposite position: I never used the XSL formatter. I guess it's the correct tool for producing xml, while Mako looks to me fine for things like csv, (sloppy) html, and PostScript. without Mako already in place, I would have chosen Jinja2, just because I had used it elsewhere and it is probably more main-stream.

mfrasca commented 8 years ago

From @brettatoms on January 17, 2016 13:52

@mfrasca That's a good idea to use mako to generate the postscript. When I chose Mako ~10 years ago Jinja2 hadn't yet become the "winner" of the python templating languages. Today I use Jinja2 everywhere. Mostly because its bundled with Flask.

@RoDuth The reason for XSL is because it has a component called XSL-FO which is kind of like CSS but for paged and printed media. It's great for generating pixel perfect PDFs but it's extremely complicated and has a high learning curve. I probably would have reached for XSL first for this task as well but @mfrasca made a good call doing it this way with mako. Any day I can avoid using XSL is a good day. ;)

mfrasca commented 8 years ago

use #140