Skip to content

Commit 911ef42

Browse files
committed
Updated pdf_add_image_alt_text.go
1 parent da87051 commit 911ef42

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

accessibility/pdf_add_image_alt_text.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func main() {
4949

5050
// Construct base K dictionary.
5151
docK := model.NewKDictionary()
52-
docK.S = core.MakeName(model.StructureTypeDocument)
52+
docK.S = core.MakeName(string(model.StructureTypeDocument))
5353
// Manually set optional ID for the K object
5454
docK.ID = core.MakeString(kIds[0])
5555
// Or generate the ID automatically using the following:
@@ -62,7 +62,7 @@ func main() {
6262
pageMarkedContentSection := model.NewKDictionary()
6363

6464
// Set the structure type to Section.
65-
pageMarkedContentSection.S = core.MakeName(model.StructureTypeSection)
65+
pageMarkedContentSection.S = core.MakeName(string(model.StructureTypeSection))
6666
pageMarkedContentSection.ID = core.MakeString(kIds[1])
6767

6868
// Add as a child
@@ -105,7 +105,12 @@ func addImage(c *creator.Creator, imageFile string, x, y float64, mcid int64, al
105105
}
106106

107107
// Add the image to the marked content section.
108-
altKdictEntry := img.SetMarkedContentID(mcid)
108+
img.SetMarkedContentID(mcid)
109+
110+
altKdictEntry, err := img.GenerateKDict()
111+
if err != nil {
112+
fmt.Errorf("Error: %v", err)
113+
}
109114

110115
// Set the alternate text.
111116
altKdictEntry.Alt = core.MakeString(altText)

0 commit comments

Comments
 (0)