Sponsored Content
Top Forums Shell Programming and Scripting Problem in refreshing a text editor (gedit) for scanned pdf Post 302974265 by anespa on Friday 27th of May 2016 05:08:19 AM
Old 05-27-2016
Tools Problem in refreshing a text editor (gedit) for scanned pdf

Dear Friends,
I am using Ubuntu 15.10, 34 bit system. I added a Nautilus-Actions script in shell script to convert PDF files to text. There are 2 types of PDF

1. Scanned PDF -- Not OCR type -- When I convert it to text it work , but as the part it must (text file) open in gedit . But I can see a blank file
eventhough it came in real file...

2. For Normal PDF (searcable one) -- it works fine

I add my code for your reference ... please advise what I do to avoid this issue..

Code:
#!/bin/bash
cd $1
if [[ $2 = *.pdf ]]; then
  #echo pdf > "anes.txt"
  MYFONTS=$(pdffonts -l 5 "$3" | tail -n +3 | cut -d' ' -f1 | sort | uniq)
  if [ "$MYFONTS" = '' ] || [ "$MYFONTS" = '[none]' ]; then
    #Scanned PDF
    convert -density 300 "$3" "${3%.*}.tiff"
    tesseract "${3%.*}.tiff" "$3"
    sleep 2
    rm -f "${3%.*}.tiff"
    gedit "${3/%.*}.txt"
  else
    pdftotext "$3"
    gedit "${3/%.pdf/.txt}"
  fi
elif [[ $2 = *.tif ]] ||  [[ $2 = *.tiff ]] || [[ $2 = *.jpg ]] || [[ $2 = *.jpeg ]] || [[ $2 = *.png ]] || [[ $2 = *.gif ]]; then
   tesseract "$3" "${3%.*}"
   gedit "${3/%.*}.txt"
else
  # Not implemented case...
  #echo Nothing to do > "anes.txt"
fi

Waiting for your fast response

Thanks

Anes
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

pdf to text

Hi, Can anyone help me in converting a PDF file into a text file? Thanks, sskb (2 Replies)
Discussion started by: sskb
2 Replies

2. UNIX for Dummies Questions & Answers

how to open a text file using some tool such as gedit under gtk

how to open a text file using some tool such as gedit under gtk I list some text file names in a GtkCList . I want to open the file on when users click on the row. How to implement this ? Thanks (0 Replies)
Discussion started by: cy163
0 Replies

3. UNIX for Dummies Questions & Answers

Pasting text in VI editor from a different editor

Hi, I knw its a silly question, but am a newbie to 'vi' editor. I'm forced to use this, hence kindly help me with this question. How can i paste a chunk 'copied from' a different editor(gedit) in 'vi editor'? As i see, p & P options does work only within 'vi'. (10 Replies)
Discussion started by: harishmitty
10 Replies

4. Solaris

weird problem - terminal not refreshing; sleep not terminating

Hi, I am having a wierd problem in one of the Solaris server. root@ussd # uname -a SunOS ussd 5.8 Generic_108528-24 sun4u sparc SUNW,Sun-Fire-280R The problem is that terminal is not refreshing when we run commands like prstat, tail -f "some log file", sar -u 1 10 Also, sleep... (3 Replies)
Discussion started by: vikas027
3 Replies

5. Red Hat

create pdf of text file help

Can someone please tell me why this is not working? I have created numerous pdf's from text files by following these instructions and this time it is not working. Convert jpeg files to PDF under Linux | bitPrison.net convert /home/liveuser/Documents/hw7 /home/liveuser/Documents/hw7.pdf... (5 Replies)
Discussion started by: cokedude
5 Replies

6. UNIX for Advanced & Expert Users

PDF to Text Conversion

Hi Guys, My OS is Suse Linux.. Is there a Command to convert PDF file to Text?? Cheers!!!!! (2 Replies)
Discussion started by: mac4rfree
2 Replies

7. Shell Programming and Scripting

Pdf to text

Is there a way using the pdf to text utility to convert all the pdf in a given directory? So instead of one at a time: pdftotext pdftotext hp-manual.pdf hp-manual.txt a directory of 50 pdf files would be converted: pdftotext /home/dnascopev/Desktop/PDF.pdf /home/dnascopev/Desktop/PDF.txt ... (6 Replies)
Discussion started by: cmccabe
6 Replies

8. Shell Programming and Scripting

Text to pdf

Is there a way to covert te attached text file to a pdf? I have tried: enscript-p output.ps article.txt PRE.cjk { font-family: "WenQuanYi Micro Hei",monospace; }PRE.ctl { font-family: "Lohit Hindi",monospace; }P { margin-bottom: 0.08in; } awk '{ A=$2; next} END { for (i in A) print... (7 Replies)
Discussion started by: cmccabe
7 Replies

9. HP-UX

Best text to pdf converter for Hp/UX 11.31

Hi, Can anyone tell me the best converter I can use to convert text to pdf for HP/UX 11.31? Thanks, Linda (0 Replies)
Discussion started by: lnemitz
0 Replies
gpdf(1)                                                            User Commands                                                           gpdf(1)

NAME
gpdf - view PDF documents SYNOPSIS
gpdf [gnome-std-options] [filename...] DESCRIPTION
The PDF Document Viewer application is based on xpdf. PDF Document Viewer provides viewing features such as panning, zoom in, zoom out, best fit, and fit width. OPTIONS
The following options are supported: gnome-std-options Standard options available for use with most GNOME applications. See gnome-std-options(5) for more information. OPERANDS
The following operands are supported: filename The name of the to be . EXAMPLES
Example 1: Launching the PDF Document Viewer example% gpdf Example 2: Opening the Document test.pdf in PDF Document Viewer example% gpdf test.pdf ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of gpdf: NLSPATH. EXIT STATUS
The following exit values are returned: 0 Application exited successfully >0 Application exited with failure FILES
The following files are used by this application: /usr/bin/gpdf Executable for PDF Document Viewer. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-* | +-----------------------------+-----------------------------+ |Interface stability |External | +-----------------------------+-----------------------------+ SEE ALSO
PDF Document Viewer Manual Latest version of the GNOME Desktop User Guide for your platform. gnome-std-options(5) NOTES
Written by Niall Power, Sun Microsystems Inc., 2003. SunOS 5.10 1 Oct 2003 gpdf(1)
All times are GMT -4. The time now is 10:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy