Line breaks when printing

First of all I’d just like to say how pleased we are with Aspose v6 - we’ve been waiting a long time for the printing facilities and it’s great to finally see it.
Having said that, we’ve got a small issue with Aspose 6 (both v6.1.0.0 and which is a bit annoying. We have a number of documents where line breaks in the document aren’t being printed - instead the text that should be on seperate lines prints all on the same line. The attached document (test1.doc) shows this problem - look at the name and address blocks on the first page. Then try printing the document and notice how the text is now formatted differently - some of the line breaks have been removed.
If it makes a difference, we’re using the following code to print:

DocumentBuilder mBuilder = new DocumentBuilder( mDocument );
PrinterSettings mSettings = new PrinterSettings();
mSettings.PrinterName = "HP Laserjet 4Si";
mSettings.Duplex = Duplex.Default;
mBuilder.PageSetup.FirstPageTray = PaperTray.LowerBin;
mBuilder.PageSetup.OtherPagesTray = PaperTray.LowerBin;
mBuilder.PageSetup.TopMargin = ConvertUtil.MillimeterToPoint( 8 );
mBuilder.PageSetup.BottomMargin= ConvertUtil.MillimeterToPoint( 8 );
mBuilder.PageSetup.LeftMargin = ConvertUtil.MillimeterToPoint( 8 );
mBuilder.PageSetup.RightMargin = ConvertUtil.MillimeterToPoint( 8 );
mBuilder.PageSetup.Gutter = ConvertUtil.MillimeterToPoint( 0 );
mBuilder.PageSetup.HeaderDistance = ConvertUtil.MillimeterToPoint( 10 );
mBuilder.PageSetup.FooterDistance = ConvertUtil.MillimeterToPoint( 10 );
mDocument.Print( mSettings );

I’d appreciate it if you could have a look and let me know if this is a bug with Aspose, and if so, an indication of when it is likely to be fixed.
Andrew Dancy
Lovetts plc

Thanks for your request. I managed to reproduce the problem on my side and create new issue #7665 in our defect database. I will notify you as soon as it is fixed.
It seems the problem occurs because some paragraphs contain SmartTags.
Best regards.

I’ve noticed before that Word has a habit of putting smart tags into documents in such a way that they appear to span Aspose node elements. Indeed we had a number of problems with Aspose where we were trying to replace bookmark text where the bookmark node had a Smart Tag inside it. This particular issue was fixed in - presumably our printing issue is similar to this.
I can think of two possible ways of working around our printing issue that may be worth implementing in a future version of Aspose. Firstly, MS Word has a method - RemoveSmartTags() which can be used to remove all smart tags from a document. We’ve used this in the past to get rid of troublesome smart tags. Unfortunately we can’t just use Aspose to find the smart tag node and remove it, as that seems to damage the surrounding nodes (unlike the MS Word method that seems to cleanly remove the tag). So one option would be an equivalent to the Word RemoveSmartTags() method we could run on any document before we do any processing, or a way of getting Aspose to do this automatically whenever you open a document.
Another option would be to have an option that sets smart tag behaviour in Aspose to how it was prior to (which is when I think smart tag support was added); so Aspose would just ignore smart tags completely when rendering, processing bookmarks, etc.
Andrew Dancy
Lovetts plc

Thanks for your inquiry. I created new feature request #7676 in our defect database, regarding this issue.
I also created workaround for you. Here is code that removes SmartTags from the document.

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


/// Removes all SmartTYag nodes from the docuemnt, preserving content
/// Input document
private void RemoveSmartTags(Document doc)
    // Get collection of SmartTags from the document
    NodeCollection nodes = doc.GetChildNodes(NodeType.SmartTag, true, true);
    // Loop while there is SmartTags in the document
    while (nodes.Count > 0)
/// Recursive part of RemoveSmartTags method
/// It is needed because SmartTag can contain another SmartTags
/// SmartTag that should be removed
private void RemoveSmartTagCore(SmartTag tag)
    // Get parent node of smartTag.
    // we should move all content from smatrTag to its parent to preserve documents content
    CompositeNode parent = tag.ParentNode;
    // Loop throuht all nodes inside smartTag and move its convent to parent node
    while (tag.HasChildNodes)
        if (tag.FirstChild.NodeType != NodeType.SmartTag)
            parent.InsertBefore(tag.FirstChild, tag);
    // Remove smartTag

Hope this helps.
Best regards.

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

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