make new PDF action object from JavaScript source Parameters are a PDF document and a Python string. Returns a PDF action object.
(pdf, value)
| 20962 | |
| 20963 | |
| 20964 | def JM_new_javascript(pdf, value): |
| 20965 | ''' |
| 20966 | make new PDF action object from JavaScript source |
| 20967 | Parameters are a PDF document and a Python string. |
| 20968 | Returns a PDF action object. |
| 20969 | ''' |
| 20970 | if value is None: |
| 20971 | # no argument given |
| 20972 | return |
| 20973 | data = JM_StrAsChar(value) |
| 20974 | if data is None: |
| 20975 | # not convertible to char* |
| 20976 | return |
| 20977 | |
| 20978 | res = mupdf.fz_new_buffer_from_copied_data(data.encode('utf8')) |
| 20979 | source = mupdf.pdf_add_stream(pdf, res, mupdf.PdfObj(), 0) |
| 20980 | newaction = mupdf.pdf_add_new_dict(pdf, 4) |
| 20981 | mupdf.pdf_dict_put(newaction, PDF_NAME('S'), mupdf.pdf_new_name('JavaScript')) |
| 20982 | mupdf.pdf_dict_put(newaction, PDF_NAME('JS'), source) |
| 20983 | return newaction |
| 20984 | |
| 20985 | |
| 20986 | def JM_new_output_fileptr(bio): |
no test coverage detected
searching dependent graphs…