Skip to content

Commit aa6e880

Browse files
committed
Add paper size config for push to save
1 parent 2e628c9 commit aa6e880

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

internal/config/store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ type Settings struct {
2424
FTPPassword string `json:"ftpPassword"`
2525
PaperlessURL string `json:"paperlessUrl"`
2626
PaperlessToken string `json:"paperlessToken"`
27-
ForcePaperAuto bool `json:"forcePaperAuto"` // AirScan: force paper auto-detect by constraining max area to A4
27+
ForcePaperAuto bool `json:"forcePaperAuto"` // AirScan: force paper auto-detect for eSCL clients
28+
PaperSize string `json:"paperSize"` // button scan paper size: "auto", "a4", "a5", "business_card", "postcard"
2829
}
2930

3031
// DefaultSettings returns the default scan settings.

internal/scanner/savejob.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,31 @@ func SettingsToScanConfig(s config.Settings) vens.ScanConfig {
104104
}
105105
cfg.BleedThrough = s.BleedThrough
106106
cfg.BWDensity = s.BWDensity
107+
108+
// Paper size for button scan
109+
switch s.PaperSize {
110+
case "a4":
111+
cfg.PaperSize = vens.PaperA4
112+
dim := vens.PaperDimensions[vens.PaperA4]
113+
cfg.PaperWidth = dim.Width
114+
cfg.PaperHeight = dim.Height
115+
case "a5":
116+
cfg.PaperSize = vens.PaperA5
117+
dim := vens.PaperDimensions[vens.PaperA5]
118+
cfg.PaperWidth = dim.Width
119+
cfg.PaperHeight = dim.Height
120+
case "business_card":
121+
cfg.PaperSize = vens.PaperBusinessCard
122+
dim := vens.PaperDimensions[vens.PaperBusinessCard]
123+
cfg.PaperWidth = dim.Width
124+
cfg.PaperHeight = dim.Height
125+
case "postcard":
126+
cfg.PaperSize = vens.PaperPostcard
127+
dim := vens.PaperDimensions[vens.PaperPostcard]
128+
cfg.PaperWidth = dim.Width
129+
cfg.PaperHeight = dim.Height
130+
}
131+
107132
return cfg
108133
}
109134

internal/webui/static/index.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@
193193
</div>
194194
</div>
195195

196+
<div class="field">
197+
<label class="label is-small" x-text="t('paperSize')"></label>
198+
<div class="control">
199+
<div class="select is-fullwidth">
200+
<select x-model="scanConfig.paperSize" @change="debounceSaveSettings()">
201+
<template x-for="ps in ['auto', 'a4', 'a5', 'business_card', 'postcard']" :key="ps">
202+
<option :value="ps" x-text="t('paper_' + ps)"></option>
203+
</template>
204+
</select>
205+
</div>
206+
</div>
207+
</div>
208+
196209
<div class="field">
197210
<label class="label is-small" x-text="t('outputFormat')"></label>
198211
<div class="control">
@@ -468,7 +481,7 @@
468481
status: null,
469482
tick: 0,
470483
lang: localStorage.getItem('lang') || (navigator.language.startsWith('ja') ? 'ja' : 'en'),
471-
scanConfig: { colorMode: 'auto', resolution: '0', duplex: false, format: 'application/pdf', blankPageRemoval: true, bleedThrough: false, bwDensity: 0, saveType: 'none', savePath: '', ftpHost: '', ftpUser: '', ftpPassword: '', paperlessUrl: '', paperlessToken: '', forcePaperAuto: false },
484+
scanConfig: { colorMode: 'auto', resolution: '0', duplex: false, format: 'application/pdf', blankPageRemoval: true, bleedThrough: false, bwDensity: 0, paperSize: 'auto', saveType: 'none', savePath: '', ftpHost: '', ftpUser: '', ftpPassword: '', paperlessUrl: '', paperlessToken: '', forcePaperAuto: false },
472485
scanJob: { scanning: false, lastError: '', lastScan: '', pages: 0, filePath: '' },
473486
scanPreview: { scanning: false, error: '', pages: [], showModal: false, currentPage: 0 },
474487
settingsReady: false,
@@ -522,6 +535,7 @@
522535
ftpPassword: s.ftpPassword || '',
523536
paperlessUrl: s.paperlessUrl || '',
524537
paperlessToken: s.paperlessToken || '',
538+
paperSize: s.paperSize || 'auto',
525539
forcePaperAuto: s.forcePaperAuto || false,
526540
};
527541
this.clampToCapabilities();
@@ -573,6 +587,7 @@
573587
ftpPassword: this.scanConfig.ftpPassword,
574588
paperlessUrl: this.scanConfig.paperlessUrl,
575589
paperlessToken: this.scanConfig.paperlessToken,
590+
paperSize: this.scanConfig.paperSize,
576591
forcePaperAuto: this.scanConfig.forcePaperAuto,
577592
};
578593
const resp = await fetch('api/settings', {

internal/webui/static/messages.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ const MESSAGES = {
6969
modeGrayscale: { en: 'Grayscale', ja: 'グレースケール' },
7070
modeBW: { en: 'B&W', ja: '白黒' },
7171

72+
// Paper size
73+
paperSize: { en: 'Paper Size', ja: '用紙サイズ' },
74+
paper_auto: { en: 'Auto', ja: '自動' },
75+
paper_a4: { en: 'A4', ja: 'A4' },
76+
paper_a5: { en: 'A5', ja: 'A5' },
77+
paper_business_card: { en: 'Biz Card', ja: '名刺' },
78+
paper_postcard: { en: 'Postcard', ja: 'はがき' },
79+
7280
// AirScan settings
7381
airscanSettings: { en: 'AirScan Settings', ja: 'AirScan 設定' },
7482
forcePaperAuto: { en: 'Auto paper size detect', ja: '用紙サイズ自動検出' },

0 commit comments

Comments
 (0)