Solved

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

Posted on 2016-09-22
8
153 Views
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?

Thanks!
0
Comment
Question by:rcimasi
[X]
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
8 Comments
 
LVL 58

Expert Comment

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

Author Comment

by:rcimasi
ID: 41812691
Yes exactly
0
 
LVL 58

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?
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 

Author Comment

by:rcimasi
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
0
 
LVL 58

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?
0
 

Author Comment

by:rcimasi
ID: 41816556
We can use what ever language, what do you recommend?
0
 
LVL 58

Accepted Solution

by:
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).
<?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
 

Author Closing Comment

by:rcimasi
ID: 41816978
Thanks for the help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

623 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