Skip to main content

Referencia

MarkpdfClient

string
required
Tu API key.
string
default:"https://api.markpdf.tech"
URL base of API.
Unlike SDK of Node.js, this client is standalone: ​​it does not wrap @markpdf/sdk, it implements the calls directly on the fetch/FormData globals of React Native.

Methods

convertLocalFile

Upload a local file (from a picker) via POST /convert (multipart/form-data), using the { uri, name, type } format that React Native recognizes in FormData to attach files without reading them in JS.
string
required
URI local to the file (file://... or content://...), as returned by the picker.
string
required
File name to send.
string
default:"application/octet-stream"
Content-Type of the file.

convertFromUrl

Calls POST /convert/from-url with a body JSON — does not upload any files, API downloads URL server-side.
string
required
URL public (or signed) of the document to be converted. The API is downloaded directly; It does not go through the device.
string
File name to associate with the result. If omitted, API attempts to infer it from URL.
ConvertOptions
Same options as convertLocalFile.

pdfIndex

Call POST /pdf/index. Returns the spine of PDF without converting it — useful for an agent to decide what range of pages to request before spending a full conversion. See POST /pdf/index.

getJob / waitForJob

string
required
Job identifier (job_id) returned by API when 202 responds.
number
default:"5000"
Milliseconds between each GET /jobs/{id}.
number
If specified, waitForJob throws a generic Error upon passing without the job having finished. Without timeoutMs, it polls indefinitely until completed or failed.
getJob queries GET /jobs/{id} only once and returns Job as it is (may follow "queued" or "processing"). waitForJob does repeated poll until status is "completed" or "failed":
  • If status === "failed", waitForJob launches JobFailedError (does not return the failed job, launches).
  • If status === "completed", returns Job with body populated (string or JsonResult depending on responseFormat of the original job).
  • If timeoutMs is exceeded, throws a generic Error (not MarkpdfError).

ConvertOptions

All fields are optional; they apply to convertLocalFile, convertFromUrl and convert() of useConvertFile.
"auto" | "pdf" | "docx" | "csv" | "txt" | "xlsx" | "pptx" | "zip"
default:"auto"
Input file format. "auto" detects it by extension/content. Set this explicitly if you upload a file without a reliable extension (for example an Android content:// URI with no clear name).
"fast" | "ultra_fast" | "balanced" | "quality" | "auto"
default:"fast"
Conversion speed/quality profile. "ultra_fast" prioritizes latency, "quality" prioritizes fidelity of the resulting Markdown, "auto" lets the backend decide based on the document.
boolean
default:"true"
boolean
default:"false"
boolean
default:"false"
"markdown" | "json"
default:"markdown"
If it is "json", the resolved response is an object JsonResult with metadata (engine, size_bytes, timings, etc.) in addition to the Markdown. With "markdown" (default), the resolved response is directly string.
boolean
default:"false"
Reduces Markdown to a more compact version (less spacing/redundant metadata), intended to minimize tokens in RAG/LLM pipelines.
string
Page range 1-based, only applies to PDF. Examples: "1,3,5-10", "120-145". Useful on mobile to avoid uploading/processing entire documents of hundreds of pages when you only need one section.
boolean
default:"true"
If API responds 202 (saturated backends), convertLocalFile/convertFromUrl do automatic polling via waitForJob until the job finishes. useConvertFile does not honor this option — it always requires manual handling of 202 because it uses XMLHttpRequest instead of waitForJob. See Streaming and asynchronous jobs.
number
default:"5000"
Interval between each poll to GET /jobs/{id} when autoPoll is active.

useConvertFile(client)

Same as convertLocalFile, but with upload progress via XMLHttpRequest (RN implements XMLHttpRequest globally, unlike the browser with only fetch). Takes client as argument — does not use context/Provider.

Tipos

ConvertResult is Job only if autoPoll: false and API responded 202; otherwise convertLocalFile/convertFromUrl have already resolved the job internally.