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

TOPIC:

Get object identifier (object number and generation number) with radaee API 5 years 4 months ago #14760

  • Soldan
  • Soldan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
Hi,
I need to extract the object identifier, defined as object number plus generation number in the pdf specification, from an annotation.
Is there a way to do this with your API?
I noticed that (m_annot is a Page.Annotation):

final long refAnnot = m_annot.GetRef();

returns a long, so I supposed that object and generation number could be in there.
I tried:

final long genNum = (refAnnot & 0xFFFF0000) >> 32;
final long objNum = refAnnot & 0x0000FFFF;

and actually I can get the same object and generation number that I can read from the pdf file.
But the method GetRef is not documented
www.radaeepdf.com/documentation/javadocs...tation.html#GetRef--
so can I suppose GetRef returns a long with the generation number into the most significant bits 32 bits and the object number in the 32 less significant bits?
Is there a more friendly way to do this? Is my method reliable or could be any edge case?

Thank you so much

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

Get object identifier (object number and generation number) with radaee API 5 years 4 months ago #14767

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
dear user, this method is reliable.
it is not the only way. and this function mainly used in operation stack.
acturally, Annotation.GetRef() is same to Annotation.Advance_GetRef();
we wrap 2 methods with same return value, because we hope use different method on different occasion.
and, we not mention about this, because the return value mainly used in inner class.
you are right for codes:
final long genNum = (refAnnot & 0xFFFF0000) >> 32;
 final long objNum = refAnnot & 0x0000FFFF;

at last, i shall say: all Advance_GetRef() in Document, Page, Annotation return the same.

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

Last edit: by radaee.

Get object identifier (object number and generation number) with radaee API 5 years 4 months ago #14769

  • Soldan
  • Soldan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
Ok, thank you so much.
If the code is reliable I think I'll use
final long refAnnot = m_annot.GetRef();
final long genNum = (refAnnot & 0xFFFF0000) >> 32;
final long objNum = refAnnot & 0x0000FFFF;
Thanks

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

Get object identifier (object number and generation number) with radaee API 5 years 1 month ago #14927

  • Soldan
  • Soldan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
Hi,
I've been thinking about the above code after a while. Could it be that it is wrong?
In fact I'm doing a bitwise AND between refAnnot which is 64 bits and 0xFFFF0000 / 0x0000FFFF which are 32 bit right?
So I guess that the right code should be
final long refAnnot = m_annot.GetRef();
final long genNum = (refAnnot & 0xFFFFFFFF00000000L) >> 32;
final long objNum = refAnnot & 0x00000000FFFFFFFFL;

Am I right?
Thanks

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

Last edit: by Soldan.

Get object identifier (object number and generation number) with radaee API 5 years 1 month ago #14928

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
seems ok, but i think following codes are better:
final long refAnnot = m_annot.GetRef();
final long genNum = (refAnnot >> 32) & 0x00000000FFFFFFFFL;
final long objNum = refAnnot & 0x00000000FFFFFFFFL;
if genNum is less than 0, your codes may run not correctly, but seems never happen.

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

Get object identifier (object number and generation number) with radaee API 5 years 1 month ago #14931

  • Soldan
  • Soldan's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 0
I think that the pdf specification defines genNum as greater or equal than zero. So it shouldn't be less than 0.

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

  • Page:
  • 1
Powered by Kunena Forum