0

I have started a small project to make sheets of (complex) labels in code by effectively merging first a pre-generated QR code (svg format) onto a single label, then this label onto a master sheet.

The merging is automated in Python and works.

But, the position of the QR in the single label is done by first editing a label to my needs in inkScape, then duplicating the result. This requires very specific parametres on the QR code source to succeed.

The QR generated starts like this. Note the width and height which I can of course extract.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="294" height="294" version="1.1" xmlns="http://www.w3.org/2000/svg">
   <desc>Zint Generated Symbol</desc>
   <g id="barcode" fill="#000000">
      <rect x="0" y="0" width="294" height="294" fill="#FFFFFF" />
      <rect x="0.00" y="0.00" width="98.00" height="14.00" />
      ..many more follows..

By designing in inkScape, I have found that I need to apply a transformation parameter to the barcode to insert into the label. Example for one example is transform="matrix(0.086, 0,0,0.086, 52, 100)"

This is all good, but how can I go from the 294 x 294 (or any other number) to achieve the same position on the label (correct transformation) - making me independent on a specific setting in Zint generator ? My desired end goal is that I can extract the size and control final size and x,y position as indicated here:

extract of label showing QR size and position

This way I can also small small adjustments in the script to fine tune position, without having to go back to inkScape.

I modify / merge the SVG files using Python and xml.etree.ElementTree. Could it be simpler / better to use a dedicated SVG module instead ?

The final merge of generated labels on the mastersheet is fairly trivial. Same problem but should be done only once and not change. I will be happy to answer questions in that relation if anyone is curious.

2
  • Are you asking how to generate a transformation matrix that puts an image of a given size at a certain position and size in the user coordinate system? Commented Jul 5 at 16:31
  • @TurePålsson I think that is probably what my question is: how to take a simple (or more complex) SVG file an insert into another at specific X,Y coordinate and scale to desired size.
    – MyICQ
    Commented Jul 6 at 22:48

0

Browse other questions tagged or ask your own question.