Solved

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

Posted on 2016-09-22
8
119 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
  • 4
  • 4
8 Comments
 
LVL 56

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 56

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

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 56

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 56

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

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!

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

713 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