• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

removing hyperlinks from end-notes in a PDF to HTML conversion

We are using a program called JPDF to HTML from IDR solutions to convert over 500 PDF's into HTML and in the PDF’s, the end notes contain URL’s. Now some of those URL’s have been converted into hyperlinks, and it doesn’t convert the whole URL just the first line of the URL. Does anyone know the easiest way to strip the hyperlinks from the URL’s?

Thanks!
0
rcimasi
Asked:
rcimasi
  • 4
  • 4
1 Solution
 
Julian HansenCommented:
When you say strip do you mean the conversion does this
<a href="http://www.somedomain.com/folder/truncated_">http://www.somedomain.com/folder/truncated_</a> path/somefile.html

Open in new window

And you want to end up with
http://www.somedomain.com/folder/truncated_path/somefile.html

Open in new window


Some examples of what you are referring to be would be helpful to understand what it is you are asking.
0
 
rcimasiAuthor Commented:
Yes exactly
0
 
Julian HansenCommented:
Do you have a sample of a converted document (or part of one with a broken hyperlink)?

Specifically need to see how lines are broken.

One solution is to use a regular expressiong

/<a(.*?)>(.*?)</a>/g, \1
The expression and implementation will vary depending on what you use to implement it but basically the expression matches all <a> tags and takes what is between them as the replacement for everything from the opening tag to the closing tag.

What tools would you use to process the html files to do the replace - Java?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rcimasiAuthor Commented:
The solution that we are using right now for this is to put the converted web pages into Dreamweaver and then use the find and replace function to quickly go through and find the hyperlinks and the remove the /a tag
0
 
Julian HansenCommented:
Understood but I could recommend a solution in PHP only to find you don't use PHP - hence my question given a scripted solution what server side script environment would you prefer to use?
0
 
rcimasiAuthor Commented:
We can use what ever language, what do you recommend?
0
 
Julian HansenCommented:
It does not really make a difference. Anything that supports regular expressions.
Here is a PHP solution
The script searches for all .html files in a folder, converts the URLs and then writes the file back to a folder (output).
<?php
$files = glob('*.html');
foreach($files as $file) {
  $content = file_get_contents($file);
  $fixed = preg_replace('/\<a(.*?)href="(.*?)"(.*?)>(.*?)\<\/a>/i', '\2', $content);
  file_put_contents("output/{$file}", $fixed);
}

Open in new window

To be able to determine if the script is correct I would need to see a sample of a file.
Here is the test file I used
<!doctype html>
<html>
<body>
	This is a test to see if ths <a href="http://www.somedomain.com/folder/truncated_">http://www.somedomain.com/folder/truncated_</a>path/somefile.html and some more
	text over here <a href="http://www.somedomain.com/folder/someotherfile.html">http://www.somedomain.com/folder/someotherfile.html</a> would go over here.
</body>
</html>

Open in new window

0
 
rcimasiAuthor Commented:
Thanks for the help
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now