I am creating a PDF-file with GemBox in my .net project and I am wondering how to position the qr code in the top right corner.
With the code below, I am replacing variables in my word file and with the addition of the qr code section, the qr code is created on a separate page instead on the same page.
So my question is, how to place the qr code on the same page and how to position it in the top right corner.
I hope someone can help :)
var qrCodeValue = JsonConvert.SerializeObject(new
{
FirstName = data.firstName,
LastName = data.lastName,
CreationDate = data.documentCreationDate
});
var qrCodeField = new Field(document, FieldType.DisplayBarcode, $"{qrCodeValue} QR");
document.Sections.Add(new Section(document, new Paragraph(document, qrCodeField)));
document.Content.Replace("%FirstName%", data.firstName);
document.Content.Replace("%LastName%", data.lastName);
You need to add the QR code to an existing section.
Also, to position it in the top right corner you could insert the right aligned
Paragraph
at the beginning or in the document's header or insert a floatingTextBox
.Here are the examples for all three suggested approaches.
Insert into the body of an existing section
Insert into the header of an existing section
Insert with a floating textbox