# OFD Editor quick start

Open a real OFD, edit a paragraph, download it and reopen the result.

The live editor opens a native OFD guide containing editable paragraphs, tables and page headers. The workspace currently uses Chinese labels. This guide includes those labels so you can follow along. [Open the full OFD Editor](https://quirekit.com/demo/ofd-editor/)

## Make your first edit

1. Click a sentence in the body of the first page and type. The status bar displays 正文编辑 (body editing).
2. Open 文件 → 导出 → OFD (.ofd) to download the edited file.
3. Choose 文件 → 导入 → OFD 文档 to reopen your download and check the same sentence. To start a new official document, open 文件 → 文档模板库 → 公文示例, then choose 用模板新建.

## Inspect an OFD

Read the sample to see its declared type and physical page count. You can also select your own file. The example reads the native package locally using the MIT-licensed `@quirekit/ofd/preservation` entry. The full workspace is provided by the commercial `@quirekit/ofd-editor` component.

### demos/inspect-file.vue

```vue
<script setup lang="ts">
import { computed, onBeforeUnmount, ref } from "vue";
import { openOFDSource } from "@quirekit/ofd/preservation";
import { QuireButton, QuireFileUpload, QuireIcon } from "@quirekit/ui/vue";

const props = defineProps<{ /** Page language from the documentation shell. */ locale?: string }>();
const english = computed(() => props.locale === "en");
const result = ref<{ name: string; kind: string; pages: number }>();
const failed = ref(false);
const busy = ref(false);
let selection = 0;
onBeforeUnmount(() => { selection++; });

/**
 * Reads only the latest file selected, entirely in this browser.
 * @param file - A local file, or the packaged guide when omitted.
 * @returns Resolves when file facts or a readable error are displayed.
 */
async function inspect(file?: File): Promise<void> {
  const current = ++selection;
  result.value = undefined;
  failed.value = false;
  busy.value = true;
  try {
    let bytes: ArrayBuffer;
    if (file) bytes = await file.arrayBuffer();
    else {
      const response = await fetch("/downloads/guide.ofd");
      if (!response.ok) throw new Error("Sample unavailable");
      bytes = await response.arrayBuffer();
    }
    if (current !== selection) return;
    const source = openOFDSource(new Uint8Array(bytes));
    result.value = { name: file?.name ?? "guide.ofd", kind: source.documentType ?? "OFD", pages: source.pages.length };
  } catch {
    if (current === selection) failed.value = true;
  } finally {
    if (current === selection) busy.value = false;
  }
}
</script>

<template>
  <div class="file-inspector">
    <div class="file-actions">
      <QuireButton size="sm" @click="inspect()">{{ english ? "Inspect the sample" : "读取示例 OFD" }}</QuireButton>
      <QuireFileUpload :model-value="[]" accept=".ofd" :label="english ? 'Open a local OFD' : '打开本地 OFD'"
        @file-accept="({ files }) => files[0] && inspect(files[0])">
        <template #default="{ openFilePicker }">
          <QuireButton size="sm" variant="outline" @click="openFilePicker">
            <template #leading><QuireIcon name="folderOpen" /></template>
            {{ english ? "Choose a local OFD" : "选择本地 OFD" }}
          </QuireButton>
        </template>
      </QuireFileUpload>
    </div>
    <p aria-live="polite" role="status">
      <template v-if="busy">{{ english ? "Reading file…" : "正在读取文件…" }}</template>
      <template v-else-if="failed">{{ english ? "Could not read this file. Select a valid OFD or try the sample again." : "文件读取失败，请选择有效的 OFD 或重新读取示例。" }}</template>
      <template v-else-if="result">{{ result.name }} · {{ result.kind }} · {{ result.pages }} {{ english ? "pages" : "页" }}</template>
      <template v-else>{{ english ? "Selected files are read in your browser." : "选择的文件仅在当前浏览器中读取。" }}</template>
    </p>
  </div>
</template>

<style scoped>
.file-inspector { display: grid; gap: 12px; padding: 16px; }
.file-actions { display: flex; gap: 8px; align-items: start; flex-wrap: wrap; }
.file-inspector p { margin: 0; overflow-wrap: anywhere; color: var(--qk-color-text-secondary); }
</style>

```

## Go further

| Task | Guide |
| --- | --- |
| Find editable content, change a header or fill a field | [Editing and saving](/en/guide/editing) |
| Save an official document layout for reuse | [Create and update templates](/en/guide/templates) |
| Check paper size or print several files in order | [Printing and batch jobs](/en/guide/printing) |
| Supply a Word/PDF copy or preserve a signed original | [Conversion, signatures and archiving](/en/guide/exchange) |
| Embed the workspace and observe its document session | [Embed the workspace](/en/integration/embed) |
| Fill a template from a spreadsheet, a business system or a HIS | [One fill-data contract](/en/integration/data) |
| Use hospital templates, CDA or issued records | [OFD-H medical extension](/en/integration/medical) |
