Skip to main content
Participant
November 15, 2021
Question

apis.gotoLocation x and y coordinate utits

  • November 15, 2021
  • 1 reply
  • 434 views

Hello world! I have a PDF with hight 576 px. Also i have a bounds of some aria that I am highlighting with this bounds. The bounds from adobe api. To highlight i am using annotationManager.AddAnnotationsToPDF and it highlighted well. the bounds is float numbers. But when I tryed to use the same bundes to pass to apis.gotoLocation (like apis.gotoLocation(11, 0, parseInt(bondles[1])) where bondles[1] is y1 as float => it "jump" to random plase. If I doesn't do this the editor automaticly "jump" to page where  I add highlited comment but not to the specific aria by y-coordinate. As got here (https://community.adobe.com/t5/document-services-apis-discussions/adobe-pdf-embed-gotolocation-timing-problem/m-p/12391079) may be I need to do the similar calculation for the y coordinate value (to use screen.height and PPI) but what must be the units of x and y coordinate and how exactly to calculate tham? Or, otherwise why it does not focus on the add comment(highlight)?

    This topic has been closed for replies.

    1 reply

    Participant
    November 15, 2021

    ... it focus on the page but not on the aria. So I also to scroll to specific place on the page.

    Participant
    November 15, 2021
    if(_adobeViewer) {
                    (_adobeViewer as any).getAPIs().then((apis: any) => {
                        (_adobeViewer as any)
                            .getAnnotationManager()
                            .then(function (annotationManager: any) {
                                var filter = {
                                    pageRange: {
                                        startPage: 1,
                                        endPage: 123
                                    }
                                };
                                annotationManager.deleteAnnotations(filter)
                                annotationManager
                                    .addAnnotationsInPDF([
                                        {
                                            "@context": [
                                                "https://www.w3.org/ns/anno.jsonld",
                                                "https://comments.acrobat.com/ns/anno.jsonld",
                                            ],
                                            type: "Annotation",
                                            id: uuidv4(),
                                            bodyValue: "",
                                            motivation: "commenting",
                                            target: {
                                                source: "6d07d124-ac85-43b3-a867-36930f502ac6",
                                                selector: {
                                                    node: {
                                                        index: newAction
                                                            .pdfParams
                                                            .pageNumber,
                                                    },
                                                    opacity: 1,
                                                    subtype: "highlight",
                                                    boundingBox: [
                                                        newAction.pdfParams
                                                            .bounds[0],
                                                        newAction.pdfParams
                                                            .bounds[1],
                                                        newAction.pdfParams
                                                            .bounds[2],
                                                        newAction.pdfParams
                                                            .bounds[3],
                                                    ],
                                                    quadPoints: [
                                                        newAction.pdfParams
                                                            .bounds[0],
                                                        newAction.pdfParams
                                                            .bounds[3],
                                                        newAction.pdfParams
                                                            .bounds[2],
                                                        newAction.pdfParams
                                                            .bounds[3],
                                                        newAction.pdfParams
                                                            .bounds[0],
                                                        newAction.pdfParams
                                                            .bounds[1],
                                                        newAction.pdfParams
                                                            .bounds[2],
                                                        newAction.pdfParams
                                                            .bounds[1],
                                                    ],
                                                    strokeColor: "#fccb00",
                                                    strokeWidth: 3,
                                                    type: "AdobeAnnoSelector",
                                                },
                                            },
                                            creator: {
                                                type: "Person",
                                                name: "John Smith",
                                            },
                                            created: "2020-04-01T20:37:03Z",
                                            modified: "2020-04-01T20:37:03Z",
                                        },
                                    ])
                                    .then(function (result: any) {
                                        apis.gotoLocation(
                                            newAction.pdfParams.pageNumber + 1,
                                            0,
                                            parseInt(
                                                newAction.pdfParams.bounds[1]
                                            ) // ??????????????????
                                        )
                                            .then(() => {
                                                console.log("Success");
                                            })
    
                                            .catch((error: any) =>
                                                console.log(error)
                                            );
                                    });
                            });
                    });