annotation vertex points
(self)
| 1891 | |
| 1892 | @property |
| 1893 | def vertices(self): |
| 1894 | """annotation vertex points""" |
| 1895 | CheckParent(self) |
| 1896 | annot = self.this |
| 1897 | assert isinstance(annot, mupdf.PdfAnnot) |
| 1898 | annot_obj = mupdf.pdf_annot_obj(annot) |
| 1899 | page = _pdf_annot_page(annot) |
| 1900 | page_ctm = mupdf.FzMatrix() # page transformation matrix |
| 1901 | dummy = mupdf.FzRect() # Out-param for mupdf.pdf_page_transform(). |
| 1902 | mupdf.pdf_page_transform(page, dummy, page_ctm) |
| 1903 | derot = JM_derotate_page_matrix(page) |
| 1904 | page_ctm = mupdf.fz_concat(page_ctm, derot) |
| 1905 | |
| 1906 | #---------------------------------------------------------------- |
| 1907 | # The following objects occur in different annotation types. |
| 1908 | # So we are sure that (!o) occurs at most once. |
| 1909 | # Every pair of floats is one point, that needs to be separately |
| 1910 | # transformed with the page transformation matrix. |
| 1911 | #---------------------------------------------------------------- |
| 1912 | o = mupdf.pdf_dict_get(annot_obj, PDF_NAME('Vertices')) |
| 1913 | if not o.m_internal: o = mupdf.pdf_dict_get(annot_obj, PDF_NAME('L')) |
| 1914 | if not o.m_internal: o = mupdf.pdf_dict_get(annot_obj, PDF_NAME('QuadPoints')) |
| 1915 | if not o.m_internal: o = mupdf.pdf_dict_gets(annot_obj, 'CL') |
| 1916 | |
| 1917 | if o.m_internal: |
| 1918 | # handle lists with 1-level depth |
| 1919 | # weiter |
| 1920 | res = [] |
| 1921 | for i in range(0, mupdf.pdf_array_len(o), 2): |
| 1922 | x = mupdf.pdf_to_real(mupdf.pdf_array_get(o, i)) |
| 1923 | y = mupdf.pdf_to_real(mupdf.pdf_array_get(o, i+1)) |
| 1924 | point = mupdf.FzPoint(x, y) |
| 1925 | point = mupdf.fz_transform_point(point, page_ctm) |
| 1926 | res.append( (point.x, point.y)) |
| 1927 | return res |
| 1928 | |
| 1929 | o = mupdf.pdf_dict_gets(annot_obj, 'InkList') |
| 1930 | if o.m_internal: |
| 1931 | # InkList has 2-level lists |
| 1932 | #inklist: |
| 1933 | res = [] |
| 1934 | for i in range(mupdf.pdf_array_len(o)): |
| 1935 | res1 = [] |
| 1936 | o1 = mupdf.pdf_array_get(o, i) |
| 1937 | for j in range(0, mupdf.pdf_array_len(o1), 2): |
| 1938 | x = mupdf.pdf_to_real(mupdf.pdf_array_get(o1, j)) |
| 1939 | y = mupdf.pdf_to_real(mupdf.pdf_array_get(o1, j+1)) |
| 1940 | point = mupdf.FzPoint(x, y) |
| 1941 | point = mupdf.fz_transform_point(point, page_ctm) |
| 1942 | res1.append( (point.x, point.y)) |
| 1943 | res.append(res1) |
| 1944 | return res |
| 1945 | |
| 1946 | @property |
| 1947 | def xref(self): |
nothing calls this directly
no test coverage detected