Skip to content

Commit d179367

Browse files
Add files via upload
1 parent af7f49b commit d179367

8 files changed

+288
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func DeletePageAnnotations(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, output_name string) {
10+
// Delete annotation from the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": REMOTE_FOLDER,
14+
}
15+
16+
_, httpResponse, err := pdf_api.DeletePageAnnotations(document_name, page_num, args)
17+
if err != nil {
18+
fmt.Println(err.Error())
19+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
20+
fmt.Println("DeletePageAnnotations(): Failed to delete annotation from the document.")
21+
} else {
22+
fmt.Println("DeletePageAnnotations(): annotations on page '", page_num, "' deleted from the document '"+document_name+"'.")
23+
DownloadFile(pdf_api, document_name, output_name, "del_page_annotations_")
24+
}
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func DeleteAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, annotation_id string, output_name string) {
10+
// Delete annotation from the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": REMOTE_FOLDER,
14+
}
15+
16+
_, httpResponse, err := pdf_api.DeleteAnnotation(document_name, annotation_id, args)
17+
if err != nil {
18+
fmt.Println(err.Error())
19+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
20+
fmt.Println("DeleteAnnotation(): Failed to delete annotation from the document page.")
21+
} else {
22+
DeletePopupAnnotations(pdf_api, document_name, annotation_id)
23+
fmt.Println("DdeleteAnnotation(): annotation '" + annotation_id + "' deleted from the document '" + document_name + "'.")
24+
DownloadFile(pdf_api, document_name, output_name, "del_annotation_")
25+
}
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func RequestAnnotationById(pdf_api *asposepdfcloud.PdfApiService, document_name string, annotation_id string, remote_folder string) {
10+
// Get annotation from the page in the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
result, httpResponse, err := pdf_api.GetTextAnnotation(document_name, annotation_id, args)
16+
if err != nil {
17+
fmt.Println(err.Error())
18+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
19+
fmt.Println("RequestAnnotationById(): Failed to delete annotation from the document page.")
20+
} else {
21+
fmt.Println("RequestAnnotationById(): annotation '" + annotation_id + "' successfully found '" + result.Annotation.Contents + "' in the document '" + document_name + "'.")
22+
}
23+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func RequestAnnotations(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, remote_folder string) string {
10+
// Get annotations from the page in the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
annotation_result := ""
16+
result, httpResponse, err := pdf_api.GetPageAnnotations(document_name, page_num, args)
17+
if err != nil {
18+
fmt.Println(err.Error())
19+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
20+
fmt.Println("RequestAnnotations(): Failed to delete annotation from the document page.")
21+
} else {
22+
for _, annotation := range result.Annotations.List {
23+
if annotation.AnnotationType == asposepdfcloud.AnnotationTypeText {
24+
fmt.Println("RequestAnnotations(): annotation id=", annotation.Id, " with '"+annotation.Contents+"' content get from the document '"+document_name+"' on ", annotation.PageIndex, " page.")
25+
annotation_result := annotation.Id
26+
return annotation_result
27+
}
28+
}
29+
}
30+
fmt.Println("RequestAnnotations(): Failed to get annotation in the document.")
31+
return annotation_result
32+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func AppendHighlightAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, output_document string, prefix string, remote_folder string) {
10+
// Append a new highlight text annotation to the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
new_annotation := asposepdfcloud.HighlightAnnotation{
16+
Name: "Highlight_Text_Annotation",
17+
Rect: &asposepdfcloud.Rectangle{LLX: 100, LLY: 350, URX: 450, URY: 400},
18+
Flags: []asposepdfcloud.AnnotationFlags{asposepdfcloud.AnnotationFlagsDefault},
19+
HorizontalAlignment: asposepdfcloud.HorizontalAlignmentLeft,
20+
VerticalAlignment: asposepdfcloud.VerticalAlignmentTop,
21+
RichText: NEW_HL_ANNOTATION_TEXT,
22+
Subject: NEW_HL_ANNOTATION_SUBJECT,
23+
Contents: NEW_HL_ANNOTATION_CONTENTS,
24+
Title: NEW_HL_ANNOTATION_DESCRIPTION,
25+
ZIndex: 1,
26+
Color: &asposepdfcloud.Color{A: 0xFF, R: 0x00, G: 0xFF, B: 0x00},
27+
QuadPoints: []asposepdfcloud.Point{
28+
{X: 10, Y: 10},
29+
{X: 20, Y: 10},
30+
{X: 10, Y: 20},
31+
{X: 10, Y: 10},
32+
},
33+
Modified: "03/27/2025 00:00:00.000 AM",
34+
}
35+
_, httpResponse, err := pdf_api.PostPageHighlightAnnotations(document_name, page_num, []asposepdfcloud.HighlightAnnotation{new_annotation}, args)
36+
if err != nil {
37+
fmt.Println(err.Error())
38+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
39+
fmt.Println("AppendHighlightAnnotation(): Failed to append annotation to the document page.")
40+
} else {
41+
fmt.Println("AppendHighlightAnnotation(): annotation '" + NEW_HL_ANNOTATION_TEXT + "' added to the document '" + document_name + "'.")
42+
DownloadFile(pdf_api, document_name, output_document, prefix)
43+
}
44+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func AppendStrikeoutAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, output_document string, prefix string, remote_folder string) {
10+
// Append a new strikeout text annotation to the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
16+
new_annotation := asposepdfcloud.StrikeOutAnnotation{
17+
Name: "Highlight_Text_Annotation",
18+
Rect: &asposepdfcloud.Rectangle{LLX: 100, LLY: 350, URX: 450, URY: 400},
19+
Flags: []asposepdfcloud.AnnotationFlags{asposepdfcloud.AnnotationFlagsDefault},
20+
HorizontalAlignment: asposepdfcloud.HorizontalAlignmentLeft,
21+
VerticalAlignment: asposepdfcloud.VerticalAlignmentTop,
22+
RichText: NEW_SO_ANNOTATION_TEXT,
23+
Subject: NEW_SO_ANNOTATION_SUBJECT,
24+
Contents: NEW_SO_ANNOTATION_CONTENTS,
25+
Title: NEW_SO_ANNOTATION_DESCRIPTION,
26+
ZIndex: 1,
27+
Color: &asposepdfcloud.Color{A: 0xFF, R: 0x00, G: 0xFF, B: 0x00},
28+
QuadPoints: []asposepdfcloud.Point{
29+
{X: 10, Y: 10},
30+
{X: 20, Y: 10},
31+
{X: 10, Y: 20},
32+
{X: 10, Y: 10},
33+
},
34+
Modified: "03/27/2025 00:00:00.000 AM",
35+
}
36+
37+
_, httpResponse, err := pdf_api.PostPageStrikeOutAnnotations(document_name, page_num, []asposepdfcloud.StrikeOutAnnotation{new_annotation}, args)
38+
if err != nil {
39+
fmt.Println(err.Error())
40+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
41+
fmt.Println("AppendStrikeoutAnnotation(): Failed to append annotation to the document page.")
42+
} else {
43+
fmt.Println("AppendStrikeoutAnnotation(): annotation '" + NEW_SO_ANNOTATION_TEXT + "' added to the document '" + document_name + "'.")
44+
DownloadFile(pdf_api, document_name, output_document, prefix)
45+
}
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func AppendTextAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, output_document string, prefix string, remote_folder string) {
10+
// Append a new free text annotation to the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
16+
text_style := asposepdfcloud.TextStyle{
17+
FontSize: 20,
18+
Font: "Arial",
19+
ForegroundColor: &asposepdfcloud.Color{A: 0xFF, R: 0x00, G: 0xFF, B: 0x00},
20+
BackgroundColor: &asposepdfcloud.Color{A: 0xFF, R: 0xFF, G: 0x00, B: 0x00},
21+
}
22+
23+
new_annotation := asposepdfcloud.FreeTextAnnotation{
24+
Rect: &asposepdfcloud.Rectangle{LLX: 100, LLY: 350, URX: 450, URY: 400},
25+
TextStyle: &text_style,
26+
Name: "Free Text Annotation",
27+
Flags: []asposepdfcloud.AnnotationFlags{asposepdfcloud.AnnotationFlagsDefault},
28+
HorizontalAlignment: asposepdfcloud.HorizontalAlignmentCenter,
29+
Intent: asposepdfcloud.FreeTextIntentFreeTextTypeWriter,
30+
RichText: NEW_FT_ANNOTATION_TEXT,
31+
Subject: NEW_FT_ANNOTATION_SUBJECT,
32+
Contents: NEW_FT_ANNOTATION_CONTENTS,
33+
Title: NEW_FT_ANNOTATION_DESCRIPTION,
34+
ZIndex: 1,
35+
Justification: asposepdfcloud.JustificationCenter,
36+
}
37+
38+
_, httpResponse, err := pdf_api.PostPageFreeTextAnnotations(document_name, page_num, []asposepdfcloud.FreeTextAnnotation{new_annotation}, args)
39+
if err != nil {
40+
fmt.Println(err.Error())
41+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
42+
fmt.Println("AppendTextAnnotation(): Failed to append annotation to the document page.")
43+
} else {
44+
fmt.Println("AppendTextAnnotation(): annotation '" + NEW_FT_ANNOTATION_TEXT + "' added to the document '" + document_name + "'.")
45+
DownloadFile(pdf_api, document_name, output_document, prefix)
46+
}
47+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
7+
)
8+
9+
func AppendUnderlineAnnotation(pdf_api *asposepdfcloud.PdfApiService, document_name string, page_num int32, output_document string, prefix string, remote_folder string) {
10+
// Append a new underline text annotation to the PDF document.
11+
UploadFile(pdf_api, document_name)
12+
args := map[string]interface{}{
13+
"folder": remote_folder,
14+
}
15+
16+
new_annotation := asposepdfcloud.UnderlineAnnotation{
17+
Rect: &asposepdfcloud.Rectangle{LLX: 100, LLY: 350, URX: 450, URY: 400},
18+
Name: "Underline Text Annotation",
19+
Flags: []asposepdfcloud.AnnotationFlags{asposepdfcloud.AnnotationFlagsDefault},
20+
HorizontalAlignment: asposepdfcloud.HorizontalAlignmentLeft,
21+
VerticalAlignment: asposepdfcloud.VerticalAlignmentTop,
22+
RichText: NEW_UL_ANNOTATION_TEXT,
23+
Subject: NEW_UL_ANNOTATION_SUBJECT,
24+
Title: NEW_UL_ANNOTATION_DESCRIPTION,
25+
Contents: NEW_UL_ANNOTATION_CONTENTS,
26+
ZIndex: 1,
27+
Color: &asposepdfcloud.Color{A: 0xFF, R: 0x00, G: 0xFF, B: 0x00},
28+
QuadPoints: []asposepdfcloud.Point{
29+
{X: 10, Y: 10},
30+
{X: 20, Y: 10},
31+
{X: 10, Y: 20},
32+
{X: 10, Y: 10},
33+
},
34+
Modified: "03/27/2025 00:00:00.000 AM",
35+
}
36+
_, httpResponse, err := pdf_api.PostPageUnderlineAnnotations(document_name, page_num, []asposepdfcloud.UnderlineAnnotation{new_annotation}, args)
37+
if err != nil {
38+
fmt.Println(err.Error())
39+
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
40+
fmt.Println("AppendUnderlineAnnotation(): Failed to append annotation to the document page.")
41+
} else {
42+
fmt.Println("AppendUnderlineAnnotation(): annotation '" + NEW_UL_ANNOTATION_TEXT + "' added to the document '" + document_name + "'.")
43+
DownloadFile(pdf_api, document_name, output_document, prefix)
44+
}
45+
}

0 commit comments

Comments
 (0)