Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to insert a barcode into the lower continuum

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 two questions

  1. How to create a right footer, now it is being created on the left
    2)How to insert a barcode into the footer

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading