Page 1 of 1

XHTMLImporterImpl href

PostPosted: Thu Jun 22, 2017 7:17 am
by laurenquintanilla
Hi. I am using the latest docx4j-ImportXHTML-3.3.4.jar and docx4j-3.3.4.jar and having a problem converting href links to word.

This one works fine: <div><p><span class="wikiexternallink"><a href="http://www.google.com/ target=&quot;_blank&quot;">TestLink</a></span></p></div>

However, if I don't manually add the trailing "/" to the google url, "The file is corrupt and cannot be opened" from Word document.

My work around can be to programatically add the "/", but wondering if there is a better way or a patch out there for this issue.

Thanks!
Lauren

Re: XHTMLImporterImpl href

PostPosted: Fri Jun 23, 2017 10:00 am
by jason
Hi Lauren

I can't see a problem in docx4j here?

Your input:

<div><p><span class="wikiexternallink"><a href="http://www.google.com/ target=&quot;_blank&quot;">TestLink</a></span></p></div>

results in docx4j creating a rel with target: http://www.google.com/ target="_blank" (note the space in the input, which you probably didn't intend)

which in the actual zipped XML becomes: Target="http://www.google.com/ target=&quot;_blank&quot;"

All good. From what you say I suspect Word might be checking that the value of @Target is a well formed URL.

What is the @href you can't process properly?

Re: XHTMLImporterImpl href

PostPosted: Sat Jun 24, 2017 7:45 am
by laurenquintanilla
The url w/out the trailing slash is giving me the problem


<div><p><span class="wikiexternallink"><a href="http://www.google.com target=&quot;_blank&quot;">TestLink</a></span></p></div>

Re: XHTMLImporterImpl href

PostPosted: Mon Jun 26, 2017 10:12 pm
by jason
Assuming thphpbb isn't messing with your post, why have you got whitespace in your URL? You can't expect that to work...

Re: XHTMLImporterImpl href

PostPosted: Tue Jun 27, 2017 8:14 am
by laurenquintanilla
Jason, sorry to waste your time! I didn't notice the first part of my conversion from markdown to html added that extra space incorrectly. Your answer did fix my problem though!! Thanks!!!!!!