Skip to content

Commit

Permalink
update: 添加根据文本内容去水印功能
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin2li committed Jul 26, 2023
1 parent f9fd0c1 commit 76d7e01
Show file tree
Hide file tree
Showing 12 changed files with 1,362 additions and 112 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [安装](#安装)
- [使用](#使用)
- [FAQ](#faq)
- [Star History](#star-history)
- [Authors](#authors)
- [License](#license)
- [Acknowledgments](#acknowledgments)
Expand Down Expand Up @@ -406,6 +407,11 @@ chmod +x "${PWD}/PDF Guru.app/Contents/MacOS/PDF Guru"

![](https://minio.kevin2li.top/image-bed/blog/20230715195747.png)

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=kevin2li/PDF-Guru&type=Date)](https://star-history.com/#kevin2li/PDF-Guru&Date)


## Authors

[@Kevin2li](https://github.com/kevin2li)
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/Forms/AnkiForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,11 @@ export default defineComponent({
message.error("请选择父牌组");
return;
}
if(store.modelname === undefined){
message.error("请选择模板");
return;
if(store.card_type === "qa"){
if(store.modelname === undefined){
message.error("请选择模板");
return;
}
}
switch (store.card_type) {
case "mask": {
Expand Down
367 changes: 367 additions & 0 deletions frontend/src/components/Forms/AnnotForm.vue

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions frontend/src/components/Forms/WatermarkForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<a-radio value="type">类型水印</a-radio>
<a-radio value="mask">遮罩水印</a-radio>
<a-radio value="index">内容水印</a-radio>
<a-radio value="text">(可编辑)文字水印</a-radio>
</a-radio-group>
</a-form-item>
<div v-if="store.remove_method === 'type'">
Expand Down Expand Up @@ -306,6 +307,11 @@
<a-input v-model:value="store.page" placeholder="应用的页码范围(留空表示全部), e.g. 1-10" allow-clear />
</a-form-item>
</div>
<div v-if="store.remove_method === 'text'">
<a-form-item name="wm_text" label="水印文本">
<a-input v-model:value="store.wm_text" placeholder="水印文本内容,支持正则,e.g. 内部资料" allow-clear />
</a-form-item>
</div>
</div>
<a-form-item name="input" label="输入" :validateStatus="validateStatus.input" :help="validateHelp.input">
<div>
Expand Down Expand Up @@ -357,8 +363,7 @@ import {
WatermarkPDFByText,
WatermarkPDFByImage,
WatermarkPDFByPDF,
RemoveWatermarkByIndex,
RemoveWatermarkByType,
RemoveWatermark,
DetectWatermarkByIndex,
MaskPDFByAnnot,
MaskPDFByRect
Expand Down Expand Up @@ -558,7 +563,14 @@ export default defineComponent({
case "remove": {
switch (store.remove_method) {
case "type": {
await handleOps(RemoveWatermarkByType, [store.input, store.output, store.page]);
await handleOps(RemoveWatermark, [
store.input,
store.output,
"type",
[],
"",
store.page,
]);
break;
}
case "index": {
Expand All @@ -570,7 +582,14 @@ export default defineComponent({
}
case "2": {
let wm_index = store.wm_index.split(",").map((item) => parseInt(item.trim()) - 1);
await handleOps(RemoveWatermarkByIndex, [store.input, store.output, wm_index, store.page]);
await handleOps(RemoveWatermark, [
store.input,
store.output,
"index",
wm_index,
"",
store.page
]);
break;
}
}
Expand All @@ -589,6 +608,17 @@ export default defineComponent({
}
break;
}
case "text": {
await handleOps(RemoveWatermark, [
store.input,
store.output,
"text",
[],
store.wm_text,
store.page,
]);
break;
}
}
break;
}
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ interface WatermarkState {
remove_method: string;
step: string;
wm_index: string;
wm_text: string;
wm_path: string;
scale: number;
mask_type: string;
Expand Down Expand Up @@ -318,6 +319,13 @@ interface SignState {
font_color: string;
}

interface AnnotState {
input: string;
output: string;
op: string;
types: string[];
}

interface AnkiState {
input: string;
output: string;
Expand Down Expand Up @@ -477,6 +485,7 @@ export type {
DualLayerState,
CrackState,
SignState,
AnnotState,
AnkiState,
IndexState,
};
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/store/watermark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const useWatermarkState = defineStore("WatermarkState", {
remove_method: "type",
step: "1",
wm_index: "",
wm_text: "",
lines: 0,
wm_path: "",
scale: 1,
Expand Down Expand Up @@ -61,6 +62,7 @@ export const useWatermarkState = defineStore("WatermarkState", {
remove_method: "type",
step: "1",
wm_index: "",
wm_text: "",
lines: 0,
wm_path: "",
scale: 1,
Expand Down
4 changes: 1 addition & 3 deletions frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ export function RemovePDFHeaderAndFooter(arg1:string,arg2:string,arg3:Array<numb

export function RemovePDFPageNumber(arg1:string,arg2:string,arg3:Array<number>,arg4:string,arg5:string,arg6:string):Promise<void>;

export function RemoveWatermarkByIndex(arg1:string,arg2:string,arg3:Array<number>,arg4:string):Promise<void>;

export function RemoveWatermarkByType(arg1:string,arg2:string,arg3:string):Promise<void>;
export function RemoveWatermark(arg1:string,arg2:string,arg3:string,arg4:Array<number>,arg5:string,arg6:string):Promise<void>;

export function ReorderPDF(arg1:string,arg2:string,arg3:string):Promise<void>;

Expand Down
8 changes: 2 additions & 6 deletions frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,8 @@ export function RemovePDFPageNumber(arg1, arg2, arg3, arg4, arg5, arg6) {
return window['go']['main']['App']['RemovePDFPageNumber'](arg1, arg2, arg3, arg4, arg5, arg6);
}

export function RemoveWatermarkByIndex(arg1, arg2, arg3, arg4) {
return window['go']['main']['App']['RemoveWatermarkByIndex'](arg1, arg2, arg3, arg4);
}

export function RemoveWatermarkByType(arg1, arg2, arg3) {
return window['go']['main']['App']['RemoveWatermarkByType'](arg1, arg2, arg3);
export function RemoveWatermark(arg1, arg2, arg3, arg4, arg5, arg6) {
return window['go']['main']['App']['RemoveWatermark'](arg1, arg2, arg3, arg4, arg5, arg6);
}

export function ReorderPDF(arg1, arg2, arg3) {
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
build
*.spec
*.spec
*cache*
Loading

0 comments on commit 76d7e01

Please sign in to comment.