Free Support Forum - aspose.com

Converting Word to PDF format

I have converted a Word document to PDF and the conversion is shifting sections of the Word document up so that the section appears on the previous page. The section is titled 'Background Information' on the document. You will notice that other sections are behaving the same.

I am using Aspose.pdf version 3.6.0.0, .NET 2.0, Windows XP with SP2, Word 2003 with SP2. The Word document enclosed is a VSTO document, so when it is loaded, it will state that it can't find a 'RunningReport.dll' assembly, so just ignore that please. I have attempted to include the pdf file, but it seems that I am only able to include one file. I will create onther post to upload the pdf file.

Does anyone have any ideas as to what is causes this issue?

Steve

Here is the pdf file

Dear Steve,

Currently we can’t make the text height exactly the same between Word and Pdf. As a workaround you can add a page break before the ‘Background Information’.

Sure, I can add a workaround to the issue, but my end users will have to add a page break not only to the 'Background Information' section , but to all sections before converting the word document to PDF. This means that our IT help desk will have to explain this workaround to about 300 people around the country whenever they call in complaining that the conversion isn't working. Not only that, but our workflow rules indicate that when a word document is converted into PDF, the pdf file cannot be recreated because programtically I make sure that the Word document can no longer ever be used anymore.

Is this just a temporary issue? Will there be a fix for this in a future version release? Do you have any other ideas for workarounds?

Steve

Dear Steve,

The line spacing in Word is quite complexed and we can’t make the pdf exactly as Word. This can’t be fixed in short time. As another workaround, you can put some objects into new page if you know some special property of the objects. As a example, the following code check the first table with one row and one cell and put it into a new page:

pdf.BindXML(@“D:\test\TestWord\input.xml”,null);

Aspose.Pdf.Section sec0 = pdf.Sections[0];
foreach(Aspose.Pdf.Paragraph para in sec0.Paragraphs)
{
if(para is Aspose.Pdf.Table)
{
Aspose.Pdf.Table table = para as Aspose.Pdf.Table;
if(table.Rows != null && table.Rows.Count == 1)
{
Aspose.Pdf.Row row0 = table.Rows[0];
if(row0.Cells != null && row0.Cells.Count == 1)
{
//make the table in a new page
table.IsFirstParagraph = true;
break;
}
}

pdf.Save(@“D:\test\testword\output.pdf”);

}
}
This code can make the “BACKGROUND INFORMATION” into new page.