Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

Need to add annotation in swift as per our define position.

More
IP: 123.252.224.118 6 years 11 months ago #14289 by apdeveloper
Hi Team,
I have to add annotation from swift project like (x, y, height, width) at some particular position programmatically and that annotation is going to work as our currently working annotation.


Can you please help me out as soon as possible.
More
IP: 212.97.62.176 6 years 11 months ago #14290 by emanuele
Hi,

you could take a look at addEditText method of PDFView class (Obj-C part).
You could use the same logic and add your annotations (this method is based on screen coordinates).
More
IP: 114.143.175.251 6 years 11 months ago #14294 by apdeveloper
Hi Team,
Do you have any idea how to pass annotation position from swift project and show in radaee pdf do you have any dummy how to do that.
More
IP: 114.143.175.251 6 years 11 months ago #14295 by apdeveloper
Hi Team,
I have added this code but unable to see any annotation

// get the vpage to calculate the annot size based on current scale value
PDFVPage *vpage = [m_view vGetPage:0];
PDFPage *page = [vpage GetPage];

// customize this part to modify the rect size and position
int x = 50;
int y = 100;
int width = 500;
int height = 100;

// convert the coordinate system from screen to pdf
struct PDFV_POS pos1;
struct PDFV_POS pos2;

[m_view vGetPos:&pos1 :(x - self.contentOffset.x) * m_scale :(y - self.contentOffset.y) * m_scale];
[m_view vGetPos:&pos2 :(x - self.contentOffset.x + width) * m_scale :(y - self.contentOffset.y + height) * m_scale];

PDF_RECT rect;

rect.left = pos1.x;
rect.right = pos2.x;
rect.top = pos2.y;
rect.bottom = pos1.y;

// add the annotation
[page addAnnotRect:&rect: g_rect_Width * m_scale / [m_view vGetScaleMin:0]: g_rect_color: 0];

// refresh the page
[m_view vRenderSync:0];
[self refresh];
More
IP: 114.143.175.251 6 years 11 months ago #14296 by apdeveloper
Hi team,
Can you just reply little fast what i am doing wrong after i have added the above code in PDFview.m file in objc and calling this function using the delegate from swift project but unable to see the annotation.
More
IP: 212.97.62.176 6 years 11 months ago #14297 by emanuele
Hi,
to add a new method, starting from PDFView class, you should add the method in:
- PDFView class: add and implement the new method.
- RDPDFViewController: add new method the calls the PDFView class' method.
- RadaeePDFPlugin: add new method the calls the RDPDFViewController class' method.

Then build the lib project and replace the RadaeePDFPlugin.h into your project, run the make command to create the new lib and replace the old one into your project.
Please be sure to use your method when the pdf file is opened, as it's using vpage instance.
If you want to add annotation using the PDF coordinate system you should use something like:
Code:
// get the page from doc PDFPage *page = [m_doc page:0]; [page objsStart]; // customize this part to modify the rect size and position int x = 50; // left int y = 200; // top int width = 200; int height = 100; // create rect in pdf coordinate system PDF_RECT rect; rect.left = x; rect.right = x + width; rect.top = y; rect.bottom = y + height; // add the annotation [page addAnnotRect:&rect: g_rect_Width * m_scale / [m_view vGetScaleMin:0]: g_rect_color: 0]; // refresh the page [m_view vRenderSync:0]; [self refresh];
If you want to add the annotation when the pdf file is closed (only PDF coordinate system) you should also:
- open it with a PDFDoc instance (Ex. [m_doc open:*pdfPath* :*password*];)
- remove [self refresh] at the end of the method
- add [m_doc save]; at the end of the method
Time to create page: 0.496 seconds
Powered by Kunena Forum