From 4c6cd33921ca2599c5e58d7115c9539bac148b97 Mon Sep 17 00:00:00 2001 From: Jamie Lemon Date: Thu, 6 Jul 2023 22:32:54 +0100 Subject: [PATCH] wasm: Aligns docs more with latest fixes. --- docs/src/mupdf-js.rst | 1 + docs/src/mupdf-wasm.rst | 111 +++++++++++++++++ docs/src/mutool-object-color-space.rst | 8 -- docs/src/mutool-object-device.rst | 29 ++--- docs/src/mutool-object-display-list.rst | 1 - docs/src/mutool-object-document.rst | 56 +++++++-- docs/src/mutool-object-image.rst | 2 - docs/src/mutool-object-page.rst | 6 +- docs/src/mutool-object-path.rst | 12 +- docs/src/mutool-object-pdf-annotation.rst | 62 +++++----- docs/src/mutool-object-pdf-document.rst | 16 +-- docs/src/mutool-object-pdf-page.rst | 56 +++++++++ docs/src/mutool-object-pixmap.rst | 2 +- docs/src/mutool-object-stroke-state.rst | 134 +++++++++++++++++++++ docs/src/mutool-object-structured-text.rst | 21 ++-- docs/src/mutool-object-text.rst | 2 +- docs/src/mutool-run-js-api.rst | 2 + 17 files changed, 423 insertions(+), 98 deletions(-) create mode 100644 docs/src/mutool-object-stroke-state.rst diff --git a/docs/src/mupdf-js.rst b/docs/src/mupdf-js.rst index f5baaf0b1c..cbd4654442 100644 --- a/docs/src/mupdf-js.rst +++ b/docs/src/mupdf-js.rst @@ -70,6 +70,7 @@ Class A-Z Index - :ref:`PDFWidget` - :ref:`Pixmap` - :ref:`Story` +- :ref:`StrokeState` - :ref:`StructuredText` - :ref:`Text` - :ref:`XML` diff --git a/docs/src/mupdf-wasm.rst b/docs/src/mupdf-wasm.rst index 9bd956b6bf..5e040c1dc0 100644 --- a/docs/src/mupdf-wasm.rst +++ b/docs/src/mupdf-wasm.rst @@ -57,6 +57,117 @@ The following :title:`JavaScript` sample demonstrates how to load a local docume console.log(doc.countPages()); +Creating a PDF +------------------- + +The following :title:`JavaScript` sample demonstrates how to create a blank :title:`PDF` file with an assortment of annotations. + + + .. code-block:: javascript + + var fs = require("fs") + var mupdf = require("mupdf") + + function createBlankPDF() { + var doc = new mupdf.PDFDocument() + doc.insertPage(0, doc.addPage([0, 0, 595, 842], 0, null, "")) + return doc + } + + function savePDF(doc, path, opts) { + fs.writeFileSync(path, doc.saveToBuffer(opts).asUint8Array()) + } + + try { + var doc = createBlankPDF() + var page = doc.loadPage(0) + var annot + + annot = page.createAnnotation("Text") + annot.setRect([200, 10, 250, 50]) + annot.setContents("This is a Text annotation!") + annot.setColor([0,0.5,1]) + + annot = page.createAnnotation("FreeText") + annot.setRect([10, 10, 200, 50]) + annot.setContents("This is a FreeText annotation!") + annot.setDefaultAppearance("TiRo", 18, [0]) + + annot = page.createAnnotation("Circle") + annot.setRect([100, 100, 300, 300]) + annot.setColor([0, 1, 1]) + annot.setInteriorColor([0.5, 0, 0]) + annot.setBorderEffect("Cloudy") + annot.setBorderEffectIntensity(4) + annot.setBorderWidth(10) + + annot = page.createAnnotation("Polygon") + annot.setColor([1, 0, 0]) + annot.setInteriorColor([1, 1, 0]) + annot.addVertex([10, 100]) + annot.addVertex([200, 200]) + annot.addVertex([30, 300]) + + annot = page.createAnnotation("Line") + annot.setColor([1, 0, 0]) + annot.setInteriorColor([0, 0, 1]) + annot.setLine([10, 300], [200, 500]) + annot.setLineEndingStyles("None", "ClosedArrow") + + annot = page.createAnnotation("Highlight") + annot.setColor([1, 1, 0]) + annot.setQuadPoints([ + [ + 80, 70, + 190, 70, + 80, 90, + 190, 90, + ] + ]) + + annot = page.createAnnotation("Stamp") + annot.setRect([10, 600, 200, 700]) + annot.setAppearance(null, null, mupdf.Matrix.identity, [ 0, 0, 100, 100 ], {}, "0 1 0 rg 10 10 50 50 re f") + + annot = page.createAnnotation("Stamp") + annot.setRect([10, 750, 200, 850]) + annot.setIcon("TOP SECRET") + + annot = page.createAnnotation("FileAttachment") + annot.setRect([300, 10, 350, 60]) + annot.setFileSpec( + doc.addEmbeddedFile ( + "readme.txt", + "text/plain", + "Lorem ipsum dolor...", + new Date(), + new Date(), + false + ) + ) + + annot = page.createAnnotation("Ink") + annot.setColor([0.5]) + annot.setBorderWidth(5) + annot.addInkListStroke() + for (let i = 0; i < 360; i += 5) { + let y = Math.sin(i * Math.PI / 180) + annot.addInkListStrokeVertex([ 200 + i, 700 + y * 50 ]) + } + + page.createLink([ 500, 20, 590, 40 ], "https://mupdf.com/") + page.createLink([ 500, 40, 590, 60 ], doc.formatLinkURI({ type: "Fit", page: 0 })) + + page.update() + + savePDF(doc, "out.pdf", "") + + } catch (err) { + console.error(err) + process.exit(1) + } + + Trying the Viewer -------------------------- diff --git a/docs/src/mutool-object-color-space.rst b/docs/src/mutool-object-color-space.rst index d376ec3cfe..34a3f4547c 100644 --- a/docs/src/mutool-object-color-space.rst +++ b/docs/src/mutool-object-color-space.rst @@ -94,7 +94,6 @@ .. method:: isGray() - |mutool_tag| Returns true if the object is a gray color space. @@ -107,7 +106,6 @@ .. method:: isRGB() - |mutool_tag| Returns true if the object is an RGB color space. @@ -120,7 +118,6 @@ .. method:: isCMYK() - |mutool_tag| Returns true if the object is a CMYK color space. @@ -132,7 +129,6 @@ .. method:: isIndexed() - |mutool_tag| Returns true if the object is an Indexed color space. @@ -144,7 +140,6 @@ .. method:: isLab() - |mutool_tag| Returns true if the object is a Lab color space. @@ -156,7 +151,6 @@ .. method:: isDeviceN() - |mutool_tag| Returns true if the object is a Device N color space. @@ -170,7 +164,6 @@ .. method:: isSubtractive() - |mutool_tag| Returns true if the object is a subtractive color space. @@ -184,7 +177,6 @@ .. method:: getType() - |wasm_tag| Returns a string indicating the type. diff --git a/docs/src/mutool-object-device.rst b/docs/src/mutool-object-device.rst index 12f9a75816..0ab3f61fe2 100644 --- a/docs/src/mutool-object-device.rst +++ b/docs/src/mutool-object-device.rst @@ -30,7 +30,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: fillPath(path, evenOdd, transform, colorspace, color, alpha, colorParams) - |mutool_tag_wasm_soon| Fill a path. @@ -52,12 +51,11 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: strokePath(path, stroke, transform, colorspace, color, alpha, colorParams) - |mutool_tag_wasm_soon| Stroke a path. :arg path: `Path` object. - :arg stroke: The :ref:`stroke dictionary`. + :arg stroke: `StrokeState` The :ref:`stroke state object`. :arg transform: `[a,b,c,d,e,f]`. The transform :ref:`matrix`. :arg colorspace: The :ref:`ColorSpace`. :arg color: The :ref:`color value`. @@ -79,7 +77,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: clipPath(path, evenOdd, transform) - |mutool_tag_wasm_soon| Clip a path. @@ -98,12 +95,11 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: clipStrokePath(path, stroke, transform) - |mutool_tag_wasm_soon| Clip & stroke a path. :arg path: `Path` object. - :arg stroke: The :ref:`stroke dictionary`. + :arg stroke: `StrokeState` The :ref:`stroke state object`. :arg transform: `[a,b,c,d,e,f]`. The transform :ref:`matrix`. |example_tag| @@ -117,7 +113,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: fillText(text, transform, colorspace, color, alpha, colorParams) - |mutool_tag_wasm_soon| Fill a text object. @@ -136,12 +131,11 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: strokeText(text, stroke, transform, colorspace, color, alpha, colorParams) - |mutool_tag_wasm_soon| Stroke a text object. :arg text: `Text` object. - :arg stroke: The :ref:`stroke dictionary`. + :arg stroke: `StrokeState` The :ref:`stroke state object`. :arg transform: `[a,b,c,d,e,f]`. The transform :ref:`matrix`. :arg colorspace: The :ref:`ColorSpace`. :arg color: The :ref:`color value`. @@ -161,7 +155,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: clipText(text, transform) - |mutool_tag_wasm_soon| Clip a text object. @@ -177,12 +170,11 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: clipStrokeText(text, stroke, transform) - |mutool_tag_wasm_soon| Clip & stroke a text object. :arg text: `Text` object. - :arg stroke: The :ref:`stroke dictionary`. + :arg stroke: `StrokeState` The :ref:`stroke state object`. :arg transform: `[a,b,c,d,e,f]`. The transform :ref:`matrix`. |example_tag| @@ -195,7 +187,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: ignoreText(text, transform) - |mutool_tag_wasm_soon| Invisible text that can be searched but should not be visible, such as for overlaying a scanned OCR image. @@ -235,7 +226,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: fillImage(image, transform, alpha, colorParams) - |mutool_tag_wasm_soon| Draw an image. An image always fills a unit rectangle `[0,0,1,1]`, so must be transformed to be placed and drawn at the appropriate size. @@ -255,7 +245,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: fillImageMask(image, transform, colorspace, color, alpha, colorParams) - |mutool_tag_wasm_soon| An image mask is an image without color. Fill with the color where the image is opaque. @@ -277,7 +266,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: clipImageMask(image, transform) - |mutool_tag_wasm_soon| Clip graphics using the image to mask the areas to be drawn. @@ -305,7 +293,6 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. method:: beginMask(area, luminosity, backdropColorspace, backdropColor, backdropAlpha, colorParams) - |mutool_tag_wasm_soon| Create a soft mask. Any drawing commands between `beginMask` and `endMask` are grouped and used as a clip mask. @@ -337,13 +324,13 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. -.. method:: beginGroup(area, isolated, knockout, blendmode, alpha) +.. method:: beginGroup(area, colorspace, isolated, knockout, blendmode, alpha) - |mutool_tag_wasm_soon| Push/pop a transparency blending group. See the PDF reference for details on `isolated` and `knockout`. - :arg area: `Path` Blend area. + :arg area: `[ulx,uly,lrx,lry]` :ref:`Rectangle`. The blend area. + :arg colorspace: :ref:`ColorSpace`. :arg isolated: `Boolean`. :arg knockout: `Boolean`. :arg blendmode: Blendmode is one of the standard :title:`PDF` blend modes: "Normal", "Multiply", "Screen", etc. @@ -359,7 +346,7 @@ The methods that clip graphics must be balanced with a corresponding `popClip`. .. code-block:: javascript - device.beginGroup(path, true, true, "Multiply", 0.5); + device.beginGroup([0,0,100,100], mupdf.ColorSpace.DeviceRGB, true, true, "Multiply", 0.5); diff --git a/docs/src/mutool-object-display-list.rst b/docs/src/mutool-object-display-list.rst index 274fd47ec1..0b486da64c 100644 --- a/docs/src/mutool-object-display-list.rst +++ b/docs/src/mutool-object-display-list.rst @@ -111,7 +111,6 @@ A display list records all the device calls for playback later. If you want to r .. method:: search(needle) - |mutool_tag_wasm_soon| Search the display list text for all instances of the `needle` value, and return an array of search hits. Each search hit is an array of :ref:`rectangles` corresponding to all characters in the search hit. diff --git a/docs/src/mutool-object-document.rst b/docs/src/mutool-object-document.rst index a03955a3c3..8a1527efa3 100644 --- a/docs/src/mutool-object-document.rst +++ b/docs/src/mutool-object-document.rst @@ -58,10 +58,28 @@ .. method:: authenticatePassword(password) - Returns *true* if the password matches. + Returns a bitfield value against the password authentication result. :arg password: The password to attempt authentication with. - :return: `Boolean`. + :return: `Integer`. + + + + .. list-table:: + :header-rows: 1 + + * - **Bitfield value** + - **Description** + * - `0` + - Failed + * - `1` + - No password needed + * - `2` + - Is User password and is okay + * - `4` + - Is Owner password and is okay + * - `6` + - Is both User & Owner password and is okay |example_tag| @@ -72,11 +90,35 @@ .. method:: hasPermission(permission) - Returns *true* if the document has permission for "print", "annotate", "edit", "copy", "form", "accessbility", "assemble" or "print-hq". + Returns *true* if the document has permission for the supplied permission `String` parameter. :arg permission: `String` The permission to seek for, e.g. "edit". :return: `Boolean`. + + .. list-table:: + :header-rows: 1 + + * - **String** + - **Description** + * - `print` + - Can print + * - `edit` + - Can edit + * - `copy` + - Can copy + * - `annotate` + - Can annotate + * - `form` + - Can fill out forms + * - `accessibility` + - Can copy for accessibility + * - `assemble` + - Can manage document pages + * - `print-hq` + - Can print high-quality + + |example_tag| .. code-block:: javascript @@ -86,7 +128,7 @@ .. method:: getMetaData(key) - Return various meta data information. The common keys are: `format`, `encryption`, `info:Author`, and `info:Title`. + Return various meta data information. The common keys are: `format`, `encryption`, `info:ModDate`, and `info:Title`. :arg key: `String`. :return: `String`. @@ -95,7 +137,9 @@ .. code-block:: javascript - var metaData = document.getMetaData("format"); + var format = document.getMetaData("format"); + var modificationDate = doc.getMetaData("info:ModDate"); + var author = doc.getMetaData("info:Author"); .. method:: setMetaData(key, value) @@ -233,8 +277,6 @@ .. method:: formatLinkURI(linkDestination) - |mutool_tag| - Format a document internal link destination object to a :title:`URI` string suitable for :ref:`createLink()`. :arg linkDestination: :ref:`Link destination`. diff --git a/docs/src/mutool-object-image.rst b/docs/src/mutool-object-image.rst index b0d43301e4..6fdb3ba871 100644 --- a/docs/src/mutool-object-image.rst +++ b/docs/src/mutool-object-image.rst @@ -19,8 +19,6 @@ .. method:: new Image(ref) - |mutool_tag_wasm_soon| - *Constructor method*. Create a new image from a `Pixmap` data, or load an image file data. diff --git a/docs/src/mutool-object-page.rst b/docs/src/mutool-object-page.rst index f38301cda4..5db33b272c 100644 --- a/docs/src/mutool-object-page.rst +++ b/docs/src/mutool-object-page.rst @@ -160,7 +160,6 @@ The base class for a :ref:`PDF Page`. .. method:: search(needle, max_hits) - |mutool_tag_wasm_soon| Search the page text for all instances of the `needle` value, and return an array of search hits. Each search hit is an array of :ref:`rectangles` corresponding to all characters in the search hit. @@ -175,6 +174,9 @@ The base class for a :ref:`PDF Page`. var results = page.search("my search phrase"); + .. note:: + + The numbers are `[ulx, uly, urx, ury, llx, lly, lrx, lry]` for each rectangle against each result. These type of rectangles are know as "Quads" or "QuadPoints" in the :title:`PDF` specification. .. method:: getLinks() @@ -212,8 +214,6 @@ The base class for a :ref:`PDF Page`. .. method:: deleteLink(link) - |mutool_tag_wasm_soon| - Delete the link from the page. :arg link: :ref:`Link`. diff --git a/docs/src/mutool-object-path.rst b/docs/src/mutool-object-path.rst index 352edd3162..7554b35e2a 100644 --- a/docs/src/mutool-object-path.rst +++ b/docs/src/mutool-object-path.rst @@ -22,7 +22,7 @@ A `Path` object represents vector graphics as drawn by a pen. A path can be eith .. method:: new Path() - |mutool_tag_wasm_soon| + *Constructor method*. @@ -185,12 +185,14 @@ A `Path` object represents vector graphics as drawn by a pen. A path can be eith .. code-block:: javascript var myPathWalker = { - moveTo: function (x, y) { ... do whatever ... }, - lineTo: function (x, y) { ... do whatever ... }, + moveTo: function (x, y) { + //... do whatever ... + }, + lineTo: function (x, y) { + //... do whatever ... + }, } - path.walk(myPathWalker); - .. |tor_todo| WASM, throws 'TODO' diff --git a/docs/src/mutool-object-pdf-annotation.rst b/docs/src/mutool-object-pdf-annotation.rst index b83148fb7f..ffb167dc50 100644 --- a/docs/src/mutool-object-pdf-annotation.rst +++ b/docs/src/mutool-object-pdf-annotation.rst @@ -115,7 +115,7 @@ To get the annotations on a page see: :ref:`PDFPage getAnnotations()` object. @@ -729,7 +729,7 @@ These properties are only present for some annotation types, so support for them .. method:: setLineEndingStyles(start, end) - |mutool_tag_wasm_soon| + Sets the :ref:`line ending styles` object. @@ -887,7 +887,7 @@ These properties are only present for some annotation types, so support for them .. method:: getLine() - |mutool_tag_wasm_soon| + Get line end points, represented by an array of two points, each represented as an `[x, y]` array. @@ -903,7 +903,7 @@ These properties are only present for some annotation types, so support for them .. method:: setLine(endpoints) - |mutool_tag_wasm_soon| + Set the two line end points, represented by an array of two points, each represented as an `[x, y]` array. @@ -1052,7 +1052,7 @@ The border drawn around some annotations can be controlled by: .. method:: getBorderStyle() - |mutool_tag_wasm_soon| + Get the annotation border style, either of "Solid" or "Dashed". @@ -1068,7 +1068,7 @@ The border drawn around some annotations can be controlled by: .. method:: setBorderStyle(style) - |mutool_tag_wasm_soon| + Set the annotation border style, either of "Solid" or "Dashed". @@ -1084,7 +1084,7 @@ The border drawn around some annotations can be controlled by: .. method:: getBorderWidth() - |mutool_tag_wasm_soon| + Get the border width in points. @@ -1100,7 +1100,7 @@ The border drawn around some annotations can be controlled by: .. method:: setBorderWidth(width) - |mutool_tag_wasm_soon| + Set the border width in points. Retain any existing border effects. @@ -1117,7 +1117,7 @@ The border drawn around some annotations can be controlled by: .. method:: getBorderDashCount() - |mutool_tag_wasm_soon| + Returns the number of items in the border dash pattern. @@ -1132,7 +1132,7 @@ The border drawn around some annotations can be controlled by: .. method:: getBorderDashItem(i) - |mutool_tag_wasm_soon| + Returns the length of dash pattern item `i`. @@ -1149,7 +1149,7 @@ The border drawn around some annotations can be controlled by: .. method:: setBorderDashPattern(dashPattern) - |mutool_tag_wasm_soon| + Set the annotation border dash pattern to the given array of dash item lengths. The supplied array represents the respective line stroke and gap lengths, e.g. `[1,1]` sets a small dash and small gap, `[2,1,4,1]` would set a medium dash, a small gap, a longer dash and then another small gap. @@ -1164,7 +1164,7 @@ The border drawn around some annotations can be controlled by: .. method:: clearBorderDash() - |mutool_tag_wasm_soon| + Clear the entire border dash pattern for an annotation. @@ -1178,7 +1178,7 @@ The border drawn around some annotations can be controlled by: .. method:: addBorderDashItem(length) - |mutool_tag_wasm_soon| + Append an item (of the given length) to the end of the border dash pattern. @@ -1214,7 +1214,7 @@ Annotations that have a border effect allows the effect to be controlled by: .. method:: getBorderEffect() - |mutool_tag_wasm_soon| + Get the annotation border effect, either of "None" or "Cloudy". @@ -1230,7 +1230,7 @@ Annotations that have a border effect allows the effect to be controlled by: .. method:: setBorderEffect(effect) - |mutool_tag_wasm_soon| + Set the annotation border effect, either of "None" or "Cloudy". @@ -1246,7 +1246,7 @@ Annotations that have a border effect allows the effect to be controlled by: .. method:: getBorderEffectIntensity() - |mutool_tag_wasm_soon| + Get the annotation border effect intensity. @@ -1263,7 +1263,7 @@ Annotations that have a border effect allows the effect to be controlled by: .. method:: setBorderEffectIntensity(intensity) - |mutool_tag_wasm_soon| + Set the annotation border effect intensity. Recommended values are between `0` and `2` inclusive. @@ -1308,7 +1308,7 @@ Ink annotations consist of a number of strokes, each consisting of a sequence of .. method:: setInkList(inkList) - |mutool_tag_wasm_soon| + Set the annotation ink list, represented as an array of strokes, each an array of points each an array of its X/Y coordinates. @@ -1331,7 +1331,7 @@ Ink annotations consist of a number of strokes, each consisting of a sequence of .. method:: clearInkList() - |mutool_tag_wasm_soon| + Clear the list of ink strokes for the annotation. @@ -1345,7 +1345,7 @@ Ink annotations consist of a number of strokes, each consisting of a sequence of .. method:: addInkList(stroke) - |mutool_tag_wasm_soon| + To the list of strokes, append a stroke, represented as an array of vertices each an array of its X/Y coordinates. @@ -1368,7 +1368,7 @@ Ink annotations consist of a number of strokes, each consisting of a sequence of .. method:: addInkListStroke() - |mutool_tag_wasm_soon| + Add a new empty stroke to the ink annotation. @@ -1382,7 +1382,7 @@ Ink annotations consist of a number of strokes, each consisting of a sequence of .. method:: addInkListStrokeVertex(vertex) - |mutool_tag_wasm_soon| + Append a vertex to end of the last stroke in the ink annotation. The vertex is an array of its X/Y coordinates. diff --git a/docs/src/mutool-object-pdf-document.rst b/docs/src/mutool-object-pdf-document.rst index 510fda2fac..03bde7d149 100644 --- a/docs/src/mutool-object-pdf-document.rst +++ b/docs/src/mutool-object-pdf-document.rst @@ -24,7 +24,7 @@ With :title:`MuPDF` it is also possible to create, edit and manipulate :title:`P .. method:: new PDFDocument() - |mutool_tag_wasm_soon| + *Constructor method*. @@ -140,7 +140,7 @@ With :title:`MuPDF` it is also possible to create, edit and manipulate :title:`P .. method:: canBeSavedIncrementally() - |mutool_tag_wasm_soon| + Returns *true* if the document can be saved incrementally, e.g. repaired documents or applying redactions prevents incremental saves. @@ -859,7 +859,7 @@ All page objects are structured into a page tree, which defines the order the pa .. method:: addPage(mediabox, rotate, resources, contents) - |mutool_tag_wasm_soon| + Create a new `PDFPage` object. Note: this function does NOT add it to the page tree, use :ref:`insertPage` to do that. @@ -900,7 +900,7 @@ All page objects are structured into a page tree, which defines the order the pa .. method:: addSimpleFont(font, encoding) - |mutool_tag_wasm_soon| + Create a `PDFObject` from the `Font` object as a simple font. @@ -918,7 +918,7 @@ All page objects are structured into a page tree, which defines the order the pa .. method:: addCJKFont(font, language, wmode, style) - |mutool_tag_wasm_soon| + Create a `PDFObject` from the Font object as a UTF-16 encoded CID font for the given language ("zh-Hant", "zh-Hans", "ko", or "ja"), writing mode ("H" or "V"), and style ("serif" or "sans-serif"). @@ -938,7 +938,7 @@ All page objects are structured into a page tree, which defines the order the pa .. method:: addFont(font) - |mutool_tag_wasm_soon| + Create a `PDFObject` from the `Font` object as an Identity-H encoded CID font. @@ -955,7 +955,7 @@ All page objects are structured into a page tree, which defines the order the pa .. method:: addImage(image) - |mutool_tag_wasm_soon| + Create a `PDFObject` from the `Image` object. @@ -1104,7 +1104,7 @@ Embedded files in :title:`PDFs` .. method:: getEmbeddedFileContents(fileSpecObject) - |mutool_tag_wasm_soon| + Returns a `Buffer` with the contents of the embedded file referenced by the `fileSpecObject`. diff --git a/docs/src/mutool-object-pdf-page.rst b/docs/src/mutool-object-pdf-page.rst index a10f2e4659..4b97cefb57 100644 --- a/docs/src/mutool-object-pdf-page.rst +++ b/docs/src/mutool-object-pdf-page.rst @@ -66,33 +66,89 @@ Extends :ref:`Page`. :header-rows: 1 * - **Name** + - **Supported** + - **Notes** * - Text + - Yes + - * - Link + - No + - Please use :ref:`Page.createLink()`. * - FreeText + - Yes + - * - Square + - Yes + - * - Circle + - Yes + - * - Polygon + - Yes + - * - PolyLine + - Yes + - * - Highlight + - Yes + - * - Underline + - Yes + - * - Squiggly + - Yes + - * - StrikeOut + - Yes + - * - Redact + - Yes + - * - Stamp + - Yes + - * - Caret + - Yes + - * - Ink + - Yes + - * - Popup + - No + - * - FileAttachment + - Yes + - * - Sound + - Yes + - * - Movie + - Yes + - * - RichMedia + - No + - * - Widget + - No + - * - Screen + - No + - * - PrinterMark + - No + - * - TrapNet + - No + - * - Watermark + - No + - * - 3D + - No + - * - Projection + - No + - .. method:: deleteAnnotation(annot) diff --git a/docs/src/mutool-object-pixmap.rst b/docs/src/mutool-object-pixmap.rst index cf7f60ac45..d9f243e66d 100644 --- a/docs/src/mutool-object-pixmap.rst +++ b/docs/src/mutool-object-pixmap.rst @@ -101,7 +101,7 @@ A `Pixmap` object contains a color raster image (short for pixel map). The compo .. method:: getAlpha() - |mutool_tag_wasm_soon| + *True* if alpha channel is present. diff --git a/docs/src/mutool-object-stroke-state.rst b/docs/src/mutool-object-stroke-state.rst new file mode 100644 index 0000000000..f62bd1f29e --- /dev/null +++ b/docs/src/mutool-object-stroke-state.rst @@ -0,0 +1,134 @@ +.. Copyright (C) 2001-2023 Artifex Software, Inc. +.. All Rights Reserved. + +---- + +.. default-domain:: js + +.. include:: html_tags.rst + +.. _mutool_object_stroke_state: + +.. _mutool_run_js_api_stroke_state: + +`StrokeState` +-------------- + +A `StrokeState` object is used to define stroke styles. + + +.. method:: new StrokeState() + + + *Constructor method*. + + Create a new empty stroke state object. + + :return: `StrokeState`. + + |example_tag| + + .. code-block:: javascript + + var strokeState = new mupdf.StrokeState(); + + + +|instance_methods| + + + +.. method:: setLineCap(style) + + + :arg style: `String` One of "Butt", "Round" or "Square". + + |example_tag| + + .. code-block:: javascript + + strokeState.setLineCap("Butt"); + + +.. method:: getLineCap() + + + :return: `String` One of "Butt", "Round" or "Square". + + |example_tag| + + .. code-block:: javascript + + var lineCap = strokeState.getLineCap(); + + +.. method:: setLineJoin(style) + + + :arg style: `String` One of "Miter", "Round" or "Bevel". + + |example_tag| + + .. code-block:: javascript + + strokeState.setLineJoin("Butt"); + + +.. method:: getLineJoin() + + + :return: `String` One of "Miter", "Round" or "Bevel". + + |example_tag| + + .. code-block:: javascript + + var lineJoin = strokeState.getLineJoin(); + + +.. method:: setLineWidth(width) + + + :arg width: `Integer`. + + |example_tag| + + .. code-block:: javascript + + strokeState.setLineWidth(2); + + +.. method:: getLineWidth() + + + :return: `Integer`. + + |example_tag| + + .. code-block:: javascript + + var width = strokeState.getLineWidth(); + + +.. method:: setMiterLimit(width) + + + :arg width: `Integer`. + + |example_tag| + + .. code-block:: javascript + + strokeState.setMiterLimit(2); + + +.. method:: getMiterLimit() + + + :return: `Integer`. + + |example_tag| + + .. code-block:: javascript + + var limit = strokeState.getMiterLimit(); diff --git a/docs/src/mutool-object-structured-text.rst b/docs/src/mutool-object-structured-text.rst index 82b705220d..971c5d19f2 100644 --- a/docs/src/mutool-object-structured-text.rst +++ b/docs/src/mutool-object-structured-text.rst @@ -21,7 +21,6 @@ .. method:: search(needle) - |mutool_tag_wasm_soon| Search the text for all instances of `needle`, and return an array with all matches found on the page. @@ -53,7 +52,7 @@ var result = sText.highlight([100,100], [200,100]); - .. |tor_todo| WASM, Even says "TODO" in the mupdf.js source file :) + .. |tor_todo| WASM, "TODO" .. method:: copy(p, q) @@ -70,10 +69,10 @@ .. code-block:: javascript - var result = sText.highlight([100,100], [200,100]); + var result = sText.copy([100,100], [200,100]); - .. |tor_todo| WASM, Even says "TODO" in the mupdf.js source file :) + .. |tor_todo| WASM, "TODO" @@ -90,26 +89,28 @@ var stext = pdfPage.toStructuredText(); stext.walk({ beginLine: function (bbox, wmode, direction) { - print("beginLine", bbox, wmode, direction); + console.log("beginLine", bbox, wmode, direction); }, beginTextBlock: function (bbox) { - print("beginTextBlock", bbox); + console.log("beginTextBlock", bbox); }, endLine: function () { - print("endLine"); + console.log("endLine"); }, endTextBlock: function () { - print("endTextBlock"); + console.log("endTextBlock"); }, onChar: function (utf, origin, font, size, quad, color) { - print("onChar", utf, origin, font, size, quad, color); + console.log("onChar", utf, origin, font, size, quad, color); }, onImageBlock: function (bbox, transform, image) { - print("onImageBlock", bbox, transform, image); + console.log("onImageBlock", bbox, transform, image); }, }); + .. note:: + On `beginLine` the direction parameter is a vector (e.g. `[0, 1]`) and can you can calculate the rotation as an angle with some trigonometry on the vector. .. method:: asJSON() diff --git a/docs/src/mutool-object-text.rst b/docs/src/mutool-object-text.rst index 25d68c28d9..d9e12b1544 100644 --- a/docs/src/mutool-object-text.rst +++ b/docs/src/mutool-object-text.rst @@ -19,7 +19,7 @@ A `Text` object contains text. .. method:: new Text() - |mutool_tag_wasm_soon| + *Constructor method*. diff --git a/docs/src/mutool-run-js-api.rst b/docs/src/mutool-run-js-api.rst index 348ddfc296..b16fa85250 100644 --- a/docs/src/mutool-run-js-api.rst +++ b/docs/src/mutool-run-js-api.rst @@ -271,6 +271,8 @@ Alpha values are floats between `0` and `1`, whereby `0` denotes full transparen .. include:: mutool-object-pdf-widget.rst +.. include:: mutool-object-stroke-state.rst + .. include:: mutool-object-outline-iterator.rst .. include:: mutool-object-archive.rst