Evaluation Questions - Adding annotation to all pages

Discussions about DocuVieware integration in GdPicture.NET.
Post Reply
Posts: 2
Joined: Tue Dec 12, 2017 5:48 pm

Evaluation Questions - Adding annotation to all pages

Post by radshat » Tue Dec 12, 2017 5:57 pm


I would like to evaluate DocuVieware being integrated within our ASP.NET MVC application and would just like to ask a few questions.

I need to add annotations to a PDF programmatically. I see this can be done through JavaScript or through a Custom Action on the Server-Side. What I could not figure out is how to add an annotation(for example a footer) to every page of the PDF but also allow that annotation to be moved. The following code only adds the annotation to the first page. What am I doing wrong?

Code: Select all

			GdPicturePDF gdPicturePDF = new GdPicturePDF();
            customActionEventArgs.docuVieware.GetNativePDF(out gdPicturePDF);            

            var pages = gdPicturePDF.GetPageCount();
            for (int page = 1; page < gdPicturePDF.GetPageCount(); page++)

                var id = "footer_page_" + page.ToString();
                CleanAnnotation(annotationManager, id );
                AnnotationText myAnnot = annotationManager.AddTextAnnot(0.2f, 0.2f, 3.0f, 0.2f, "FOOTER");             
                myAnnot.AutoSize = true;
                myAnnot.Fill = false;
                myAnnot.Stroke = false;
                myAnnot.FontName = "Courier New";
                myAnnot.ForeColor = Color.Red;
                myAnnot.FontSize = 20;
                myAnnot.CanEditText = false;
                myAnnot.Tag = id;


Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Evaluation Questions - Adding annotation to all pages

Post by Cedric » Tue Jan 22, 2019 5:09 pm

I don't think the approach is correct, you can do this completely client side without having to implement a custom action using the JavaScript API.
In a nutshell all you have to do is use the on document loaded and, create an annotation object for each page and finally add the annotations in a single call. Everything else will be taken care of behind the scene for you automatically.

The equivalent to your code would give something like this:

Code: Select all

function RegisterOnNewDocumentLoadedOnDocuViewareAPIReady() {
    if (typeof DocuViewareAPI !== "undefined" && DocuViewareAPI.IsInitialized("DocuVieware1")) {
        DocuViewareAPI.RegisterOnNewDocumentLoaded("DocuVieware1", function () {
            var pageCount = DocuViewareAPI.GetPageCount("DocuVieware1");
            var annotations = new Array();
            for (var i = 1; i <= pageCount; i++) {
                var annotation = {
                    type: 8,
                    pageNo: i,
                    coordinates: {
                        left: 0.2,
                        top: 0.2,
                        height: 3.0,
                        width: 0.2
                    appearance: {
                        text: "FOOTER",
                        autoSize: true,
                        fill: false,
                        stroke: false,
                        fontName: "Courier New",
                        foreColor: "#FF0000",
                        fontSize: 20,
                        canEditText: false
                    common: {
                        tag: "id"
            DocuViewareAPI.AddAnnot("DocuVieware1", annotations);
    else {
        setTimeout(function () { RegisterOnNewDocumentLoadedOnDocuViewareAPIReady() }, 10);
document.addEventListener("DOMContentLoaded", function () {
}, false);

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests