- Posts: 67
- Thank you received: 0
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.
- apdeveloper
- Topic Author
- Offline
- Senior Member
-
Less
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.
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.
IP: 212.97.62.176
6 years 11 months ago #14290
by emanuele
Replied by emanuele on topic Need to add annotation in swift as per our define position.
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).
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).
- apdeveloper
- Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 67
- Thank you received: 0
IP: 114.143.175.251
6 years 11 months ago #14294
by apdeveloper
Replied by apdeveloper on topic Need to add annotation in swift as per our define position.
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.
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.
- apdeveloper
- Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 67
- Thank you received: 0
IP: 114.143.175.251
6 years 11 months ago #14295
by apdeveloper
Replied by apdeveloper on topic Need to add annotation in swift as per our define position.
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];
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];
- apdeveloper
- Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 67
- Thank you received: 0
IP: 114.143.175.251
6 years 11 months ago #14296
by apdeveloper
Replied by apdeveloper on topic Need to add annotation in swift as per our define position.
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.
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.
IP: 212.97.62.176
6 years 11 months ago #14297
by emanuele
Replied by emanuele on topic Need to add annotation in swift as per our define position.
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:
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
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];
- 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