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

Posted on 2016-09-22
Last Modified: 2016-09-26
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?

Question by:rcimasi
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
LVL 57

Expert Comment

by:Julian Hansen
ID: 41812243
When you say strip do you mean the conversion does this
<a href=""></a> path/somefile.html

Open in new window

And you want to end up with

Open in new window

Some examples of what you are referring to be would be helpful to understand what it is you are asking.

Author Comment

ID: 41812691
Yes exactly
LVL 57

Expert Comment

by:Julian Hansen
ID: 41812943
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?
Independent Software Vendors: 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!


Author Comment

ID: 41816304
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
LVL 57

Expert Comment

by:Julian Hansen
ID: 41816493
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?

Author Comment

ID: 41816556
We can use what ever language, what do you recommend?
LVL 57

Accepted Solution

Julian Hansen earned 500 total points
ID: 41816869
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).
$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>
	This is a test to see if ths <a href=""></a>path/somefile.html and some more
	text over here <a href=""></a> would go over here.

Open in new window


Author Closing Comment

ID: 41816978
Thanks for the help

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question