The document rendered as pdf, docx or html, as a base64 value, ready for @response($doc->bytes(as: pdf), type: 'application/pdf') without a file.
Parameter Takes as required one of these words: pdf|docx|html
Example
.kscript XML Copy
<echo>{ @document('# Invoice')->bytes(as: pdf).bytes > 0 }</echo>.kscript XML Copy
echo @document('# Invoice')->bytes(as: pdf).bytes > 0The zero-based match offset in the document's source, or -1.
Parameter Takes text required string
Example
.kscript XML Copy
<echo>{ @document('# Notes')->find('Notes') }</echo>.kscript XML Copy
echo @document('# Notes')->find('Notes')Returns a document with same-format source or plain text added at the given offset.
Parameter Takes content required any value at optional int
Arguments can be named: ->insert(…, at: …).
Example
.kscript XML Copy
<echo>{ @document('# Notes')->insert(' and ideas')->convert(to: markdown) }</echo>.kscript XML Copy
echo @document('# Notes')->insert(' and ideas')->convert(to: markdown)How many pages the PDF has.
Example
.kscript XML Copy
<echo>{ $doc->pages() } pages</echo>.kscript XML Copy
echo "{ $doc->pages() } pages"# document ->replace (search: string , replacement: string ) → document KScript.Document Returns a document made from the source with every literal match replaced.
Parameter Takes search required string replacement required string
Arguments can be named: ->replace(…, replacement: …).
Example
.kscript XML Copy
<echo>{ @document('# Notes')->replace('Notes', 'Outline')->convert(to: markdown) }</echo>.kscript XML Copy
echo @document('# Notes')->replace('Notes', 'Outline')->convert(to: markdown)# document ->save (path: string , as?: pdf|docx|'latex'|'markdown'|html ) KScript.Document Saves the document. The filename extension selects the format unless as is given.
Parameter Takes path required string as optional one of these words: pdf|docx|'latex'|'markdown'|html
Arguments can be named: ->save(…, as: …).
Example
.kscript XML Copy
<echo>{ @document('# Notes')->save('notes', as: pdf) }</echo>.kscript XML Copy
echo @document('# Notes')->save('notes', as: pdf)How many words the text has, not counting maths and code.
Example
.kscript XML Copy
<echo>{ $doc->words() } words</echo>.kscript XML Copy
echo "{ $doc->words() } words"