Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Thu Mar 07, 2013 6:25 am

If I have a document with 500 pages I want go go through the pages and split into a new document each time a new bar code is located. I did this with crude word automation but think Spire.Doc can make this better (no copying to clipboard for one).

In the word automation I loop through the text looking for the barcode font (a 30f9 font). I tried FindAllPattern using \*[a-zA-Z0-9]+\*. This gets me very close because the barcode will always start and end with an *. However I would like to verify the text found has the barcode font.

Any suggestions on how to locate text using a specific font?
Thank You,

Posts: 7
Joined: Thu Mar 07, 2013 3:23 am

Fri Mar 08, 2013 10:26 am


Thanks for your inquiry.
I think the code(Linq) below can help you:
Code: Select all
doc.FindAllPattern(new Regex(@"*[a-zA-Z0-9]+*"))
    .Select(t => t.GetAsOneRange())
    .Where(r => r.CharacterFormat.FontName == "30f9")

It will find all barcode in your document, each of them is a Spire.Doc.Fields.TextRange object.

If you have any other problem about this issue, please tell us and send us (support@e-iceblue.com) your word document.

Best Regards,
Technical Support / Developer,
e-iceblue Support Team
User avatar

Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Tue Mar 12, 2013 10:48 am

Hello drpotts,

Do our previous code help you solve your problem?
Please give us a feedback on this issue at your early convenience. Thank you in advance!
If you have other any problem, please feel free to contact us.

Best regards,
E-iceblue support team
User avatar

Posts: 2284
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc