![]() Windows has many software solutions for such cases, but Linux has a more robust command shell. While manually extracting some links from a pdf file is easy to do, the issue becomes more complex when the pdf file has hundreds of pages or multiple documents. You can also use it as a Python library or in a bash script. There are many options to use, such as the -v flag for having all references, not just the PDFs, and -t flag to extract the pdf text, and -c flag to detect the broken links. Now let’s use the previous command on this PDF document: $ pdfx -v | sed -n 's/^- \(http\)/\1/p' ![]() To use it, simply pass the PDF path on your machine or the remote URL of the PDF document, as it’ll automatically download it: $ pdfx If you already have Python installed, you simply use easy_install to install it: $ sudo easy_install -U pdfx Pdfx has many features and options that deserve to try, such as finding broken hyperlinks (using the -c flag), outputting the result as JSON, and online pdf files directly without downloading them. But you need to install it firstly with easy_install or pip, or you will get a “command not found” message: $ pdfx -v file.pdf | sed -n 's/^- \(http\)/\1/p' Using pdfxĪnother alternative would be pdfx. However, as you can see, we will miss many URLs the first method is the preferred one. You can also use the pre-built strings command and grep to do the same thing: $ strings somePDFfile.pdf | grep http Related: How to Convert PDF Files to Images in Linux Using Strings If you want to test the above command but don’t have an example PDF document, you can download a sample here. You still need to merge it with some options and other commands such as grep, like this: $ pdftotext -raw "filename.pdf" & file=`ls -tr | tail -1` grep -E "https?://.*" "$-urls.txt" part of the command is responsible for that you can change it to urls.txt for example. To be able to use pdftotext, we have to install poppler-utils: $ apt install poppler-utilsīy using the pdftotext command, you can get a list of all URLs in a pdf file. ![]() However, each method has its pros and cons. Others need to install some additional libraries and packages. Some of them are ready to use and don’t need extra steps. There are many terminal commands and options to get all links from pdf Linux. Those eager users of Linux like you certainly prefer to use command and bash shell solutions. But Linux has many rich commend shell better options. And therefore, you have come to the right place!Īs we mentioned previously, Linux has no or limited PDF software editors to extract text or links from it. Whether this file is on your desktop or the web, if you are a Linux user, you have no easy GUI software options to facilitate this task for Windows users. In many cases, you will need to extract URLs from a specific pdf file. PDF files are one of the most common online documents formats.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |