MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / JM_new_javascript

Function JM_new_javascript

src/__init__.py:20964–20983  ·  view source on GitHub ↗

make new PDF action object from JavaScript source Parameters are a PDF document and a Python string. Returns a PDF action object.

(pdf, value)

Source from the content-addressed store, hash-verified

20962
20963
20964def 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
20986def JM_new_output_fileptr(bio):

Callers 1

JM_put_scriptFunction · 0.85

Calls 2

JM_StrAsCharFunction · 0.85
PDF_NAMEFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…