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

Free Support Forum - aspose.com

Image hyperlink replaced by hyperlink only when converting html to word/pdf

Hi,

I am using aspose-words-17.3.0-jdk16.jar to create a word/pdf file. When I try to convert an image hyperlink the image disappears and is replaced by a hyperlink text. Please see attached zip for html, word, and pdf. What can I do to fix this issue?

Below is the code to convert to word/pdf:

public void convertToPdf() {
Document document = new Document(new FileInputStream("aspose.html"));

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
opts.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

document.updatePageLayout();
document.save("test.pdf", opts);
}

public void convertToWord() {
Document document = new Document(new FileInputStream("aspose.html"));

document.save("test.docx");
}

Hi there,


Thanks for your inquiry. While testing the scenario with Aspose.Words for Java 17.3 and 17.4 on Win 7 64 bit, we are unable to notice the reported issue. Please find attached sample outputs for your reference.

Please double check the scenario at your end with latest version of Aspose.Words for Java. However, if the issue persists then please share some more details to replicate the issue along with your environment details.

Best Regards,

Morning


We are having the same issue running on Aspose Java 17.3

Using this code:
<a href=“mailto:myemail@emailaddress.com”><img src=“https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png” alt=“Email Image”>

We are unable to produce your expected result. The result in PDF is a hyperlink. See output below:

<a href=“mailto:myemail@emailaddress.com”>mailto:myemail@emailaddress.com

Could you please post your htm and java code and we’ll test it at our end?
Hi,

The code snippet I posted in the first message was incorrect. I have discovered that when I updateFields() it will remove the image hyperlink and replace it with the hyperlink text.

public void convertToPdf() {
Document document = new Document(new FileInputStream("aspose.html"));

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
opts.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

document.updateFields();
document.updatePageLayout();
document.save("test.pdf", opts);
}

public void convertToWord() {
Document document = new Document(new FileInputStream("aspose.html"));

document.updateFields();
document.save("test.docx");
}

Hi there,


Thanks for your feedback. We have also noticed that issue occurs after using updateFields() method. We will appreciate it if you please confirm the use of updateFields() method in your scenario, it will help us to address your issue exactly. Usually this method is called before saving document when you have modified the document programmatically and want to make sure the proper (calculated) field values appear in the saved document.

Best Regards,

Hi,


I am calling updateFields() because I have inserted the numpages and total num pages. Please see below.

public void convertToPdf() {
Document document = new Document(new FileInputStream(“aspose.html”));
DocumentBuilder builder = new DocumentBuilder(document);

PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
opts.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);

int startPage = 2;
insertNumPagesFooter(builder, startPage);

<span style=“font-family: “Courier New”; font-size: small;”> document.updateFields();
document.updatePageLayout();
document.save(“test.pdf”, opts);
}

private void insertNumPagesFooter(DocumentBuilder builder, int startPage){
for (Section section : builder.getDocument().getSections()) {
section.clearHeadersFooters();
}
builder.moveToSection(startPage);

Section currentSection = builder.getDocument().getFirstSection();
PageSetup pageSetup = currentSection.getPageSetup();
if (startPage == 0) {
pageSetup.setDifferentFirstPageHeaderFooter(false);
} else {
pageSetup.setDifferentFirstPageHeaderFooter(true);
}

builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
builder.insertField(“PAGE”);
builder.write(" of “);
Field field = builder.insertField(”=");
builder.moveTo(field.getSeparator());
builder.insertField(“NUMPAGES”);
builder.write("-" + startPage);
builder.getCurrentParagraph().getParagraphFormat().setAlignment(ParagraphAlignment.RIGHT);
builder.moveToDocumentEnd();

Section section = builder.getDocument().getSections().get(startPage);
section.getPageSetup().setRestartPageNumbering(true);
section.getPageSetup().setPageStartingNumber(1);
}

Hi there,


Thanks for sharing additional information. We have logged a ticket WORDSJAVA-1544 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

The issues you have found earlier (filed as WORDSJAVA-1544) have been fixed in this Aspose.Words for .NET 17.6 update and this Aspose.Words for Java 17.6 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.