### Initialize .NET Environment Source: https://mupdfnet.readthedocs.io/en/latest/getting-started/index.html Commands to verify the .NET SDK installation and install the necessary runtime on Linux systems. ```bash # Check if .NET is installed dotnet --version # If not installed, install it (Ubuntu/Debian example) sudo apt update sudo apt install dotnet-sdk-8.0 ``` -------------------------------- ### Create and Run a .NET Console Project Source: https://mupdfnet.readthedocs.io/en/latest/getting-started/index.html Standard CLI commands to scaffold a new console application, navigate to the directory, and execute the project. ```bash # Create a new console app dotnet new console -n MyProject # Navigate to the project directory cd MyProject # Run the project dotnet run ``` -------------------------------- ### Install MuPDF.NET via NuGet Source: https://mupdfnet.readthedocs.io/en/latest/getting-started/index.html Command to add the MuPDF.NET dependency to an existing .NET project using the NuGet package manager. ```bash dotnet add package MuPDF.NET ``` -------------------------------- ### Create PDF with Text using MuPDF.NET Source: https://mupdfnet.readthedocs.io/en/latest/getting-started/index.html C# code snippet demonstrating how to instantiate a document, create a page, write text using a specific font, and save the resulting PDF file. ```csharp using MuPDF.NET; Document doc = new Document(); Page page = doc.NewPage(); string text = "Made with MuPDF.NET"; // define some text! MuPDF.NET.Font font = new MuPDF.NET.Font("helv"); // define a font to use, in this case Helvetica MuPDF.NET.TextWriter tw = new MuPDF.NET.TextWriter(page.Rect); // define the rectangle for the text tw.Append(new(50, 100), text, font); // define the point where you want to add the text tw.WriteText(page); // use the TextWriter to write the text to the page doc.Save("hello_world.pdf"); // save the result! ``` -------------------------------- ### Create Mutable Identity Matrix in C# Source: https://mupdfnet.readthedocs.io/en/latest/classes/IdentityMatrix.html Demonstrates how to create a mutable Matrix object with identity values in C#. These examples show different ways to initialize a matrix that acts as an identity matrix, useful when a mutable matrix is required as a starting point. ```csharp Matrix m = new Matrix(1, 0, 0, 1, 0, 0); // specify the values Matrix m = new Matrix(1, 1); // use scaling by factor 1 Matrix m = new Matrix(0); // use rotation by zero degrees Matrix m = new Matrix(new IdentityMatrix()); // make a copy of IdentityMatrix ``` -------------------------------- ### Page Rotation Example Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Demonstrates how to rotate a page and calculate the new coordinates of a point using the RotationMatrix. This is useful for accurately placing elements on rotated pages. ```python page.SetRotation(90) # rotate an ISO A4 page page.Rect Point p = new Point(0, 0) # where did top-left point land? p * page.RotationMatrix ``` -------------------------------- ### Iterate Document Pages Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Demonstrates the use of GetPages to generate an iterator over document pages with various start, stop, and step configurations. ```C# doc.GetPages(); doc.GetPages(4, 9, 2); doc.GetPages(0, null, 2); doc.GetPages(-2); doc.GetPages(-1, -1); doc.GetPages(-1, -10); ``` -------------------------------- ### GET /LoadPage Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Creates a Page object for processing, supporting both 0-based page numbers and chapter-page tuples. ```APIDOC ## GET /LoadPage ### Description Creates a Page object for further processing such as rendering or text searching. ### Method GET ### Endpoint /LoadPage ### Parameters #### Request Body - **pageId** (int/tuple) - Required - 0-based page number or (chapter, pno) tuple. ### Response #### Success Response (200) - **Page** (Object) - The loaded page object. ### Response Example { "page": "PageObject" } ``` -------------------------------- ### Matrix Rotation Example Source: https://mupdfnet.readthedocs.io/en/latest/classes/Matrix.html Demonstrates counterclockwise rotation using a matrix. A positive angle 'beta' results in a counterclockwise rotation. This is typically achieved by constructing a matrix with specific values for its trigonometric components. ```python # Example of creating a rotation matrix (conceptual) # In a real implementation, this would involve constructing a Matrix object # with values derived from cos(beta) and sin(beta). # For instance, Matrix(cos(beta), -sin(beta), sin(beta), cos(beta)) # The text mentions Matrix(beta) performs counterclockwise rotations for positive angles beta. # This implies a constructor or a method that takes an angle and creates a rotation matrix. # Conceptual representation: # def create_rotation_matrix(beta): # # This is a placeholder for actual matrix construction logic # return Matrix(math.cos(beta), -math.sin(beta), math.sin(beta), math.cos(beta)) # Example usage: # rotation_angle = math.pi / 4 # 45 degrees # rotation_matrix = create_rotation_matrix(rotation_angle) ``` -------------------------------- ### Initialize Document Objects Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Demonstrates how to instantiate a Document object from a file path, memory stream, or as a new empty PDF. Note that filetype specification is mandatory for non-PDF formats when loading from memory. ```csharp // from a file Document doc = new Document("some.pdf"); // handle wrong extension doc = new Document("some.file", filetype: "xps"); // from memory, filetype is required if not a PDF doc = new Document(filetype: "xps", mem_area); doc = new Document(null, stream: mem_area, filetype: "xps"); doc = new Document(stream: mem_area, filetype: "xps"); // new empty PDF doc = new Document(); doc = new Document(""); ``` -------------------------------- ### Save Pixmap with OCR (C#) Source: https://mupdfnet.readthedocs.io/en/latest/classes/Pixmap.html Performs OCR on an image using Tesseract and saves it as a 1-page PDF with a text layer. Supports compression, language selection, and Tesseract data path configuration. Requires Tesseract installation and proper environment setup. ```csharp public void SavePdfOCR(string filename, bool compress = true, string language = "eng", string tessdata = null) ``` -------------------------------- ### Create a Pie Chart with Different Colors Source: https://mupdfnet.readthedocs.io/en/latest/classes/Shape.html Illustrates how to draw a full circle composed of multiple pie slices, each with a different color. It shows the pattern of creating a shape, drawing sectors, finishing each sector with a specific color, and finally committing the shape to the page. ```csharp Shape shape = page.NewShape(); // start a new shape float[] cols = (...); // a sequence of RGB color triples int pieces = len(cols); // number of pieces to draw float beta = 360.0f / pieces; // angle of each piece of pie center = new Point(...); // center of the pie p0 = new Point(...); // starting point for (int i = 0; i < pieces; i ++) Point p0 = shape.DrawSector(center, p0, beta, fullSector=true) // draw piece // now fill it but do not connect ends of the arc shape.Finish(fill: cols[i], closePath: false) shape.Commit(); // update the page ``` -------------------------------- ### OCMD Visibility Policies - Python Example Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Demonstrates using the 'policy' parameter in SetOCMD to define OCMD visibility. Policies like 'AnyOn', 'AnyOff', 'AllOn', and 'AllOff' control visibility based on the state of associated OCGs. ```python # Example: Make an object visible only if OCG with xref 10 is OFF # SetOCMD(ocgs=[10], policy="AllOff") # Example: Make an object visible if OCG with xref 10 is ON # SetOCMD(ocgs=[10], policy="AnyOn") ``` -------------------------------- ### Get Page Label and Links Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Retrieve the label associated with a PDF page or get a list of all interactive links present on the page. The label retrieval is PDF-specific. ```csharp string pageLabel = page.GetLabel(); List allLinks = page.GetLinks(); ``` -------------------------------- ### Get Page Image Rectangles and References Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Obtain improved bounding box information for images on a PDF page, or get a list of all referenced images. These operations are exclusive to PDF documents. ```csharp List imageRects = page.GetImageRects(); List referencedImages = page.GetImages(); ``` -------------------------------- ### Initialize and Execute DisplayList Source: https://mupdfnet.readthedocs.io/en/latest/classes/DisplayList.html Demonstrates how to instantiate a new DisplayList with a mediabox and execute it to generate a pixmap or extract text. These methods allow for efficient document rendering and data extraction without re-parsing the source file. ```csharp // Create a new display list with a specified mediabox Rect mediabox = new Rect(0, 0, 600, 800); DisplayList dl = new DisplayList(mediabox); // Generate a pixmap from the display list Pixmap pixmap = dl.GetPixmap(matrix: null, colorSpace: null, alpha: 0, clip: null); // Generate a text page from the display list // Flags: 3 = TEXT_PRESERVE_LIGATURES | TEXT_PRESERVE_WHITESPACE TextPage textPage = dl.GetTextPage(3); ``` -------------------------------- ### Add Nodes to DOM using Xml (Context Manager Support) Source: https://mupdfnet.readthedocs.io/en/latest/classes/Xml.html Illustrates the use of context manager support for Xml methods, providing a more concise way to chain operations. This example shows how to set text properties and add text in a fluent manner, reducing boilerplate code. ```csharp Xml body = story.Body; Xml para = body.AddParagraph(); para.SetBold().AddText("some bold text"); para.SetItalic().AddText("this is bold and italic"); para.SetItalic(false).SetBold(false).AddText("regular text"); para.AddText("more regular text"); ``` -------------------------------- ### Get Page Bounding Box and Image Information Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Retrieve the bounding box and matrix of embedded images, or get a list of meta-information for all images used on a PDF page. These functions are specific to PDF documents. ```csharp Rect bbox = page.GetImageBbox(); List imageInfoList = page.GetImageInfo(); ``` -------------------------------- ### GET /utils/GetArea Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Calculates the area of a rectangle in specified units. ```APIDOC ## GET GetArea ### Description Calculate area of rectangle. Parameter is one of ‘px’ (default), ‘in’, ‘cm’, or ‘mm’. ### Method GET ### Parameters #### Query Parameters - **rect** (Rect) - Required - Rectangle to calculate area for. - **unit** (string) - Optional - Unit used (px, in, cm, mm). ### Response #### Success Response (200) - **area** (float) - The calculated area. ``` -------------------------------- ### Matrix Class Constructors Source: https://mupdfnet.readthedocs.io/en/latest/classes/Matrix.html Provides details on the various ways to construct a Matrix object, including default, zoom/shear, copy, rotation, and rect-based matrices. ```APIDOC ## Matrix Class Constructors ### Description Overloaded constructors for the Matrix class allow for creation of matrices with default values, specific zoom or shear factors, copies of existing matrices, rotation matrices based on degrees, or matrices derived from a Rect object. ### Constructors - `Matrix()`: Creates a zero matrix `[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]`. - `Matrix(_float zoom-x_, _float zoom-y_)`: Creates a zoom matrix. - `Matrix(_float shear-x_, _float shear-y_, _1_)`: Creates a shear matrix. - `Matrix(_float a_, _float b_, _float c_, _float d_, _float e_, _float f_)`: Creates a matrix with specified values. - `Matrix(_Matrix matrix_)`: Creates a new copy of an existing matrix. - `Matrix(_int degree_)`: Creates a rotation matrix for anti-clockwise rotation by the specified degrees. - `Matrix(_Rect rect_)`: Creates a matrix based on a Rect object. ### Special Cases - `Matrix(1, 1)` and `Matrix(IdentityMatrix)`: Create modifiable versions of the Identity Matrix `[1, 0, 0, 1, 0, 0]`. ``` -------------------------------- ### GET /PaperSize Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Retrieves the dimensions of a specified paper format. ```APIDOC ## GET /PaperSize ### Description Returns the width and height of a paper format. Format names are case-insensitive and support '-L' (landscape) or '-P' (portrait) suffixes. ### Method GET ### Endpoint /PaperSize ### Parameters #### Query Parameters - **s** (string) - Required - The paper format name (e.g., "A4", "letter-l"). ### Response #### Success Response (200) - **width** (int) - The width of the paper. - **height** (int) - The height of the paper. #### Response Example { "width": 595, "height": 842 } ``` -------------------------------- ### GET /GetAttributes Source: https://mupdfnet.readthedocs.io/en/latest/classes/Xml.html Retrieves all attributes associated with the current node. ```APIDOC ## GET /GetAttributes ### Description Returns a dictionary containing all attributes and their values for the current node. ### Method GET ### Endpoint /GetAttributes ### Response #### Success Response (200) - **attributes** (object) - Dictionary of key-value pairs. #### Response Example { "id": "node1", "class": "text-bold" } ``` -------------------------------- ### Create a Regular Polygon with Custom Styling Source: https://mupdfnet.readthedocs.io/en/latest/classes/Shape.html Shows how to draw a regular n-sided polygon with a specific border color and fill color. It utilizes `DrawSector` to calculate vertex points and then `DrawPolyline` to draw the polygon, demonstrating how to clear the draw buffer before drawing the actual polygon. ```csharp Shape shape = page.NewShape(); // start a new shape float beta = -360.0f / n; // our angle, drawn clockwise Point center = new Point(...); // center of circle Point p0 = new Point(...); // start here (1st edge) List points = new List(p0); // store polygon edges for (int i = 0; i < n; i ++) // calculate the edges Point p0 = shape.DrawSector(center, p0, beta); points.Add(p0); shape.DrawCont = ""; // do not draw the circle sectors shape.DrawPolyline(points); # draw the polygon shape.Finish(color: {1,0,0}, fill: {1,1,0}, closePath: false); shape.Commit(); ``` -------------------------------- ### Display PDF Page with Rotation Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Demonstrates how to display a page from a source PDF document onto a target page, with options for rotation and clipping. This method imports other resources like text, images, and fonts from the source. ```csharp Document doc = new Document() // new empty PDF Page page=doc.NewPage() // new page in A4 format // upper half page Rect r1 = new Rect(0, 0, page.rect.width, page.rect.height/2) // lower half page Rect r2 = r1 + new Rect(0, page.rect.height/2, 0, page.rect.height/2) Document src = new Document("MuPDF.pdf") // show page 0 of this page.ShowPdfPage(r1, src, 0, rotate=90) page.ShowPdfPage(r2, src, 0, rotate=-90) doc.Save("show.pdf") ``` -------------------------------- ### GET /Link/Border Source: https://mupdfnet.readthedocs.io/en/latest/classes/Link.html Retrieves the current border characteristics of the link annotation. ```APIDOC ## GET /Link/Border ### Description Returns a dictionary containing the current border settings of the link. ### Method GET ### Endpoint /Link/Border ### Response #### Success Response (200) - **width** (float) - Border thickness. - **dashes** (int[]) - Dash pattern. - **style** (string) - Border style identifier. #### Response Example { "width": 1.0, "dashes": [], "style": "S" } ``` -------------------------------- ### GET /page/read-barcodes Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Scans a specified area of the page to retrieve barcode information. ```APIDOC ## GET /page/read-barcodes ### Description Retrieves barcode data from a defined rectangle on the page. Supports various barcode formats and decoding configurations. ### Method GET ### Parameters #### Query Parameters - **clip** (Rect) - Optional - Area to scan. - **type** (BarcodeFormat) - Optional - Format of the barcode to decode. - **multi** (bool) - Optional - Whether to attempt reading multiple barcodes. ### Response #### Success Response (200) - **barcodes** (List) - A list of decoded Barcode objects. ``` -------------------------------- ### Create a TextPage for extraction Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Initializes a TextPage object which serves as the foundation for subsequent text extraction and search operations. Parameters allow for clipping the area of interest and setting extraction flags. ```csharp TextPage tp = page.GetTextPage(clip: new Rect(0, 0, 100, 100), flags: 3); ``` -------------------------------- ### GET /utils/GetAnnotByName Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Retrieves a specific PDF annotation from a page by its name identifier. ```APIDOC ## GET GetAnnotByName ### Description Retrieve annotation by name (/NM key) from a given page. ### Method GET ### Parameters #### Query Parameters - **page** (Page) - Required - Page object containing annotations. - **name** (string) - Required - Annotation name to search for. ### Response #### Success Response (200) - **PdfAnnot** (Object) - The PdfAnnot object matching the name. ``` -------------------------------- ### GET /utils/CalcImageMatrix Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Calculates the transformation matrix required for inserting an image into a target rectangle. ```APIDOC ## GET CalcImageMatrix ### Description Compute image insertion matrix based on dimensions and target rectangle. ### Method GET ### Parameters #### Query Parameters - **width** (int) - Required - Image width. - **height** (int) - Required - Image height. - **tr** (Rect) - Required - Rectangle of target image. - **rotate** (float) - Required - Rotation to be set for target image. - **keep** (bool) - Required - Calculate size of target image keeping origin image’s ratio. ### Response #### Success Response (200) - **Matrix** (Object) - The resulting transformation matrix. ``` -------------------------------- ### OCMD Visibility Expression (VE) - Python Example Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Illustrates creating complex visibility conditions for OCMDs using the 've' (visibility expression) parameter. Expressions can combine OCGs using logical operators like 'and', 'or', and 'not'. ```python # Example: ON if OCG 4 is ON, or OCG 5 is OFF, or both OCG 6 and 7 are ON # SetOCMD(ve=["or", 4, ["not", 5], ["and", 6, 7]]) # Example: Equivalent to policy "AllOff" for a single OCG # SetOCMD(ve=["not", xref]) ``` -------------------------------- ### GET /GetTextLength Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Calculates the rendered length of a text string based on font and size. ```APIDOC ## GET /GetTextLength ### Description Calculates the length of a text string in points using a built-in font, size, and encoding. ### Method GET ### Endpoint /GetTextLength ### Parameters #### Query Parameters - **text** (string) - Required - The text string to measure. - **fontName** (string) - Optional - Default: "helv". - **fontSize** (float) - Optional - Default: 11. - **encoding** (int) - Optional - 0=Latin, 1=Greek, 2=Cyrillic. ### Response #### Success Response (200) - **length** (float) - The length in points. #### Response Example { "length": 45.5 } ``` -------------------------------- ### Add Nodes to DOM using Xml (Standard Method) Source: https://mupdfnet.readthedocs.io/en/latest/classes/Xml.html Demonstrates the standard method for adding nodes to a DOM using Xml. It shows how to add a paragraph, set its properties like bold and italic, and add text. This method involves sequential calls for each modification. ```csharp Xml body = story.Body; Xml para = body.AddParagraph(); // add a paragraph para.SetBold(); // text that follows will be bold para.AddText("some bold text"); para.SetItalic(); // text that follows will additionally be italic para.add_txt("this is bold and italic"); para.SetItalic(false).SetBold(false); // all following text will be regular para.AddText("regular text"); ``` -------------------------------- ### GET /sRGB2Pdf Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Converts an sRGB integer color to a normalized PDF color tuple. ```APIDOC ## GET /sRGB2Pdf ### Description Converts an integer sRGB color (RRGGBB) into a tuple of floats (red, green, blue) in the range [0, 1]. ### Method GET ### Endpoint /sRGB2Pdf ### Parameters #### Query Parameters - **srgb** (int) - Required - Integer color in RRGGBB format. ### Response #### Success Response (200) - **color** (tuple) - (red, green, blue) float values. #### Response Example { "color": [1.0, 0.0, 0.0] } ``` -------------------------------- ### MuPDF.NET Inbuilt Fonts Example (C#) Source: https://mupdfnet.readthedocs.io/en/latest/glossary/vars.html Demonstrates how to instantiate Font objects using inbuilt font references in MuPDF.NET. This allows for the creation of fonts without external files, utilizing predefined font styles. ```csharp MuPDF.NET.Font fontA = new MuPDF.NET.Font(""); // choose the Noto Serif Regular font MUPDF.NET.Font fontB = new MuPDF.NET.Font("helv"); // choose the Helvetica font ``` -------------------------------- ### GET /document/entry-structure Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Retrieves the internal entry structure for images, fonts, and forms within the document. ```APIDOC ## GET /document/entry-structure ### Description Returns the structural details for document resources such as images, fonts, and form objects. ### Method GET ### Response #### Success Response (200) - **Xref** (int) - Object number. - **Name** (string) - Name or basefont name. - **Ext** (string) - File extension. - **Width/Height** (int) - Image dimensions. - **Bpc** (int) - Bits per component. - **CsName** (string) - Colorspace name. - **Filter** (string) - Decode filter. - **Type** (string) - Font type (e.g., "TrueType"). #### Response Example { "Xref": 12, "Name": "Arial", "Type": "TrueType", "Ext": "ttf" } ``` -------------------------------- ### Rect Constructors Source: https://mupdfnet.readthedocs.io/en/latest/classes/Rect.html Details the different ways to construct a Rect object. ```APIDOC ## Rect Constructors ### Description This section outlines the available constructors for creating `Rect` objects in MuPDF. ### Constructors * **`Rect()`** * Creates a default rectangle. The specific default values may depend on the context or library version, but it typically represents an empty or invalid state. * **`Rect(_float x0_, _float y0_, _float x1_, _float y1_)`** * Creates a rectangle using four floating-point coordinates defining two diagonally opposite points. * **Parameters**: * `x0` (float): The x-coordinate of the first point. * `y0` (float): The y-coordinate of the first point. * `x1` (float): The x-coordinate of the second point. * `y1` (float): The y-coordinate of the second point. * **`Rect(_Point tl_, _Point br_)`** * Creates a rectangle using two `Point` objects, representing the top-left (`tl`) and bottom-right (`br`) corners. * **Parameters**: * `tl` (Point): The top-left point of the rectangle. * `br` (Point): The bottom-right point of the rectangle. ``` -------------------------------- ### GET /document/page-methods Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Overview of homologous methods available on both Document and Page objects for content extraction. ```APIDOC ## GET /document/page-methods ### Description Retrieves content from a document or page. Document-level methods act as wrappers that load and discard pages, while Page-level methods operate directly on the object. ### Method GET ### Parameters #### Query Parameters - **pno** (int) - Required - 0-based page index ### Response #### Success Response (200) - **data** (object) - Returns requested content (Fonts, Images, Pixmap, Text, or Search results) ### Response Example { "method": "GetPageText", "content": "Extracted text from page..." } ``` -------------------------------- ### GET /matrix/properties Source: https://mupdfnet.readthedocs.io/en/latest/classes/Matrix.html Retrieves the transformation attributes of a matrix, including scaling, shearing, and shifting factors. ```APIDOC ## GET /matrix/properties ### Description Returns the current transformation attributes of the matrix, which define scaling (A, D), shearing (B, C), and translation (E, F). ### Method GET ### Endpoint /matrix/properties ### Response #### Success Response (200) - **A** (float) - Scaling in X-direction. - **B** (float) - Shearing effect (x, y - b*x). - **C** (float) - Shearing effect (x - c*y, y). - **D** (float) - Scaling in Y-direction. - **E** (float) - Horizontal shift. - **F** (float) - Vertical shift. - **IsRectilinear** (bool) - Indicates if no shearing is present and rotations are multiples of 90 degrees. ### Response Example { "A": 1.0, "B": 0.0, "C": 0.0, "D": 1.0, "E": 10.0, "F": 20.0, "IsRectilinear": true } ``` -------------------------------- ### Run Page Through Device and Search Text Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Process the page using a specified device (e.g., for rendering) or search for a specific string within the page's content. The `Run` method is versatile for outputting page data. ```csharp page.Run(device); List foundPositions = page.SearchFor("search string"); ``` -------------------------------- ### GET /PageXref Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Retrieves the xref of a page without loading the full page object for performance optimization. ```APIDOC ## GET /PageXref ### Description Returns the xref of the page without loading the page via LoadPage(). ### Method GET ### Endpoint /PageXref ### Parameters #### Query Parameters - **pno** (int) - Required - 0-based page number. ### Response #### Success Response (200) - **xref** (int) - The xref identifier. ``` -------------------------------- ### Define PDF page labels using SetPageLabels Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Demonstrates the structure of the list of dictionaries required to define page labeling rules in a PDF. Each dictionary specifies the starting page, prefix, numbering style, and initial page number. ```python [{'StartPage': 6, 'Prefix': 'A-', 'Style': 'D', 'FirstPageNum': 10}, {'StartPage': 10, 'Prefix': '', 'Style': 'D', 'FirstPageNum': 1}] ``` -------------------------------- ### Page Display List Source: https://mupdfnet.readthedocs.io/en/latest/classes/Page.html Runs a page through a list device and returns its display list, which represents how the page is rendered. ```APIDOC ## GET /page/display-list ### Description Run a page through a list device and return its display list. ### Method GET ### Endpoint /page/display-list ### Parameters #### Query Parameters - **page_number** (int) - Required - The page number to generate the display list for. - **annots** (int) - Optional - A flag (typically 1) to include annotations in the display list. ### Response #### Success Response (200) - **display_list** (DisplayList) - The display list of the page. ``` -------------------------------- ### GET /document/properties Source: https://mupdfnet.readthedocs.io/en/latest/classes/Document.html Retrieves the core properties and metadata of a loaded document, including security status and structural information. ```APIDOC ## GET /document/properties ### Description Retrieves the current state and metadata of the loaded document object. ### Method GET ### Parameters None ### Response #### Success Response (200) - **PageLayout** (string) - The layout mode (e.g., "SinglePage"). - **VersionCount** (int) - Number of incremental saves plus one. - **NeedsPass** (bool) - Indicates if document is password-protected. - **IsEncrypted** (bool) - Indicates if document is currently encrypted. - **Permissions** (int) - Bitmask representing access permissions. - **MetaData** (Dictionary) - Document metadata (title, author, format, etc.). - **Name** (string) - Filename or filetype. - **PageCount** (int) - Total number of pages. - **ChapterCount** (int) - Total number of chapters. - **LastLocation** (int) - Last page/chapter location. - **FormFonts** (List) - List of form field font names. #### Response Example { "PageLayout": "SinglePage", "PageCount": 10, "IsEncrypted": false, "MetaData": { "format": "PDF-1.6", "title": "Document Title" } } ``` -------------------------------- ### Initialize Pixmap from various sources Source: https://mupdfnet.readthedocs.io/en/latest/classes/Pixmap.html Constructors for creating a Pixmap object. Supports copying existing pixmaps, loading from files, memory streams, raw byte arrays, or existing PDF image objects. ```csharp // Copy and add/drop alpha Pixmap p1 = new Pixmap(source, 1); // From file Pixmap p2 = new Pixmap("image.png"); // From memory stream Pixmap p3 = new Pixmap(byteArray); // From raw pixels Pixmap p4 = new Pixmap(colorspace, width, height, samples, alpha); // From PDF image Pixmap p5 = new Pixmap(doc, xref); ``` -------------------------------- ### GET /utils/RecoverLineQuad Source: https://mupdfnet.readthedocs.io/en/latest/glossary/Utils.html Computes the quadrilateral of a subset of spans within a text line, useful for text marker annotations. ```APIDOC ## GET RecoverLineQuad ### Description Compute the quadrilateral of a subset of spans of a text line extracted via options “dict” or “rawdict” of Page.GetText(). ### Method GET ### Endpoint RecoverLineQuad(Line line, List spans: None) ### Parameters #### Path Parameters - **line** (Line) - Required - The line object. - **spans** (List) - Optional - A sub-list of line.Spans. If omitted, the full line quad is returned. ### Response #### Success Response (200) - **Quad** (Object) - The Quad of the selected line spans. ```