Free Support Forum - aspose.com

Different barcode on each page

Hi,


We are trying to add some content to word document with different barcode on each page. We used this sample http://goo.gl/v0xXAy and we created different barcode on each page but when we want add some content we have some problems…
Document generates same barcode during content… New barcode generates with the new page when content ends previous page. How can we add content in that sample please help.
I will add some screenshots

Hi Volkswagen,

Can you please share your code and input document to reproduce the issue?

Best Regards,

Hi,


I attached sample code. I tried to explation our problem in code comments.

Thank you

Hi Volkswagen,

The reason is that you are adding all contents in a single section. We are working on a workaround for your case and will share it with you soon.

Best Regards,

Thank you for your interest. This is very important for us. We are waiting for any solution for single section usage.

Hi Volkswagen,

We will let you know once the example is complete.

Best Regards,

Hi Volkswagen,

Sorry for the delay. You can use the following code to display different barcode for each page according to your requirement.

// Create a blank documenet.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

for (int i = 0; i < 100; i++)

{

builder.Write("comment");

builder.Writeln();

}

// The number of pages the document should have.

int numPages = doc.PageCount; ;

// Move the DocumentBuilder cursor into the primary footer.

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

Field field = null;

for (int i = 1; i <= numPages; i++)

{

field = builder.InsertField(@"IF ");

builder.MoveTo(field.Separator);

builder.InsertField("PAGE");

builder.Write(" = " + i);

builder.Write(" \"");

builder.InsertImage("./../../Image/Barcode" + i + ".jpg");

builder.Write(" \"");

builder.Write(" \"");

}

//builder.Write(" \"This is page 2\"");

builder.Write("\"");

field.Update();

doc.Save("Document out.docx");

Best Regards,