Free Support Forum - aspose.com

Exception or call back when a mentioned file in html is not available

Hi,


I’am using aspose to convert html to a pdf. What I like to have is that I get information on missing resources during the conversion of the html. For example when a image is not available I like to have a notification that the image is not available. Via for example a callback or an exception. Is that possible?

With kind regards,

Gerard

package test.aspose;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import com.aspose.pdf.Document;
import com.aspose.pdf.HtmlLoadOptions;
import com.aspose.pdf.SaveFormat;

public class AsposeHtmlConvertorMain {

public static void main(String[] args) throws IOException {
File fileExistingImage = create(“C:/temp/resultExistingImage.pdf”);
File fileNoneExistingImage = create(“C:/temp/resultNotExistingImage.pdf”);
convert(“test
test
<img src=“http://www.ohra.nl/images/logo-ohra_tcm66-219852.jpg”>”, fileExistingImage);
// I like to have an exception or some callback to inform me that a mentioned file in the html is not available.
convert(“test
test
<img src=“http://www.ohra.nl/images/logo-ohra_xx_tcm66-219852.jpg”>”, fileNoneExistingImage);
}
private static void convert(String inputHtml, File pdfOutputFile) throws IOException {
InputStream htmlInputStream = new ByteArrayInputStream(inputHtml.getBytes());
convert(htmlInputStream, pdfOutputFile);
htmlInputStream.close();
}

private static void convert(InputStream htmlInputStream, File pdfOutputFile) {
Document doc = new Document(htmlInputStream, new HtmlLoadOptions());
doc.save(pdfOutputFile.getAbsolutePath(), SaveFormat.Pdf);
}
private static File create(String name) {
File result = new File(name);
if (result.exists()) {
result.delete();
}
return result;
}
}

Hi Gerard,


Thanks for your inquiry. I am afraid currently the requested feature is not available. However I have logged a new feature request PDFJAVA-36192 in our issue tracking system for further investigation and implementation. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience.

Best Regards,

Hi Tital Ahmad,


Thank you logging it as a new request. Can I see some were what the progress is of the request? Have you any idea when this feature will be available?

Best Regards,

Gerard

Hi Gerard,


Thanks for your inquiry. Please note our issue tracking system(JIRA) is our internal system and It is not accessible to customers. However you may check the high level status with issue id in left column of the thread or you can ask us for the updates, we will be glad to update you the issue resolution progress.

Furthermore in reference to feature ETA, I am afraid it is difficult to share some ETA until the issue investigation is completed. We will notify you as soon as we made some significant progress towards issue resolution.

Best Regards,