Add and modify rectangle

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Cosmic2000
User
Posts: 2
Joined: Fri Jan 28, 2011 8:36 am

Add and modify rectangle

Post by Cosmic2000 »

I want to load and display an existing PDF file. That is no problem to me. Than I want to add an red rectangle to the document which is 1 cm high and its width is the page width. The rectangle should be 40% transparent. First the top position of the rectangle should 0 cm from page top. Every time I click a button in my application I want to move the rectangle 2.5 cm downwards. Is this possible? Could you someone provide me an code example for c# or Delphi? I have been searching the docu and forum for hours, but I cant find a solutuon. Thanks in advance.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Add and modify rectangle

Post by Stefan - PDF-XChange »

Hello Cosmic2000,

You could use JS to create the needed rectangle, and then when you click the buttons you have designed, just run some extra JS to move the already created rectangle with the desired offset.
Here is the JavaScript for Acrobat API Reference - the link is to the PDF file directly.

Most of the functions described in the above document are supported in our products and pretty much all of the Annotation functions are (the ones you need), and there should be examples how to execute JS code in the SDK Samples.

Best,
Stefan
Cosmic2000
User
Posts: 2
Joined: Fri Jan 28, 2011 8:36 am

Re: Add and modify rectangle

Post by Cosmic2000 »

OK. Thanks.

I have found this:

Code: Select all

this.addAnnot({Page: 10, type: "FreeText", contents: "test", rect: [5, 10, 100, 100]});
This adds a freetext annotation always at the first page. Why not on page 10? It is always the first page. Every page no is ignored.

Problem 2:
How to provide the values of rect: [...] in millimeters or inch? What is the default measuring unit?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: Add and modify rectangle

Post by Stefan - PDF-XChange »

Hi Cosmic2000,

"page" should be lowercase :)

How to provide the values of rect: [...] in millimeters or inch? What is the default measuring unit?
The rect array consists of four numbers [xll, yll, xur, yur] specifying the lower-left x, lower-left y, upper-right
x, and upper-right y coordinates—in default user space—of the rectangle defining the location of the
annotation on the page. See also the popupRect property.
Best,
Stefan