Inserting a Barcode while merging documents

Last post 05-01-2012, 11:12 PM by imran.rafique. 15 replies.
Page 1 of 2 (16 items)   1 2 Next >
Sort Posts: Previous Next
  •  01-06-2010, 3:42 PM 215905

    Inserting a Barcode while merging documents .NET

    We are currently using 6.4.0.0 of Words to create order forms customized for each customer.  Can you point me to sample documentation on how to insert a bar code  into a mail merge field.

    Bill

     
  •  01-07-2010, 4:32 AM 215983 in reply to 215905

    Re: Inserting a Barcode while merging documents

    Attachment: Present (inaccessible)

    Hi

     

    Thanks for your request. I think, you can use MergeImaeField event handler to achieve this. Please see the following link for more information:

    http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/howto-insert-images-from-a-database.html

     

    To generate barcode you can use Aspose.Barcode:

    http://www.aspose.com/documentation/.net-components/aspose.barcode-for-.net/product-overview.html

     

    Here simple code example:

     

    // Open template.

    Document doc = new Document(@"Test001\in.doc");

     

    // Add MergeImageField event handler. We will generate barcode image usng it.

    doc.MailMerge.MergeImageField += MailMerge_InsertBarcode;

     

    // As a datasource, we will use object array.

    string[] names = {"Name", "Barcode"};

    object[] values = {"Alexey", "This is code of your barcode 123456798*"};

     

    // Execute mail merge.

    doc.MailMerge.Execute(names, values);

     

    // Save output document.

    doc.Save(@"Test001\out.doc");

     

    ===========================================================

     

    void MailMerge_InsertBarcode(object sender, Aspose.Words.Reporting.MergeImageFieldEventArgs e)

    {

        if(e.FieldName == "Barcode")

        {

            // Create barcode iamges using Aspose.Barcode.

            Aspose.BarCode.BarCodeBuilder bcBuilder = new Aspose.BarCode.BarCodeBuilder();

            bcBuilder.SymbologyType = Aspose.BarCode.Symbology.UPCA;

            bcBuilder.CodeLocation = Aspose.BarCode.CodeLocation.None;

            bcBuilder.CodeText = e.FieldValue.ToString();

           

            // Set image,which will be inserted into the document (in our case it is barcode).

            e.Image = bcBuilder.GenerateBarCodeImage();

        }

    }

     

    I also attached input and output documents. Also Barcode demo could be useful for you:

    http://www.aspose.com/demos/.net-components/aspose.words/csharp/general/barcode.aspx

     

    Hope this helps.

     

    Best regards.


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  01-07-2010, 10:35 AM 216047 in reply to 215983

    Re: Inserting a Barcode while merging documents .NET

    Thanks for the quick response.

    This look straight forward.

    Bill

     
  •  01-14-2010, 1:42 PM 217201 in reply to 215983

    Re: Inserting a Barcode while merging documents .NET

    I have since found out that I will be exporting a list of Persons with addresses to a Pitney-Bowes software.  That software will process those address and send them back out with a tray number and an integer representing the barcode for each person.  I will update my database with these two data elements so that I can print the mailing documents in tray order and with the barcode.

    The barcode font is provided by Pitney-Bowes called uspsplanet font.  Manually you if you type the integer produced by the Pitney-Bowes into a word document and surround it with square brackets, highlight this text, and change the font to uspsplanet the barcode appears.

    Given this additional information, do I still need the Aspose Barcode?  Can the merge field be set to a particular font at design time of the mail merge template or at runtime?

    Bill

     

    Filed under: 3rd Party barcode
     
  •  01-14-2010, 2:37 PM 217207 in reply to 217201

    Re: Inserting a Barcode while merging documents

    Hi Bill,

     

    Thanks for your request. If you have barcode font, you can use it during MailMerge, just specify this font as font of the appropriate merge field. Please let me know in case of any issues.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  01-14-2010, 4:02 PM 217217 in reply to 217207

    Re: Inserting a Barcode while merging documents

    Two last clarifications:

    And the barcode and photos (which we also insert) will be preserve if we use the XPS print function?  And finally, what is the first version in which you implemented the print function.  It appears that our version 6.4 does not.

    Bill

     

     
  •  01-15-2010, 4:06 AM 217293 in reply to 217217

    Re: Inserting a Barcode while merging documents

    Hi

     

    Thanks for your request. Could you please attach your barcode font here for testing? I will check it on my side and provide you more information. Export documents or pages as XPS is supported starting from 6.5.0 version of Aspose.Words.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  01-15-2010, 3:45 PM 217401 in reply to 217293

    Re: Inserting a Barcode while merging documents

    Attachment: Present (inaccessible)

    Turns out the barcode works.  Just setting the font on the template for that field works.

    I have concern whether it will work when using your print function.  Attached are the fonts.

    Regarding the Words version see my post at:

    http://www.aspose.com/community/forums/thread/217290.aspx

    Thank you again for your time and interest.

     
  •  01-16-2010, 3:03 AM 217427 in reply to 217401

    Re: Inserting a Barcode while merging documents

    Hi

     

    Thank you for additional information. I tried converting a Word document with barcode, which uses the fonts, you attached and an exception occurs while saving to XPS. I will notify you as soon as this problem is resolved.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  01-17-2010, 4:54 PM 217482 in reply to 217427

    Re: Inserting a Barcode while merging documents .NET

    I forgot one small detail.  The barcorde is represented textually as an integer up to 12 digits enclosed by square brackets.

    When I created the merge field I put the [ and ] in the text before and after respectfully.  When you set the mergefield and its enclosing brackets to the barcode font, it works.  Again, I have no way of knowing if it would work when printing from within Aspose.

    Bill

     
  •  01-18-2010, 4:51 AM 217545 in reply to 217482

    Re: Inserting a Barcode while merging documents

    Hi

     

    Thank you for additional information. You can attach sample template here for testing. I will check how it goes on my side.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  01-18-2010, 10:34 AM 217599 in reply to 217545

    Re: Inserting a Barcode while merging documents .NET

    Attachment: Present (inaccessible)

    Attached is the template:  Currently I have the PitneyBowlesRegular as the font of the Barcode merge field on the template.  I sent an earlier reply with the fonts attached.

     

     
  •  01-19-2010, 3:12 AM 217698 in reply to 217599

    Re: Inserting a Barcode while merging documents

    Attachment: Present (inaccessible)

    Hi

     

    Thank you for additional information. Printing works fine with barcode. I used the following code for testing:

     

    Document doc = new Document(@"Test001\in.doc");

    doc.MailMerge.Execute(new string[] { "BarCode" }, new object[] { 123456789012 });

    PrinterSettings settings = new PrinterSettings();

    settings.PrinterName = "Microsoft Office Document Image Writer";

    settings.PrintToFile = true;

    settings.PrintFileName = @"Test001\out.tif";

    doc.Print(settings);

     

    I attached the output TIF file.

     

    Best regards,


    Andrey Noskov
    Developer/Technical Support
    Aspose Auckland Team
     
  •  07-11-2010, 3:54 AM 248049 in reply to 215905

    Re: Inserting a Barcode while merging documents

    The issues you have found earlier (filed as 13544) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
    (20)
     
  •  05-01-2012, 5:57 PM 379448 in reply to 215983

    Re: Inserting a Barcode while merging documents

    Hi, Since this article was written, it appears that many namespace changes have taken place. For example, doc.MailMerge.MergeImageField does not exist. I am trying to do a mail merge on a 6 labels to a page Word document and insert a bar code based on an integer ID that is a MailMerge field inserted into the template, and this sample is the closest thing I can find in your documents, but I am missing something. Any assistance much appreciated. Thanks.
     
Page 1 of 2 (16 items)   1 2 Next >
View as RSS news feed in XML