How to insert a barcode into the lower continuum

62 Views Asked by At

I have a barcode creation code and the footer

BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567890");

Stream ms = new MemoryStream();
generator.Save(ms, BarCodeImageFormat.Png);

Aspose.Words.Document doc = new Aspose.Words.Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertImage(ms,
    RelativeHorizontalPosition.Margin,
    0,
    RelativeVerticalPosition.Margin,
    400,
    200,
    100,
    WrapType.Square);

There are questions

  1. How to create a right footer, now it is being created on the left

Now the barcode is inserted in an arbitrary place.I use aspose.words.

1

There are 1 best solutions below

5
Alexey Noskov On BEST ANSWER

You can use DocumentBuilder.MoveToHeaderFooter to move cursor into the footer and then use ParagraphAlignment.Right to place barcode at right. See the following code:

BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "1234567890");
Stream ms = new MemoryStream();
generator.Save(ms, BarCodeImageFormat.Png);

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Move DocumentBuilder into the footer.
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
builder.InsertImage(ms);

doc.Save(@"C:\Temp\out.docx");