- Posts: 37
- 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
From PDF_RECT to CGRect
10 years 2 months ago - 10 years 2 months ago #10790
by Shades
Adding image after moving UIImageView was created by Shades
Hi,
I didn't understand,what I mean is getting the inverse from PDF_RECT to CGRECT ?
Also,after adding the bitmap image is not getting in the right position after doing that :
Any suggestions please ?
I didn't understand,what I mean is getting the inverse from PDF_RECT to CGRECT ?
Also,after adding the bitmap image is not getting in the right position after doing that :
Code:
struct PDFV_POS pos;
[m_view vGetPos:&pos :frame.origin.x * m_scale :frame.origin.y* m_scale];
_rect.left = pos.x;
_rect.right = pos.x+frame.size.width;
_rect.top = pos.y;
_rect.bottom = pos.y+frame.size.height;
NSString *tp = NSTemporaryDirectory();
tp = [tp stringByAppendingPathComponent:@"cache.dat"];
[m_doc setCache:tp];
PDFPage *page = [m_doc page:p];
CGImageRef ref = [UIImage imageWithData:data].CGImage;
[page addAnnotBitmap:ref :YES :&_rect];
[m_view vRenderSync:p];
[self refresh];
[m_doc save];
Any suggestions please ?
Last edit: 10 years 2 months ago by Shades.
10 years 2 months ago #10793
by Shades
Replied by Shades on topic From PDF_RECT to CGRect
Hi,
After adding the bitmap,I am trying to send it's coordinates to the server.That's why I think I need to convert the PDF_RECT to CGRECT.
I have done something like That:
But it seems I have done something wrong.Any suggestion please ?
Thank you
After adding the bitmap,I am trying to send it's coordinates to the server.That's why I think I need to convert the PDF_RECT to CGRECT.
I have done something like That:
Code:
struct PDFV_POS pos;
[m_view vGetPos:&pos :signatureFrame.origin.x * m_scale :signatureFrame.origin.y* m_scale];
_rect.left = pos.x;
_rect.right = pos.x+signatureFrame.size.width;
_rect.top = pos.y;
_rect.bottom = pos.y+signatureFrame.size.height;
CGRect rect1 = CGRectMake(self.contentOffset.x + (_rect.left)/m_scale,
self.contentOffset.y + (_rect.top)/m_scale,
(_rect.right - _rect.left)/m_scale,
(_rect.bottom - _rect.top)/m_scale);
But it seems I have done something wrong.Any suggestion please ?
Thank you
10 years 2 months ago #10794
by emanuele
Replied by emanuele on topic Adding image after moving UIImageView
Hi,
here is a checked slice of code that will help you.
to convert CGRect to PDF_RECT:
to convert PDF_RECT to CGRect (this PDF_RECT if got from an annotation):
here is a checked slice of code that will help you.
to convert CGRect to PDF_RECT:
Code:
CGRect frame = CGRectMake(point.x, point.y, 100, 100);
struct PDFV_POS pos1;
struct PDFV_POS pos2;
[m_view vGetPos:&pos1 :frame.origin.x * m_scale :frame.origin.y * m_scale];
[m_view vGetPos:&pos2 :(frame.origin.x + frame.size.width) * m_scale :(frame.origin.y + frame.size.height) * m_scale];
PDF_RECT rect;
rect.left = pos1.x;
rect.right = pos2.x;
rect.top = pos2.y;
rect.bottom = pos1.y;
to convert PDF_RECT to CGRect (this PDF_RECT if got from an annotation):
Code:
[m_annot getRect:&m_annot_rect];
m_annot_rect.left = [vpage GetX] - self.contentOffset.x * m_scale + [vpage ToDIBX:m_annot_rect.left];
m_annot_rect.right = [vpage GetX] - self.contentOffset.x * m_scale + [vpage ToDIBX:m_annot_rect.right];
float tmp = m_annot_rect.top;
m_annot_rect.top = [vpage GetY] - self.contentOffset.y * m_scale + [vpage ToDIBY:m_annot_rect.bottom];
m_annot_rect.bottom = [vpage GetY] - self.contentOffset.y * m_scale + [vpage ToDIBY:tmp];
int dx = m_tx - m_px;
int dy = m_ty - m_py;
CGRect rect1 = CGRectMake((m_annot_rect.left+dx)/m_scale,
(m_annot_rect.top+dy)/m_scale,
(m_annot_rect.right - m_annot_rect.left)/m_scale,
(m_annot_rect.bottom - m_annot_rect.top)/m_scale);
10 years 2 months ago #10795
by Shades
Replied by Shades on topic Adding image after moving UIImageView
Thank you for your answer.
The first code works great.Thank you.
But still confused with the second one.If we suppose we have an UIImageView instead of an annotation,how could we get the right coordinates.My point is to send right coordinates to the server,so I need to get the position ( x,y) according to the pdf.
Now I have the PDF_RECT of the pdf but still not able to post them to the server.
The first code works great.Thank you.
But still confused with the second one.If we suppose we have an UIImageView instead of an annotation,how could we get the right coordinates.My point is to send right coordinates to the server,so I need to get the position ( x,y) according to the pdf.
Now I have the PDF_RECT of the pdf but still not able to post them to the server.
10 years 2 months ago #10797
by emanuele
Replied by emanuele on topic Adding image after moving UIImageView
if you have a PDF_RECT you can convert it into CGRect with the second part of code, but if you have CGRect and you need only x,y according to pdf, you can simply use vGetPos method
If you have PDF_RECT and you need only x,y you can use m_annot_rect.left, m_annot_rect.top, that represent x,y according to pdf.
Code:
struct PDFV_POS pos1;
[m_view vGetPos:&pos1 :rect.origin.x * m_scale :rect.origin.y * m_scale];
10 years 2 months ago #10801
by Shades
Replied by Shades on topic Adding image after moving UIImageView
Hi,
Thank you!
Following that method,I don't get the right position in the server .I am confused.The image is moving to the top of the view.
Thank you!
Following that method,I don't get the right position in the server .I am confused.The image is moving to the top of the view.
Time to create page: 0.451 seconds