Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Add an Image on PDF 6 years 11 months ago #12403

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

you can convert your point to pdf coordinates with vGetPos method:
struct PDFV_POS annotPos;
[m_view vGetPos:&annotPos :point.x * m_scale :point.y * m_scale];

Then create your rect:
PDF_RECT annotRect;
annotRect.left = annotPos.x;
annotRect.top = annotPos.y;
annotRect.right = annotPos.x + yourWidth;
annotRect.bottom = annotPos.y + yourHeight;

You can also adjust the position as your prefer (in this sample annotRect.left, annotRect.top point is the bottom-left corner of your image)

Please Log in or Create an account to join the conversation.

Add an Image on PDF 6 years 10 months ago #12404

  • Pja
  • Pja's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 45
  • Thank you received: 0
Can you please help me converting screen coordinates to PDFRECT left,right,top and bottom?
Right now i am unable to plot my image at the point where i have long pressed on the document.

Please Log in or Create an account to join the conversation.

Add an Image on PDF 6 years 10 months ago #12406

  • emanuele
  • emanuele's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 580
  • Thank you received: 67
Hi,

the previous post shows how you could do that.
The first block of code convert the point of the screen (CGPoint point) to pdf coordinates (PDFV_POS annotPos).
The second block creates the PDF_RECT using the pdf coordinates (annotPos) and your image size.
The PDF_RECT's left and top are the image origin (x and y of your point).
PDF_RECT origin is the bottom-left corner (not the top-left), in this case, if you want to use the point as center, you should set the PDF_RECT properly.

For example, you can do something like:
annotRect.left -= (yourWidth / 2);
annotRect.top -= (yourHeight / 2);
annotRect.right -= (yourWidth / 2);
annotRect.bottom -= (yourHeight / 2);

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum