iTextSharp HTMLWorker img not found 404 - itext

I got the problem that the HTMLWorker.ParseToList function will throw an exception ( 404 - not found ) when a tag like:
<img alt="none" src="/image.jpg" />
Has a deadlink in the src.I'd like it to just not load the image and go on.
Does anyone now a way to configure this or has similar solution in mind?

The path must be absolute ex: c:\images\image.jpg
You can do it with
Server.MapPath(relativeUrl)

You can extend HTMLWorker to include a filter to remove (or substitute) whichever HTML elements you want before passing your HTML to your extended HTMLWorker's ParseToList() method.

look into this thread
http://www.draggerco.com/node/2
works great for me...
i just replaced
string siteUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(HttpContext.Current.Request.Url.AbsolutePath, "");
with
string siteUrl = HttpContext.Current.Server.MapPath([your_path_for_images_in_string]);
** Note: for this, use HtmlWorker.Parse() method

I'am fixed. But This;
c:\images\image.jpg as localhost:3524\images\image.jpg
<img alt="none" src="http://localhost:3524/image.jpg" />
Create your host configuration.
html = html.Replace("img src=\"", "img src=\"http://localhost:3524");
it's worded.

Related

Relative links in tvml?

Is it possible to use relative links in tvml? I've never had a problem using them in a webpage but just can't get it to work in my tvml docs.
From my swift:
static let TVBaseURL = "http://localhost:9001/"
This currently works from my tvml which is located at http://localhost:9001/templates/home.xml
<lockup onselect="getDocument('templates/Featured.xml')">
<img src="http://localhost:9001/graphics/icons/ICON_featured.png" width="313" height="600" />
</lockup>
Note that the onselect link is relative and works fine. However this doesn't work...
<lockup onselect="getDocument('templates/Featured.xml')">
<img src="../graphics/icons/ICON_featured.png" width="313" height="600" />
</lockup>
It all depends on how you define YOUR getDocument function. But from your code, most likely it looks a bit like this one from the official TVML Programming Guide, sec 8-3.
function getDocument(extension) {
var templateXHR = new XMLHttpRequest();
var url = baseURL + extension;
loadingTemplate();
templateXHR.responseType = "document";
templateXHR.addEventListener("load", function() {pushPage(templateXHR.responseXML);}, false);
templateXHR.open("GET", url, true);
templateXHR.send();
}
Which uses a pre-set baseURL like your code does. Thus, your get document support relative links. (and not universal link. putting the full http://localhost:9001/index.xml will break it.)
in this example, the XMLHttpRequest object open function, takes the full url, not the relative one. Read more about XMLHttpRequest open here.
In short. Nothing is relative here.
However, you can do something similar with the power of Javascript.
When you get a hold of the XML document, you can find all the tag with document.getElementsByTagName("img"), which give you a list of the image element. Then all it is left to do it to look at each of them with .item(i), get their source attribute by .getAttribute('src'), see if it start with http or https, and if not, set the new one by .setAttribute('src', baseUrl+imagePath)

Link to file in Fluid – how to specify storage?

As far as I know, there's no such thing as an f:link.file or v:link.file viewhelper.
There used to be a solution using file.originalResource.publicUrl as the value to point the link to, as in
<f:link.page pageUid="{file.originalResource.publicUrl}" target="_blank">
Am I right that this is no longer necessary? I got this (using ext:mask):
<f:link.page pageUid="{file.identifier}" target="_blank">
returning the same value, while originalResource.publicUrl would not even show up in f:debug.
BUT in file.identifier the storage path, e.g. fileadmin, is not present. How do I add it to the viewhelper?
Or, what is the currently recommended solution for a link to a file in TYPO3 7.6?
Just use {file.name}. When absolute URL or some special configuration is needed use <f:link.typolink parameter="{file.publicUrl}">{file.name}</f:link.typolink>.
TYPO3 11 introduced a new ViewHelper for this
<f:link.file file="{file}" target="_blank">Download</f:link.file>
https://docs.typo3.org/other/typo3/view-helper-reference/11.5/en-us/typo3/fluid/latest/Link/File.html
For me, #minifranske’s solution worked only as a hint: I needed to use {file.originalResource.publicUrl} instead:
<f:link.typolink parameter="{file.originalResource.publicUrl}">{file.originalResource.title}</f:link.typolink>
also available:
{file.originalResource.name}
{file.originalResource.description}
{file.originalResource.alternative}
Nevertheless, if anybody knows a proper core solution which resembles that of the Rich Text Editor, I’d be happy to hear about it:
file link
page link
<f:uri.image image="{imageObject}" /> produces the path + filename for your FAL object.

How do I use Perl's Remote::Selenium::WebElement to verify the URL a hyperlink will take me to?

Seems like it should be straightforward but I can't seem to get to the bottom of it.
Here's the HTML I'm working with:
<li id="a" class="FILElevel3" onclick="changeMenu("b")">
<a onclick="stopBubble(event);" href="javascript:LinkPopup('/sub/URL.html')">Visible Text</a>
I'm able to find the element using XPaths:
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']");
And I can verify this works because I'm able to extract the visible text from it:
my $returned_name = Selenium::Remote::WebElement::get_text($returned_asset);
I just can't seem to find the sequence to pull the HREF attribute from the element to put the link's URL into a verifiable string. Should I be able to do this using WebElement's get_attribute() method? I've tried variations on this:
my $returned_URL = $returned_asset-> Selenium::Remote::WebElement::get_attribute("a/href");
...where I've plugged in everything I could think of for that "a/href" string. What should go in there?
In the end I'd like to be able to put "javascript:LinkPopup('/sub/URL.html')" into a string and verify that my URL is in there.
have you tried
my $returned_asset = $sel->find_element("//*[\#class='LINKlevel3']/a");
my $returned_URL = $returned_asset->Selenium::Remote::WebElement::get_attribute("href");

Replace part of a string in a Struts2 tag

Is it possible to replace the value of a property in Struts2?
I want to resolve a mimetype image, and it would be really useful to do something like:
<img src="<s:property value='%{mimetype.replace("/", ".")}'/>" ...
Can I do something on the fly like this?
Thanks!
<img src="<s:property value='%{mimetype.replace("/", ".")}'/>
Yes it's possible ognl allows to use string mehthods directly

ICEFACES : Multiple Parameters in link

I have a datatable with multiple rows, I want to put one link to redirect the values to one Servlet. The old call that I use is similar like this :
a onclick=openWindow('./Servlet?param1=xx&param2=xxx')
I'm newbie in ICEfaces... I need your help because I don't know how can I put one parameter only like this :
ice:outputLinktarget="mainFrame" value="./Servlet?param1=#{item.id}
but when I put two parameters, I got an errors in the code.
ice:outputLinktarget="mainFrame" value="./Servlet?param1=#{item.id}&param2=#{item.id}
Somebody knows how to do it?
The ampersand (&) is the culprit; you need to escape it or else IceFaces gets confused about the page structure.
Another way to do it:
<ice:outputLink target="mainFrame" value="./Servlet">
<f:param name="param1" value="#{item.id}"/>
<f:param name="param2" value="#{item.id}"/>
</ice:outputLink>
The f:param tags add the parameters to the base URL automatically.
You haven't said about what technology you use (jsp/jsf)?
For jsf try:
<ice:outputLinktarget="mainFrame" value="./Servlet>
<f:param name="param1" value="#{item.id}"/>
<ice:outputLinktarget=>