# Adding an Image at a specific place on an existing image

I have created the following PDF: Basically an image, with a description underneath and a space to take some personal notes:

m = Import[
"https://images.pexels.com/photos/36455/rose-red-flower-victor-\
hugo.jpg?cs=srgb&dl=flora-floral-flower-36455.jpg&fm=jpg"];

exportIm =
Panel[Style[
Grid[{{im,
SpanFromLeft}, {TextCell[
Row[{"balabalaablabalb balabalbalbalba"}],
TextJustification -> 1, Hyphenation -> False],
SpanFromLeft}, {}, {"Notes: "}},
Frame -> {{False, False}, {True, True, True, False}, {False}},
BaseStyle -> ImageSizeMultipliers -> 1], 7,
FontFamily -> "Helvetica", Background -> White],
Background -> White, ImageSize -> {210, 227}*2]

Export["test.pdf", exportIm]


Now I would like to add a QR code to the bottom right of the PDF (which will eventually link to the image on the web).

I now that I can create a QR code...

BarcodeImage["123456789", "QR"]


... but I don't know how to include it into the PDF. Do you know how ?

You could use a few options here, but your best bet is to just use the grid system you already have with Item, to specify the alignment for the barcode manually. Specifically, we'll do Item[BarcodeImage["1"], Alignment->Right] to align to the right edge, coupled with a SpanFromLeft to actually place other content in the column (otherwise it doesn't work correctly - I'm not actually certain why that is).

exportIm = Panel[Style[Grid[{
{m, SpanFromLeft},
{TextCell[Row[{"balabalaablabalb balabalbalbalba"}],
TextJustification -> 1, Hyphenation -> False], SpanFromLeft},
{},
{"Notes: "},
{SpanFromLeft,
Item[BarcodeImage["123456789", "QR"], Alignment -> Right]}
}, Frame -> {{False, False}, {True, True, True, False}, {False}},
BaseStyle -> ImageSizeMultipliers -> 1], 7,
FontFamily -> "Helvetica", Background -> White],
Background -> White, ImageSize -> {210, 227}*2]


You can modify the third argument to BarcodeImage to choose the size of the QR code.

Other options include Overlay and ImageCompose. These have various issues though - Overlay is a little hard to specify location, and ImageCompose requires Rasterizeing of both inputs before working.

• Thank you very much for this great answer ! However, the barcode is not placed at the very bottom of the page. When you export it as pdf you can see that the barcode is below the "Notes" text on the left, but not on the bottom of the page. Do you see an option of how to achieve this ? – james Sep 6 '18 at 6:42
• Have you seen my previous comment ? – james Sep 6 '18 at 19:58
• mathematica.stackexchange.com/questions/181370/… – james Sep 6 '18 at 21:53
• Ah, sorry, I missed this, good idea adding a separate question. – Carl Lange Sep 6 '18 at 22:46