mac命令行將輸出寫入文件_如何在Linux中使用命令行將PDF文件轉換為可編輯文本...

mac命令行將輸出寫入文件

mac命令行將輸出寫入文件

00_lead_image_pdf_to_text

There are various reasons why you might want to convert a PDF file to editable text. Maybe you need to revise an old document and all you have is the PDF version of it. Converting PDF files in Windows is easy, but what if you’re using Linux?

出于多種原因,您可能希望將PDF文件轉換為可編輯的文本。 也許您需要修改一個舊文檔,而您所擁有的只是它的PDF版本。 在Windows中轉換PDF文件很容易,但是如果使用Linux,該怎么辦?

No worries. We’ll show you how to easily convert PDF files to editable text using a command line tool called pdftotext, that is part of the “poppler-utils” package. This tool may already be installed. To check if pdftotext is installed on your system, press “Ctrl + Alt + T” to open a terminal window. Type the following command at the prompt and press “Enter”.

別擔心。 我們將向您展示如何使用名為pdftotext的命令行工具輕松地將PDF文件轉換為可編輯文本,該工具是“ poppler-utils”軟件包的一部分。 該工具可能已經安裝。 要檢查系統上是否安裝了pdftotext,請按“ Ctrl + Alt + T”打開終端窗口。 在提示符下鍵入以下命令,然后按“ Enter”。

dpkg –s poppler-utils

dpkg –s poppler-utils

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

注意:當我們說要在本文中鍵入某些內容并且文本周圍有引號時,請不要鍵入引號,除非我們另外指定。

01_checking_for_poppler_utils

If pdftotext is not installed, type the following command at the prompt and press “Enter”.

如果未安裝pdftotext,則在提示符下鍵入以下命令,然后按“ Enter”。

sudo apt-get install poppler-utils

須藤apt-get install poppler-utils

Type your password when prompted and press “Enter”.

出現提示時輸入密碼,然后按“ Enter”。

02_installing_poppler_utils

There are several tools available in the poppler-utils package for converting PDF to different formats, manipulating PDF files, and extracting information from files.

poppler-utils軟件包中提供了幾種工具,可用于將PDF轉換為不同格式,處理PDF文件以及從文件中提取信息。

03_utilities_in_poppler_utils

The following is the basic command for converting a PDF file to an editable text file. Press “Ctrl + Alt + T” to open a Terminal window, type the command at the prompt, and press “Enter”.

以下是將PDF文件轉換為可編輯文本文件的基本命令。 按“ Ctrl + Alt + T”打開“終端”窗口,在提示符下鍵入命令,然后按“ Enter”。

pdftotext /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

pdftotext /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

Change the path to each file to correspond to the location and name of your original PDF file and where you want to save the resulting text file. Also, change the filenames to correspond to the names of your files.

更改每個文件的路徑,使其與原始PDF文件的位置和名稱以及要保存結果文本文件的位置相對應。 另外,更改文件名以對應于文件名。

04_running_pdftotext

The text file is created and can be opened just as you would open any other text file in Linux.

該文本文件已創建并可以打開,就像在Linux中打開任何其他文本文件一樣。

05_text_file_created

The converted text may have line breaks in places you don’t want. Line breaks are inserted after every line of text in the PDF file.

轉換后的文本可能在您不想要的地方有換行符。 在PDF文件中的每一行文本之后都插入了換行符。

06_converted_text_file_in_editor

You can preserve the layout of your document (headers, footers, paging, etc.) from the original PDF file in the converted text file using the “-layout” flag.

您可以使用“ -layout”標志保留轉換后的文本文件中原始PDF文件的文檔布局(頁眉,頁腳,頁面等)。

pdftotext -layout /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

pdftotext -layout /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

06a_converting_using_layout

If you want to only convert a range of pages in a PDF file, use the “-f” and “-l” (a lowercase “L”) flags to specify the first and last pages in the range you want to convert.

如果只想轉換PDF文件中的頁面范圍,請使用“ -f”和“ -l”(小寫的“ L”)標志來指定要轉換范圍的第一頁和最后一頁。

pdftotext -f 5 -l 9 /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

pdftotext -f 5 -l 9 /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

07_converting_page_range

To convert a PDF file that’s protected and encrypted with an owner password, use the “-opw” flag (the first character in the flag is a lowercase letter “O”, not a zero).

要轉換使用所有者密碼保護和加密的PDF文件,請使用“ -opw”標志(標志中的第一個字符是小寫字母“ O”,而不是零)。

pdftotext -opw ‘password’ /home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

pdftotext -opw'password'/home/lori/Documents/Sample.pdf /home/lori/Documents/Sample.txt

Change “password” to the one used to protect the original PDF file being converted. Make sure there are single quotes, not double, around “password”.

將“密碼”更改為用于保護要轉換的原始PDF文件的密碼。 確保在“密碼”周圍有單引號而不是雙引號。

08_converting_pdf_with_password

If the PDF file is protected and encrypted with a user password, use the “-upw” flag instead of the “-opw” flag. The rest of the command is the same.

如果PDF文件受用戶密碼保護和加密,請使用“ -upw”標志而不是“ -opw”標志。 其余命令相同。

09_converting_pdf_with_user_password

You can also specify the type of end-of-line character that is applied to the converted text. This is especially useful if you plan to access the file on a different operating system like Windows or Mac. To do this, use the “-eol” flag (the middle character in the flag is a lowercase letter “O”, not a zero) followed by a space and the type of end-of-line character you want to use (“unix”, “dos”, or “mac”).

您還可以指定應用于轉換后的文本的行尾字符的類型。 如果打算在Windows或Mac等其他操作系統上訪問文件,則此功能特別有用。 為此,請使用“ -eol”標志(標志的中間字符是小寫字母“ O”,而不是零),后跟一個空格和要使用的行尾字符類型(“ unix”,“ dos”或“ mac”)。

10_converting_pdf_with_eol_format

NOTE: If you don’t specify a filename for the text file, pdftotext automatically uses the base of the PDF filename and adds the “.txt” extension. For example, “file.pdf” will be converted to “file.txt”. If the text file is specified as “-“, the converted text is sent to stdout, which means the text is displayed in the Terminal window and not saved to a file.

注意:如果未為文本文件指定文件名,則pdftotext會自動使用PDF文件名的基礎并添加“ .txt”擴展名。 例如,“ file.pdf”將被轉換為“ file.txt”。 如果文本文件指定為“-”,則轉換后的文本將發送到stdout,這意味著該文本顯示在“終端”窗口中,而不保存到文件中。

To close the Terminal window, click the “X” button in the upper-left corner.

要關閉終端窗口,請單擊左上角的“ X”按鈕。

For more information about the pdftotext command, type “man page pdftotext” at the prompt in a Terminal window.

有關pdftotext命令的更多信息,請在“終端”窗口的提示符下鍵入“手冊頁pdftotext”。

翻譯自: https://www.howtogeek.com/228531/how-to-convert-a-pdf-file-to-editable-text-using-the-command-line-in-linux/

mac命令行將輸出寫入文件

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/280726.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/280726.shtml
英文地址,請注明出處:http://en.pswp.cn/news/280726.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Windows Socket和Linux Socket編程的區別

2019獨角獸企業重金招聘Python工程師標準>>> 1、一些常用函數的移植 http://www.vckbase.com/document/viewdoc/?id1586 2、網絡 socket相關程序從Windows移植到Linux下需要注意的: 1)頭文件 Windows下winsock.h/winsock2.h Linux下sys/socket.h 錯誤處理&…

使用 C# 開發的現代輕量級 Windows 文本編輯器

你好,這里是 Dotnet 工具箱,定期分享 Dotnet 有趣,實用的工具和組件,希望對您有用!Notepads 是一個具有簡約設計的現代化輕量級文本編輯器,在 github 上開源,由微軟大佬 Jiaqi Liu 開發。開發背…

分布式壓測系列之Jmeter4.0第一季

1)Jmeter4.0介紹 jmeter是個純java編寫的開源壓測工具,apache旗下的開源軟件,一開始是設計為web測試的軟件,由于發展迅猛,現在可以壓測許多協議比如:http、https、soap、ftp、database數據庫、LDAP 輕量目…

powershell 查看系統設備\device status

查看設備 $allDevice"C:\Data\soundDevAll.txt" (Get-WmiObject -Class Win32_SoundDevice).Name|Out-File $allDevice device status $deviceInfoGet-WmiObject Win32_PnPEntity| select Name, Status | where {$_.Name -like "$deviceName"} $set…

Fish Shell 使用筆記

安裝Fish Shell brew install fish 安裝Oh My Fish curl -L https://get.oh-my.fish | fish 安裝Fisher curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish 配置 autojump clone autojump git clone https://github.com/wting/autojum…

Entity Framework Core 7中高效地進行批量數據插入

因為之前的版本中,EF Core無法實現高效地批量插入、修改、刪除數據,所以我開發了Zack.EFCore.Batch這個開源項目,比較受大家的歡迎,獲得了400多個star。從.NET 7開始,微軟在Entity Framework Core 7內置了對高效地批量…

Hive學習之路 (一)Hive初識

Hive 簡介 什么是Hive 1、Hive 由 Facebook 實現并開源 2、是基于 Hadoop 的一個數據倉庫工具 3、可以將結構化的數據映射為一張數據庫表 4、并提供 HQL(Hive SQL)查詢功能 5、底層數據是存儲在 HDFS 上 6、Hive的本質是將 SQL 語句轉換為 MapReduce 任務運行 7、使不熟悉 MapR…

angularJs select綁定的model 取不到值

內容結構 一.原因分析 二. 解決辦法 一.原因分析 1.由于原型繼承的關系,修改父級對象中的someBareValue會同時修改子對象中的值,但反之則不行。2.ng-if 以及 ng-repeat 會創建一個子級作用域,如果在這倆個指令中添加了元素&a…

PS2019攝影后期處理(三)通透....

一、PS可選顏色 在對應顏色進行cmyk加減

(原創) 今天拿到學生證了 (日記)

<原文我在2006/09/07發表在藍色小舖>今天拿到學生證了&#xff0c;終於正式成為臺大的學生。第一件事情就是去臺大圖書館借了四本書回家看&#xff0c;一次可以借兩個月耶&#xff0c;真不錯。 感覺很複雜&#xff0c;下星期要離開華碩&#xff0c;得繳回識別證&#xff…

os 鍵盤快捷鍵截圖_如何通過鍵盤快捷鍵更有效地使用OS X虛擬桌面

os 鍵盤快捷鍵截圖() We like having multiple virtual desktops on OS X, especially when we can supercharge them by combining them with a few simple keyboard shortcuts. So, on that note, here are some practical ways to use OS X’s virtual desktops like you me…

旗正規則引擎內存表出錯的原因及解決方法

經常我們有一些使用者問到這個問題&#xff0c;關于內存表出錯的情況&#xff0c;其實問題不復雜&#xff0c;我這給大家簡單的講一下就明白了&#xff0c;如果還有什么不明白的&#xff0c;其實也都可以問廠家杭州旗正&#xff0c;隨時都有人回應的。 1 內存表 1.1 匯總 1.1.1…

Shell腳本之sed的使用

1.sed命令&#xff1b;主要作用是查找&#xff1b;新增 刪除 和修改替換。 user.txt daokr#cat user.txt ID Name Sex Age 1 zhang M 19 2 wang G 20 3 cheng M 10 4 huahua M 100 查找命令&#xff1a;-n 和 p&#xff08;prin…

.NET周報【11月第4期 2022-11-30】

國內文章.NET 7 的 AOT 到底能不能扛反編譯&#xff1f;https://www.cnblogs.com/huangxincheng/p/16917197.html在 B 站&#xff0c;公眾號上發了一篇 AOT 的文章后&#xff0c;沒想到反響還是挺大的&#xff0c;都稱贊這個東西能抗反編譯&#xff0c;可以讓破解難度極大提高&…

結合hello world探討gcc編譯程序的過程

本博客&#xff08;http://blog.csdn.net/livelylittlefish&#xff09;貼出作者&#xff08;三二一小魚&#xff09;相關研究、學習內容所做的筆記&#xff0c;歡迎廣大朋友指正&#xff01; 結合"hello world"探討gcc編譯程序的過程 1. gcc簡介 gcc/g是GNU工程的C和…

Powershell 時間相關

1.時間相差秒數計算 $start Get-Date Get-HotFix $end Get-Date Write-Host -ForegroundColor Red (Total Runtime: ($end - $start).TotalSeconds)//若開始時間保存為字符串$startTime Get-Date -Format yyyyMMddTHH:mm:ss $startTime[datetime]::ParseExact("$sta…

java類中,成員變量賦值第一個進行,其次是靜態構造函數,再次是構造函數

如題是結論&#xff0c;如果有人問你Java類的成員初始化順序和初始化塊知識就這樣回答他。下面是代碼&#xff1a; package com.test;public class TestClass{// 成員變量賦值第一個執行private static int m11;private int m21;// 靜態構造函數第二個執行static{System.out.pr…

Unity的未來,是固守Mono,還是擁抱CoreCLR?

TLDR;Unity堅定的擁抱.NET標準生態&#xff0c;正全速向CoreCLR遷移。Mono vs CoreCLR對于一個C#的初學者&#xff0c;首先要了解的便是.NET和C#的關系。所以這里不再贅述。對于一個Unity的初學者&#xff0c;在使用C#編碼的過程中&#xff0c;一定會遇到一些C#新特性不能在項目…

hinton教授的本科生課程CSC321-機器學習中的神經網的筆記

最近一直在看仙守博友所記錄的筆記 Hinton的CSC321課程&#xff08;完結&#xff0c;待文字潤色&#xff09;&#xff1a; 1、lecture1-NN的簡介 2、lecture2-NN結構的主要類型的概述和感知機 3、lecture3-線性神經元和算法 4、lecture4-神經網絡在語言上的應用 5、lecture5-對…

ASP存儲過程參數數據類型

ASP調用存儲過程一般的方法&#xff1a; p.Append cmd.CreateParameter("參數名稱",類型,方向,大小) 參許參數值的類型的意義如下&#xff1a; 名稱值 整數值 功能 adDBTimeStamp 135 日期時間數據類型 adDecimal 14 十進制整數值 adDouble …