Free Support Forum - aspose.com

Automatically generate a unwanted newline in Aspose

Hi,

I have faced a problem that the program generated a unwanted newline for me. Attached with the problem and the generated XML. Could anyone of you provide a solution on it?

Regards,
Ken Wan

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Please attach your source document for testing. I will try to reproduce the problem and provide you more information.

Best regards.

Hi

I’m sorry that I missed the word document.

Regards,
Ken Wan

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Unfortunately, I cannot see any problem here. It seems you just put empty string into one of merge fields. Please try to convert the document without performing mail merge before (just for testing).

Also, please make sure you are using the latest version of Apose.Words and Aspose.Pdf.

The latest version of Aspose.Words supports also direct conversion to PDF (Without using Aspose.Pdf). You can try using this method in your project. Please see the following link to learn more:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.document.savetopdf_overloads.html

Best regards.

Hi,

Is that the new version is backward compatitable and won’t cause any problem if I upgrade it?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Which version of Aspose.Words and Aspose.Pdf do you use now?

Just for note, I also cannot see problem on screenshots you provided. Have you tried to convert your template to PDF (without performing mail merge)?

You can download and try new versions from here:

http://www.aspose.com/community/files/51/file-format-components/aspose.words-for-.net-and-java/category1188.aspx

http://www.aspose.com/community/files/51/file-format-components/aspose.pdf-for-.net-and-java/category1184.aspx

Best regards.

Hi,

The problem still existed even I don’t have mail merge function.

And how can I check the version of aspose using?

Regards,
Ken wan

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

To check versions of libraries, right click on the dll, select Properties from the context menu, then select Version tab. You will see File version.

Unfortunately, I still cannot see any problem on your screenshot. Where is this new line (Page, line)? Please attach also the output PDF. I will try to compare it with original Word document.

Best regards.

Hi

My Version is 5.3.0.0.

The new line means, you can see there is a enter generated after the word “重要部份”. In the word template, it doesn’t exist. But it exists when I convert it to PDF.

Regards,
Ken Wan

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Now I see the problem. However, as I see the latest version of Aspose.Words produce correct XML, here is snippet:

<Text MarginLeft="24" IsWidowOrphanControlEnabled="false" IsSpaced="true" Alignment="Justify">

<TabStops>

<TabStop Position="24" />

<TabStop Position="551.15" />

</TabStops>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">聲明書</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">《壽險轉保守則》下稱《守則》及保險業監督根據《保險公司條例》指明的「最低限度規定」下稱「最低限度規定」</Segment>

<Segment IsUnicode="true" FontName="新細明體" IsTrueTypeFontBold="true" FontSize="12">重要部分</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">但並不是投保申請書建議書其中一部分。填寫本《</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">聲明書</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">》前,請先詳閱</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12">註釋</Segment>

<Segment IsUnicode="true" FontName="新細明體" FontSize="12"></Segment>

</Text>

So, please try using the latest versions of Aspose.Words (6.1.0) an Aspose.Pdf (3.9.0).

http://www.aspose.com/community/files/51/file-format-components/aspose.words-for-.net-and-java/category1188.aspx

http://www.aspose.com/community/files/51/file-format-components/aspose.pdf-for-.net-and-java/category1184.aspx

There should not be any problems with upgrade. Please let me know in case of any issues.

Best regards.

What is the meaning of correct XML? is that you can use bindXML and generate correct PDF?

It means that there is no line breaks in the intermediate XML produced by Aspose.Words. So, if problem still occurs with the latest versions of Aspose.Words and Aspose.Pdf, then problem should be fixed on Aspose.Pdf side. Have you tried to convert the document using the latest versions?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Best regards.

Hi,

When I use the latest version to word to XML using the folllowing code:

Document doc = new Document(“C:\Documents and Settings\ken.wan\My Documents\Visual Studio 2005\Projects\HelloPdf\HelloPdf\CPD_Form_C.doc”);

doc.Save(“MyDocument.xml”, SaveFormat.AsposePdf);

Error with the following faced:

Unhandled Exception: System.InvalidOperationException: Image file cannot be writ
ten to disk. When saving the document to a stream either PdfExportImagesFolder s
hould be specified or custom streams should be provided via PdfExportImageSaving
event handler. Please see documentation for details.

And I have tried to use the saveToPdf function directly in new version of Aspose word. The encoding seems wrong. Please see the attached file

Regards,
Ken Wan

Hi,

Supplementary for the above post.Now I have fixed the unhandled Exception part. But the generated PDF still existed “the newline problem”. So could you mind to help to investigate? I have attached with the generated PDF and xml file for your reference.

And still, I can’t solve the encoding problem using the saveToPdf.

Regards,
Ken Wan

Hi,

I am a developer of aspose pdf team.
The newline problem has been logged as PDFNET-7588 in our defect tracking system. We will resolve it in our future release. Sorry for inconvenience.

Best regards.

Hi,

Thank you for your help to trace the problem.

So can you provide any temporary solution to us?

Regards,
Ken Wan

Hi,

As a workaround, please don’t make the text ‘重要部分’ in bold. I have attached the modified document. It works fine. Thanks.

Best regards.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Regarding problem with SaveToPdf method, please make sure that font “PMingLiU” is installed on your PC.

Best regards,

Hi,

It is sorry that we have bargain with our client but unfortunately these one cannot be modified as not bold. So is there any other solution? And I’m going to try to use Aspose Word 6.2.NET versoin. Will come up a result on it soon. But is this version fixed this problem? Can I know when will this issue be fixed?

And according to my windows folder, PMingLiu font should be installed already.

Regards,
Kin

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I can successfully convert your document to PDF using the latest version of Aspose.Words (6.2.0). If you need, I can send the result of conversion. (if so, please provide me your e-mail)

Regarding the problem with new line after “重要部分”, this issue should be fixed in Aspose.Pdf, not in Apsose.Words.

Best regards.