feat(能力完善): 完善转换保真,修复交互缺陷
build.yaml / build (push) Successful in 2m26s

This commit is contained in:
xiaoqidun committed 2026-10-10 09:48:05 +08:00
1 parent 0ad34ee2b1
commit 0ad2bda1f7
47 files changed
+2849 -522

No files matched your search

+6 -11
View File
@@ -15,7 +15,6 @@
package ofdgo
import (
"bytes"
"context"
"fmt"
"io"
@@ -159,19 +158,15 @@ func Convert(ctx context.Context, source io.ReaderAt, size int64, output io.Writ
if err = progress("open", 0, 0); err != nil {
return report, err
}
if source == nil || size <= 0 {
return report, fmt.Errorf("empty document source")
}
source = convertReader{context: ctx, source: source}
report.Input = strings.ToLower(strings.TrimSpace(options.Input))
if report.Input == "" {
var header [1024]byte
n, readErr := source.ReadAt(header[:], 0)
if readErr != nil && readErr != io.EOF {
return report, readErr
}
switch {
case bytes.HasPrefix(header[:n], []byte("PK\x03\x04")):
report.Input = "ofd"
case bytes.Contains(header[:n], []byte("%PDF-")):
report.Input = "pdf"
report.Input, err = DetectFormat(source, size)
if err != nil {
return report, err
}
}
var reader *Reader