mirror of
https://github.com/unidoc/unipdf.git
synced 2025-04-30 13:48:51 +08:00
Fix for handling non-widget annotations per page when flattening
This commit is contained in:
parent
4a89eddcfc
commit
2522849b19
@ -36,6 +36,8 @@ func (pdf *PdfReader) FlattenFields(allannots bool) error {
|
|||||||
fields := acroForm.AllFields()
|
fields := acroForm.AllFields()
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
for _, wa := range field.Annotations {
|
for _, wa := range field.Annotations {
|
||||||
|
// TODO(gunnsth): Check if wa.Flags() has Print flag then include, otherwise exclude.
|
||||||
|
|
||||||
// XXX/FIXME: May be better to check field.V only if no appearance stream available.
|
// XXX/FIXME: May be better to check field.V only if no appearance stream available.
|
||||||
if field.V != nil {
|
if field.V != nil {
|
||||||
ftargets[wa.PdfAnnotation] = true
|
ftargets[wa.PdfAnnotation] = true
|
||||||
@ -56,8 +58,8 @@ func (pdf *PdfReader) FlattenFields(allannots bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go through all pages and flatten specified annotations.
|
// Go through all pages and flatten specified annotations.
|
||||||
annots := []*PdfAnnotation{}
|
|
||||||
for _, page := range pdf.PageList {
|
for _, page := range pdf.PageList {
|
||||||
|
annots := []*PdfAnnotation{}
|
||||||
for _, annot := range page.Annotations {
|
for _, annot := range page.Annotations {
|
||||||
hasV, toflatten := ftargets[annot]
|
hasV, toflatten := ftargets[annot]
|
||||||
if !toflatten {
|
if !toflatten {
|
||||||
@ -96,7 +98,7 @@ func (pdf *PdfReader) FlattenFields(allannots bool) error {
|
|||||||
page.Resources.SetXObjectFormByName(name, xform)
|
page.Resources.SetXObjectFormByName(name, xform)
|
||||||
|
|
||||||
// XXX/TODO: Take Matrix and potential scaling of annotation Rect and appearance BBox into account.
|
// XXX/TODO: Take Matrix and potential scaling of annotation Rect and appearance BBox into account.
|
||||||
// Have yet to find a case where that actually happens.
|
// Have yet to find a case where that actually is required.
|
||||||
|
|
||||||
// Placement for XForm.
|
// Placement for XForm.
|
||||||
xRect := math.Min(rect.Llx, rect.Urx)
|
xRect := math.Min(rect.Llx, rect.Urx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user