Skip to content

Commit

Permalink
Now page numbers in output according to input
Browse files Browse the repository at this point in the history
  • Loading branch information
abchk1234 committed Dec 31, 2013
1 parent 196c617 commit 1ede843
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pdf2png
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MainWindow(Gtk.Window):
aboutdialog.set_version("v0.2")
aboutdialog.set_comments("Convert PDF to multiple images in various formats\nlike PNG with a single mouse click\n")
aboutdialog.set_website("https://github.com/aadityabagga/pdf2png")
aboutdialog.set_website_label("Website\n")
aboutdialog.set_website_label("For more details, see Website\n")
aboutdialog.set_authors(["Aaron", "\nSpecial thanks to:\nAaditya"])
aboutdialog.set_license("""This program is free software;
you can redistribute it and/or modify it under the terms
Expand Down Expand Up @@ -91,11 +91,16 @@ for more details.""")
def pdf_to_img(self, chooser_dialog, pdffilepath):
pdfname, ext = os.path.splitext(chooser_dialog.get_filename())
resolution = self.entry.get_text()
arglist = ["gs", "-dBATCH", "-dNOPAUSE", "-dFirstPage={0}".format(self.spinbutton.get_text()), "-dLastPage={0}".format(self.spinbutton2.get_text()),
"-sOutputFile={0} page %01d.{1}".format(pdfname, self.comboboxtext2.get_active_text()),
"-sDEVICE={0}".format(self.comboboxtext.get_active_text()),"-r{0}".format(resolution), pdffilepath]
arglist = ["gs", "-dBATCH", "-dNOPAUSE", "-dFirstPage={0}".format(self.spinbutton.get_text()), "-dLastPage={0}".format(self.spinbutton2.get_text()), "-sOutputFile={0}_page_%01d.{1}".format(pdfname, self.comboboxtext2.get_active_text()), "-sDEVICE={0}".format(self.comboboxtext.get_active_text()),"-r{0}".format(resolution), pdffilepath]
sp = subprocess.Popen(args=arglist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sp.communicate()
sub = range(int(self.spinbutton2.get_text())+2 - int(self.spinbutton.get_text()))
ran1 = range(int(self.spinbutton.get_text())-1, int(self.spinbutton2.get_text())+1)
for (x, z) in (zip(ran1, sub)):
if z==0:
continue
else:
os.system('mv "{0}_page_{1}.{2}"'.format(pdfname, z, self.comboboxtext2.get_active_text()) + ' "{0} page {1}.{2}"'.format(pdfname, x, self.comboboxtext2.get_active_text()))

def __init__(self):
Gtk.Window.__init__(self, title="PDF to PNG")
Expand All @@ -115,7 +120,7 @@ for more details.""")

self.entry = Gtk.Entry()
self.entry.set_width_chars(1)
self.entry.set_text("100")
self.entry.set_text("200")
self.entry.set_max_length(4)
grid.attach(self.entry, Gtk.PositionType.LEFT, 2, 1, 1)

Expand Down

0 comments on commit 1ede843

Please sign in to comment.