Skip to content

Commit

Permalink
3.1.2 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Averell7 committed Jul 5, 2019
1 parent e8a8dc1 commit c0d41c7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import tarfile

def fix_bin_file(file1):
data1 = b"#!/usr/lib/python3\n"
data1 = b"#!/usr/bin/python3\n"
data1b = file1.readline()
data2 = file1.read()
data3 = data1 + data2
Expand Down
46 changes: 18 additions & 28 deletions pdfbooklet/pdfbooklet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,8 @@ def setupGui(self, inifile = "") :
if config.getint("options", "advanced") == 1 : self.advanced.set_active(1)
else : self.advanced.set_active(0)
self.guiAdvanced()
if "autoScale" in config["options"] :
if bool_test(config["options"]["autoScale"]) == True :
if "autoscale" in config["options"] :
if bool_test(config["options"]["autoscale"]) == True :
self.autoscale.set_active(1)
else :
self.autoscale.set_active(0)
Expand Down Expand Up @@ -2032,7 +2032,7 @@ def makeIniFile(self, inifile = "") :
config["options"]["repeat"] = str(self.arw["entry15"].get_text())
config["options"]["showPdf"] = str(self.arw["show"].get_active())
config["options"]["saveSettings"] = str(self.settings.get_active())
config["options"]["autoScale"] = str(self.autoscale.get_active())
config["options"]["autoscale"] = str(self.autoscale.get_active())
config["options"]["width"] = str(self.arw["outputWidth"].get_text())
config["options"]["height"] = str(self.arw["outputHeight"].get_text())

Expand Down Expand Up @@ -4072,7 +4072,7 @@ def centeredRotation(self, Rotate, myrows_i = 1, mycolumns_i = 1) :

return (sin_l, cos_l, Hcorr, Vcorr)

def autoScaleAndRotate(self, fileNum, page) :
def CalcAutoScale(self, fileNum, page) :
global inputFiles_a, inputFile_a, refPageSize_a

fileName = inputFiles_a[fileNum]
Expand All @@ -4087,32 +4087,22 @@ def autoScaleAndRotate(self, fileNum, page) :

(ref_width, ref_height) = refPageSize_a

# check source orientation
if ref_height > ref_width :
ref_orientation = "portrait"
else :
ref_orientation = "paysage"

# check page orientation
if page_height > page_width :
page_orientation = "portrait"
else :
page_orientation = "paysage"


if ref_orientation == page_orientation : # orientation is the same
delta1 = ref_height / page_height
delta2 = ref_width / page_width
else :
delta1 = ref_height / page_width
delta2 = ref_width / page_height
delta1 = ref_height / page_height
delta2 = ref_width / page_width
Vdiff = ref_height - (page_height * delta2)
Hdiff = ref_width - (page_width * delta1)

# Choose the lower factor, and calculate the translation for centering the image
if delta1 < delta2 :
Scale = delta1
Vtranslate = 0
Htranslate = Hdiff/2
else:
Scale = delta2
Vtranslate = Vdiff/2
Htranslate = 0

return Scale
return (Scale, Htranslate, Vtranslate)


def parsePageSelection(self, selection = "", append_prepend = 1) :
Expand Down Expand Up @@ -4609,10 +4599,10 @@ def createNewPdf(self, ar_pages, ar_layout, ar_cahiers, outputFile, preview = -1


# scale the page to fit the output sheet, if required
if"autoScale" in config["options"]:
if ini.readBoolean(config["options"]["autoScale"]) == True :
scaleFactor_f = self.autoScaleAndRotate(file_number, page_number)
matrix1_s = self.calcMatrix2(0, 0, Scale = scaleFactor_f)
if"autoscale" in config["options"]:
if ini.readBoolean(config["options"]["autoscale"]) == True :
(scaleFactor_f, Htranslate, Vtranslate) = self.CalcAutoScale(file_number, page_number)
matrix1_s = self.calcMatrix2(Htranslate, Vtranslate, Scale = scaleFactor_f)
data_x.append(matrix1_s)

file_name = inputFiles_a[file_number]
Expand Down

0 comments on commit c0d41c7

Please sign in to comment.