We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

One page was converted to two page!

I found a very strange phenomenon.when I download this attachment file but not open it with office software. when i run in below code,it will convert to two page.but when i open it with office software it will convert to one page.

the original size is10.4kb ,but when i open it with office software it will be 14.9kb

so you should run this code by not open it.I will supply you with the all fonts ,you shoul setup these fonts.



package aspose.words;

import com.aspose.words.Document;
import com.aspose.words.Field;
import com.aspose.words.FieldHyperlink;
import com.aspose.words.FieldType;
import com.aspose.words.License;

public class MainTest {

private final static String MyDir = "C:\\Users\\Lixp\\DeskTop\\";

@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
License license=new License();
license.setLicense(MyDir+"Aspose.Total.Java.lic");
Document wordDocument = new Document(MyDir + "oneppagetotwopage.docx");
wordDocument.acceptAllRevisions();
com.aspose.words.ImageSaveOptions imgSaveOptions = new com.aspose.words.ImageSaveOptions(
com.aspose.words.SaveFormat.JPEG);
imgSaveOptions.setPrettyFormat(true);
imgSaveOptions.setUseHighQualityRendering(false);
com.aspose.words.HtmlFixedSaveOptions htmlFixedSaveOptions = new com.aspose.words.HtmlFixedSaveOptions();
htmlFixedSaveOptions.setPrettyFormat(true);
htmlFixedSaveOptions.setExportEmbeddedCss(true);
htmlFixedSaveOptions.setExportEmbeddedFonts(true);
htmlFixedSaveOptions.setExportEmbeddedImages(true);
htmlFixedSaveOptions.setExportEmbeddedSvg(true);
htmlFixedSaveOptions.setWarningCallback(new com.aspose.words.IWarningCallback() {

@Override
public void warning(com.aspose.words.WarningInfo warningInfo) {
System.out.println(warningInfo.getDescription());
}
});
for (Field field : wordDocument.getRange().getFields()) {
if (field.getType() == FieldType.FIELD_HYPERLINK) {
FieldHyperlink hyperlink = (FieldHyperlink) field;
hyperlink.setTarget("_blank");
}
}

htmlFixedSaveOptions.setPageIndex(0);
htmlFixedSaveOptions.setPageCount(1);

wordDocument.save(MyDir + "Out.html", htmlFixedSaveOptions);
int pageCount = wordDocument.getPageCount();
for (int i = 0; i < pageCount; i++) {
if (i == 0) {

imgSaveOptions.setPageIndex(0);
imgSaveOptions.setPageCount(1);
wordDocument.save(MyDir + "Out0.html", imgSaveOptions);
}

htmlFixedSaveOptions.setPageIndex(i);
htmlFixedSaveOptions.setPageCount(1);

wordDocument.save(MyDir + "Out\\Out" + (i + 1) + "-svg.html", htmlFixedSaveOptions);
imgSaveOptions.setPageIndex(i);
imgSaveOptions.setPageCount(1);
}
}

}
Hi there,

Thanks for your inquiry. Could you please embed the fonts inside your input document and share it here for testing? We will investigate the issue on our side and provide you more information.

the fonts in this doc are Time News Main and simhei.ttf and simsun.ttc,you can download these three fonts.


Time News Main is in your english system.so you should only download simhei.ttf and simsun.ttc may be this two fonts are also in your system.

do not open this file in office,but only run the code.and see the distinguish.

because this file is edited by WPS(a office software);
Hi there,

Thanks for sharing the detail. We have installed the shared fonts and have noticed that Aspose.Words generates the two pages output. Please note that Aspose.Words mimics the same behavior as MS Word does. The input document contains two pages and Aspose.Words generates the correct output.

Please let us know if you have any more queries.

but actually,it has only one page!when you open it by MS word,it has only one page!

Hi there,

Thanks for your inquiry. We installed the shared fonts and still MS Word 2013 and 2016 shows 2 pages. Please check the attached image for detail.