syncAnnotScan();

var strFDF = exportAsFDFStr({bAllFields: 'true', bFlags: 'true', bAnnotations: 'true'});
//exportAsXFDFStr(true, true, null, true, 1);";

var strXFDF = exportAsXFDFStr(true, true, true, true, 1);
//exportAsXFDFStr(true, true, null, true, 1);

exportAsFDF({ bAnnotations: 'true', cPath: '/d/export.fdf'});


importAnFDF("/d/import.fdf");
importAnXFDF("/d/import.xfdf");
// Add navigation buttons to the page
// This script puts 3 buttons on top of every page (except the first one that has one button)
// First button "<" : takes to the previous page
// Second button: "1" : takes to the first page of the document
// Third button: ">" : takes to the next page in the document (does not exists on the last page)

var inch = 72;

try 
{

    nLastPage = this.numPages - 1;

    for (var p = 0; p < this.numPages; p++)
    {
        var x = 0.5;
 
        if (p > 0)
        {
            AddButton(p,x,0.5,0.25,0.25,"PrevPage","<","Previous Page","this.pageNum--;"); // left arrow, previous page
            x += 0.3;
        }
    
        if (p != 0)
        {
            AddButton(p,x,0.5,0.25,0.25,"StartPage","1","Go To First Page","this.pageNum=0;"); // "1", takes to the first page
            x += 0.3;
        }
    
        if (p < nLastPage)
        {
            AddButton(p,x,0.5,0.25,0.25,"NextPage",">","Next Page","this.pageNum++;"); // right arrow, next page
            x += 0.3;
        }

        AddButton(p,x,0.5,0.25,0.25,"Back","<<","Go Back","app.execMenuItem(\"GoBack\");"); // right arrow, next page
        x += 0.3;
        
    }

}


catch (e)
{
app.alert(e);
}

// AddButton function creates a button with given parameters and action

function AddButton(nPageNum, x, y, width, height, strText, strCaption, strToolTip, strAction)
{
    var aRect = this.getPageBox( { nPage: nPageNum} );
    aRect[0] += x * inch;
    aRect[1] -= y * inch;
    aRect[2] = aRect[0] + width * inch;
    aRect[3] = aRect[1] - height * inch;

    var f = this.addField(strText,"button", nPageNum, aRect);
    f.setAction("MouseUp",strAction);
    f.userName = strToolTip;
    f.delay = true;
    f.borderStyle = border.s;
    f.highlight = "push";
    f.textSize = 0; // autosized
    f.textColor = color.blue;
    f.strokeColor = color.blue;
    f.fillColor = color.white;
    // you can specify a different font here, otherwise it uses a default one
    //f.textFont = font.ZapfD;
    f.buttonSetCaption(strCaption); 
    f.delay = false;
}

 

출처 : https://www.evermap.com/javascript.asp

var annots = this.getAnnots();
console.clear();
for (var i = 0; i < annots.length; i++) 
{
	//console.println(annots[i].toString());
	//if (annots[i].type == "PolyLine") 
	{  
		var a = annots[i].getProps();
		for(var o in a)
		{
			console.println( "annots." + o + "=" + a[o]);
		}
		console.println( "==========================")
		++counter;   
	}
}

app.alert("Total comments count: " + annots.length + " / : " + counter);
var annotText = this.addAnnot({
	page: 0,
	type: "FreeText",
	textFont: "Arial", // or, textFont: "Viva-Regular",
	textSize: 7,
	rect: [57.806640625,730.9102172851562,75.806640625,744.916015625],
	width: 0,
	alignment: 1,
	contents: "D",
	lineEnding : "None",
	refType : "R",
	seqNum : 1
});

var annotPoly = this.addAnnot({
	page: 0,
	type: "PolyLine",
	rect: [55.78631591796875,730.4441528320312,73.8094482421875,747.8836059570312], // height for three lines
	reftype : "R",
	rotation: -270,
	vertices: [[73.25311279296875,738.8373413085938],[56.49212646484375,747.6712036132812],[56.367919921875,730.8611450195312],[73.25311279296875,738.8373413085938]],
	with: 0.75,
	seqNum : 2
});
var annot = this.addAnnot({
	page: 0,
	type: "Text",
	point: [72,500],
	popupRect: [72, 500,6*72,500-2*72],
	popupOpen: true,
	noteIcon: "Help"
});

var spans = new Array();
spans[0] = new Object();
spans[0].text = "Attention:\r";
spans[0].textColor = color.blue;
spans[0].textSize = 18;

spans[1] = new Object();
spans[1].text = "Adobe Acrobat 6.0\r";
spans[1].textColor = color.red;
spans[1].textSize = 20;
spans[1].alignment = "center";

spans[2] = new Object();
spans[2].text = "will soon be here!";
spans[2].textColor = color.green;
spans[2].fontStyle = "italic";
spans[2].underline = true;
spans[2].alignment = "right";

// Now give the rich field a rich value
annot.richContents = spans;

출처 : https://www.gdpicture.com/forum/viewtopic.php?t=6250#p19870 

 

Adding multiline rich text - GdPicture Imaging Forums

Post by radshat » Wed Dec 13, 2017 12:31 am I need to be able to create multiline rich text annotation. The Acrobat JavaScript API reference allows the following. What is the equivalent in GdPicture? I don't mind doing this as a custom action on the serve

www.gdpicture.com

 

+ Recent posts