We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mail Merge & Print Word DOC Documents to Printer Command Language PCL or PostScript PS Files using C# .NET

Hi,

I am currently evaluating Aspose.Words for .NET and I would like to thank you for bringing such a useful tool to the market It appears to meet all of our requirements with the exception of the printing speed.

I have been tasked with performing a mail merge and generating one PCL file for each instance of the data that has been merged. On a daily basis we will be generating about 100,000 PCL files.

The current solution I have is based upon an Excel Macro. The macro iterates through a datasource, and prints the preview of the record to file. The print driver is for a PCL printer which I how I obtain the PCL. With this approach I am able to generate 11,000 files per hour.

I attemped to translate this task to .NET using Aspose.Words and I was very impressed with the speed at which Aspose.Words could merge and save *.doc files to disk - it was much faster than what I anticipated. However, when I tried to print each document using "Print To File", I was only able to generate 3,000 files per hour.

I also tried the .NET Interop assemblies from Microsoft and was able to achieve 5,000 files per hour.

I really like the DataSource options in Aspose.Words and the fact that I don't have to install Word on the server, however I really need to the printing speed to get closer to what the VB macro can deliver. Can you help me with a solution?

Hi Craig,

Thanks for your interest in Aspose.Words.

Printing time mainly depends on the size and complexity of the documents you are printing . Are you able to attach a typical example document here for testing?

I have noticed from another thread that you may also be able to increase printing speed by multi threading, if this is applicable you may want to give it a try and see how much increase in speed you get. Please see the code below.

DateTime start = DateTime.Now;<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

// Get file names of document, which should be printed.

string[] docNames = Directory.GetFiles(@"Test001\", "*.docx");

List<Thread> threads = new List<Thread>();

// Print all documents.

foreach (string name in docNames)

{

Document doc = new Document(name);

PrintHelper helper = new PrintHelper(doc);

Thread thread = new Thread(helper.Print);

threads.Add(thread);

thread.Start();

}

Console.WriteLine("printing: {0} seconds",(DateTime.Now - start).TotalSeconds);

// Wait until everything's finished.

foreach (Thread thread in threads)

thread.Join();

Console.WriteLine("Finished: {0} seconds", (DateTime.Now - start).TotalSeconds);

private class PrintHelper

{

public PrintHelper(Document document)

{

mDocument = document;

}

public void Print()

{

Console.WriteLine("start printing");

PrinterSettings printerSettings = new PrinterSettings();

printerSettings.PrinterName = @"\\192.168.0.4\hp LaserJet 1010 Series Driver";

mDocument.Print(printerSettings);

Console.WriteLine("end printing");

}

private readonly Document mDocument;

}

Thanks,

Hi Adam,

Thank you for your quick reply to my enquiry. Unfortunately I am not able to supply you a copy of the one page letter that I am using for performancing testing, however I received the same comparison of performance with the multi-document print sample provided by Aspose.

I understand the complexity vs print time trade-off but my question was related to the performance comparison of printing the same document via three difference approaches: VB Macro; C# via Office Automation; and C# via Aspose.Words. Although Aspose.Words appears to be the fastest for generating and saving multiple Word documents, it was the slowest when printing these documents using "Print to File".

Threading maybe an option for me but I would appreciate either native support for PCL, or more performant printing in future releases.

Best regards,
Craig.

Hi Craig,

Thanks for this additional information. Yes that sounds understandable, your request has been logged in full and we will look into improving printing performance in a future version. We will keep you informed of any developments (through replies to this thread). You can subscribe to this thread to recieve an e-mail notification of any developments.

If you have any further queries, please feel free to ask.

Thanks,

Hi Adam,

Thank you for taking on board my feedback. I look forward to evaluating future updates of the product.

Best regards,
Craig.

The issues you have found earlier (filed as WORDSNET-3798) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi Craig,


Just to let you know that in the next version of Aspose.Words due for release in the next week or so, we have included a new save format to render a document directly to PostScript. I hope this will help you increase your printing time. As always after testing we appreciate any feedback you might have so we look forward to hearing from you.

You will be notified as soon as the release is available.

Cheers,

The issues you have found earlier (filed as WORDSNET-3995) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(36)

@cmunday,

You can now use the latest versions of Aspose.Words for .NET and Aspose.Words for Java APIs to convert Word documents directly to PostScript (PS) and Printer Command Language (PCL) file formats.

For example, please check the following C# code to set whether or not to rasterize complex elements before saving to PCL:

Document doc = new Document("Rendering.docx");

PclSaveOptions saveOptions = new PclSaveOptions
{
    SaveFormat = SaveFormat.Pcl,
    RasterizeTransformedElements = true
};

doc.Save("PclSaveOptions.RasterizeElements.pcl", saveOptions);

The PclSaveOptions Class can be used to specify additional options when saving a Word document into the PCL format.

The following C# code example will create a book fold in the PostScript format.

Document doc = new Document("Paragraphs.docx");

// Configure both page setup and PsSaveOptions to create a book fold
foreach (Section s in doc.Sections)
{
    s.PageSetup.MultiplePages = MultiplePagesType.BookFoldPrinting;
}

PsSaveOptions saveOptions = new PsSaveOptions
{
    SaveFormat = SaveFormat.Ps,
    UseBookFoldPrintingSettings = true
};

// In order to make a booklet, we will need to print this document, stack the pages
// in the order they come out of the printer and then fold down the middle
doc.Save("PsSaveOptions.UseBookFoldPrintingSettings.ps", saveOptions);

The PsSaveOptions Class can be used to specify additional options when saving a Word document into the PostScript (PS) format.