feat(注解转换): 修正注解转换与图像导出
build.yaml / build (push) Successful in 52s

This commit is contained in:
xiaoqidun committed 2026-10-04 23:24:49 +08:00
1 parent d09c57f226
commit 5dcd7a4e8d
7 files changed
+61 -21

No files matched your search

+9 -13
View File
@@ -48,18 +48,11 @@ func (p *pdfImporter) appearanceAnnotation(ctx context.Context, page *pdfgo.Page
annotation.Dictionary = maps.Clone(annotation.Dictionary)
annotation.Dictionary["Contents"] = pdfgo.String("\xef\xbb\xbf" + remark)
}
flags := int64(0)
if value := annotation.Dictionary["F"]; value != nil {
resolved, err := p.reader.Resolve(value)
if err != nil {
return err
}
number, ok := resolved.(pdfgo.Integer)
if !ok {
return fmt.Errorf("invalid PDF annotation flags")
}
flags = int64(number)
flags, err := p.reader.ReadAnnotationFlags(annotation)
if err != nil {
return err
}
invisible := flags&1 != 0 && !annotation.IsStandard()
if flags&256 != 0 {
return &pdfgo.UnsupportedError{Feature: "annotation ToggleNoView flag"}
}
@@ -101,7 +94,7 @@ func (p *pdfImporter) appearanceAnnotation(ctx context.Context, page *pdfgo.Page
if err := stamp.compositeObjects(nodes); err != nil {
return err
}
if flags&(2|32) == 0 {
if flags&(2|32) == 0 && !invisible {
p.compositeNodes = stamp.compositeNodes
p.transferBackdrop = stamp.transferBackdrop
}
@@ -142,7 +135,7 @@ func (p *pdfImporter) appearanceAnnotation(ctx context.Context, page *pdfgo.Page
region.Fill, region.Stroke, region.Actions = &no, &no, actions
converted.Appearance.Objects = append(converted.Appearance.Objects, GraphicObject{Type: "PathObject", PathObject: region})
}
if flags&(2|32) != 0 {
if flags&(2|32) != 0 || invisible {
visible := false
converted.Visible = &visible
}
@@ -194,6 +187,9 @@ func pdfAnnotationType(subtype pdfgo.Name) string {
case "Text", "FreeText", "Line", "Square", "Circle", "Polygon", "PolyLine", "Caret", "Ink", "FileAttachment", "Sound", "Movie", "Screen", "Link", "Popup", "Widget", "PrinterMark", "TrapNet", "3D", "RichMedia", "Redact":
return "Path"
}
if !(pdfgo.Annotation{Subtype: subtype}).IsStandard() {
return "Path"
}
return ""
}