Carriage Returns and Line feeds

Good Morning,

I am using vb.net for a project that hunts for fields in a word document and replace them with some user defined text (which can include carriage returns and line feeds) but these characters are not being included.

Back in 2007 the following question was posted: https://forum.aspose.com/t/131396&Subj=pdfcontenteditor.replacetext-with-text-that-includes-new-carriage-return-linefeed;;;;;&Ajax_CallBack=true

In which it was said that this wasn’t available in a form field, has this changed?

However, this isn’t actually the method we are using, our method is slightly different the crux being (oField being the field in question):

Dim oText As Run
Dim oParentpara As Paragraph
Dim m_oDoc As Aspose.Words.Document

On Error Resume Next
oParentpara = oField.ParentParagraph
oText = New Run(m_oDoc, sText.Replace(vbCrLf, vbCr))
CopyFormatting(oField.FieldStart.Font, oText.Font)
oText.Font.Hidden = False
oParentpara.ParagraphBreakFont.Hidden = False
If bBold Then oText.Font.Bold = True
If bStrikethrough Then oText.Font.StrikeThrough = True
oParentpara.InsertBefore(oText, oField.FieldStart)
oField.Delete()

So we are actually inserting before the field and then removing it. So… is there a way to keep the vbCRLf/vbLf/vbCr after the insert please?

Thank you,

Stan

Good Morning,

After some digging around and looking at a few other posts I’ve resolved this issue.

In the interests of assisting anyone else with the same issue here is my solution:

Aspose has it’s own control characters object: Aspose API References

So I did a replace of vbCrLf with Aspose.Words.ControlChar.LineBreak.


Hi Jeremy,


Thanks for your inquiry. It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,