Positionned Frame in Paragraph Style

Hi,

One of our clients has sent us a Word file which uses a style with a positioned frame (see attachment file, blue left-hand text using the x-marginale style).

However, this style is causing us trouble and so we would like to remove the positioned frame settings from the style. Can this be done with Aspose?

Thanks,

Christophe

Hi Christophe,

Thanks for your inquiry. Could you please attach your expected document here for our reference? We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Also, please try using the following code if it helps:

Document doc = new Document(MyDir + @"ProblemDateiFelderMinimized.docx");
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
doc.Save(MyDir + @"16.3.0.docx");

Best regards,

Hi Awais,

Please find attached the document like we would want to have it after having been processed by Aspose. What I simply did was to remove the positioned frame from the paragraph style in Word.

I’m afraid that replacing the x_marginalie style with another style like suggested is not an option because after we have finished editing a client’s file, we have to send it back with formatting as close as possible to the original. So what we would do is adding the positioned frame setting back to the x_marginalie style.

Thanks,

Christophe

Hi Christophe,

Thanks for your inquiry. Please try using the following code:

Document doc = new Document(MyDir + @"ProblemDateiFelderMinimized.docx");
Paragraph para = doc.FirstSection.Body.FirstParagraph;
Style style = para.ParagraphFormat.Style; 
style.ParagraphFormat.ClearFormatting();
style.ParagraphFormat.Alignment = ParagraphAlignment.Right;
style.ParagraphFormat.SpaceBefore = 3;
style.BaseStyleName = "Normal";
style.NextParagraphStyleName = "x_text";
Paragraph newPara = new Paragraph(doc);
newPara.Runs.Add(para.Runs[0].Clone(true));
newPara.ParagraphFormat.Style = style;
para.ParentNode.InsertAfter(newPara, para);
para.Remove();
doc.Save(MyDir + @"16.3.0.docx");

Hope, this helps.

Best regards,

Hi Awais,

Your code assumes that we know beforehand which paragraphs use a positioned frame in the paragraph style. But this isn’t the case. So we would need to be able to find via code which paragraphs and styles use a positioned frame setting.

Is there an API somewhere for this?

Thanks,

Christophe

Hi Christophe,

Thanks for your inquiry. Unfortunately, currently text frames are not fully supported by Aspose.Words and you cannot get/change position of a text frame by using Aspose.Words. A request for this feature has been added. For reference, the ID of this issue is WORDSNET-13521. You will be notified as soon as it is available. Sorry for inconvenience.

Best regards,

Ok thanks Awais!

The issues you have found earlier (filed as WORDSNET-13521) have been fixed in this Aspose.Words for .NET 17.1.0 update and this Aspose.Words for Java 17.1.0 update.

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