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

Free Support Forum - aspose.com

Pdf导出网页的时候报错!

25adc6e1f07a951f31586644ec5de786.pdf.zip (1.2 MB)
代码:
System.out.printf(“run here 4\n”);
int pagesCount = pageCollection.size();
for (int i = 1; i <= pagesCount; i++) {
System.out.printf(“run here 5 ->%d\n”, i);
Page p = pdfDocument.getPages().get_Item(i);
System.out.printf(“run here 6 ->%d\n”, i);
Document tmpDoc = new Document();
tmpDoc.setEmbedStandardFonts(true);
System.out.printf(“run here 7 ->%d\n”, i);
tmpDoc.getPages().add§;
System.out.printf(“run here 8 ->%d\n”, i);
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setFixedLayout(true);
saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsWOFF;
saveOptions.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
saveOptions.CssClassNamesPrefix = “st” + Integer.toString(i) + “_”;
System.out.printf(“run here 8.1 ->%d\n”, i);
tmpDoc.save(mHtmlPath.getAbsolutePath() + “/” + “out” + Integer.toString(i) + “.html”, saveOptions);
System.out.printf(“run here 9 ->%d\n”, i);
pdfDocument.close();
pdfDocument.dispose();
tmpDoc.dispose();
pdfDocument = new Document(outPath + PDF_FILENAME);
System.out.printf(“run here 10 ->%d\n”, i);
}
在 tmpDoc.save(mHtmlPath.getAbsolutePath() + “/” + “out” + Integer.toString(i) + “.html”, saveOptions); 这一行的时候报错:java.lang.IllegalStateException: Resource file GBK2K-H not found in assembly

Java版本: 1.8.0_111
系统:CentOS Linux release 7.4.1708
aspose版本: 18.11

@jcing

感谢您与支持人员联系。

我们稍微修改了您的代码并在我们的环境中对其进行了测试。 不会再现任何错误,但会生成3个大小为1KB的HTML文件。

Document pdfDocument = new Document("D:\\25adc6e1f07a951f31586644ec5de786.pdf");
//System.out.printf(“run here 4\n”);
int pagesCount = pdfDocument.getPages().size();
for (int i = 1; i <= pagesCount; i++) {
System.out.printf("run here 5 ->"+i+"\n");
Page p = pdfDocument.getPages().get_Item(i);
System.out.printf("run here 6 ->"+i+"\n");
Document tmpDoc = new Document();
tmpDoc.setEmbedStandardFonts(true);
System.out.printf("run here 7 ->"+i+"\n");
tmpDoc.getPages().add();
System.out.printf("run here 8 ->"+i+"\n");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setFixedLayout(true);
saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsWOFF;
saveOptions.LettersPositioningMethod = 
LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
saveOptions.RasterImagesSavingMode = 
HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
saveOptions.CssClassNamesPrefix = "st" + Integer.toString(i) + "_";
System.out.printf("run here 8.1 ->"+i+"\n");
tmpDoc.save("D:\\" + "out" + Integer.toString(i) + ".html", saveOptions);
System.out.printf("run here 9 ->"+i+"\n");
System.out.printf("run here 10 ->%d\n", i); 
} 

您是否可以分享SSCCE代码重现问题以及错误的堆栈跟踪,以便我们进一步调查以帮助您。

从你们的代码上看,你们是window平台测试的,我是在linux机器上测试的!

@jcing

我们也在Linux环境中对它进行了测试,但错误没有重现。 请分享JDK / JRE详细信息和堆栈错误,以供我们参考。