Skip to content

Pages, page turning and PDF/EPUB import

Adding and moving between pages should need no menu. This page describes what the editor does and where the code lives.

Turning and adding pages

In Single Page layout the page follows your finger.

  • Swipe left or right to turn the page. The next or previous page slides in beside it with a grey gutter and a thin edge line, so the page limits are easy to see. A short fast flick also turns the page.
  • On the last page, swipe left. The new blank page slides in from the right with a Swipe to add page hint; past about a quarter of the screen it changes to Release to add page with a vibration. Let go and the same page finishes sliding in. Let go early and the page springs back.
  • With “Write with finger” on, one finger writes, so use two fingers to swipe. With it off, one finger swipes.
  • The + button in the top bar replaces the › arrow on the last page and adds a page at the end.
  • Page+ shows each paper (Blank, Ruled, Grid, Daily planner) as a card with a preview.

Writing never adds pages on its own.

How it works: InkCanvasView.onPageDrag reports the horizontal drag in screen coordinates (the page view itself moves, so local coordinates cannot measure it). NotebookEditor shifts the canvas with an Animatable, shows the neighbour from a full-quality snapshot (PageSnapshots.kt, same renderer, ink engine and image size as the real canvas, so nothing changes when the real page lands) and warms the shared image cache so the landing page never flashes blank.

Page manager

Open it from the page counter. Cards are small (about four per row on a tablet). Select (or a long press on a page) switches to selection mode: tick pages, Select all, then Delete after a confirmation. A notebook always keeps at least one page.

Drag images in from another app

With Folio and another app in split screen, long-press an image in the other app (Google Images in Chrome, Photos, Files) and drop it on a notebook page. It lands where you let go, at half the page width with its own proportions, and is selected right away so you can move, resize or rotate it. The drop goes through the same import as Insert → Image, so Folio keeps its own copy and Undo works. Drops are refused on a hidden or locked layer, and an app that drags only a link (no image file) is ignored. The PDF reader doesn’t take drops yet.

In split screen a page keeps the shape it has full screen and scrolls (two fingers, the Pan tool, or one finger with finger drawing off) instead of being squashed into the smaller window.

Chrome and Folio in split screen: a cat photo dragged from Google Images onto a notebook page

Code: InkCanvasView.handleImageDrag (drop target), NotebookViewModel.mergeEditorImport (placement), ViewUtils.isReducedWindow and InkCanvasView.documentAspect (page shape in split screen).

Import a PDF, EPUB, Word or PowerPoint file as a notebook

+ → Import as notebook (PDF, EPUB, Word, PowerPoint) bypasses the reader.

PDF EPUB
Result One notebook page per PDF page, shown as a picture you write over Pages of typed text; each chapter starts a new page
Kept The page exactly as rendered (up to 1200×1920 px; 1920 px wide for landscape pages) Text only, in a reading font
Left out Selectable text and search Images, fonts and layout
Limits 1–500 pages (a longer PDF gets a message suggesting it be imported as a book), up to 1 GB with a free-storage check DRM books are rejected; at most 600 pages; up to 1 GB

Page orientation: the first page decides the notebook’s page shape. A portrait document makes normal pages; a landscape one (a slide deck, a landscape PDF) makes a notebook of wide pages with the document’s own shape (Notebook.pageAspect, set by NotebookFiles.importPdfPages), which each page fills. Other pages are fitted inside that shape, and pages added later (blank pages, Insert PDF) take it too. Wide pages are shown across the screen in portrait (centred, on the grey desk) and as large as fits in landscape; thumbnails, page-turn previews and PDF/PNG export (1920 px wide) keep the shape. Ink on a wide page uses the page’s own height in ink units (JetpackInkEngine.heightUnits), so pen tips stay round.

Word (.docx) and PowerPoint (.pptx), experimental: Folio first asks how to import (OfficeImportDialog, tags office-import-editable, office-import-static, office-import-cancel): Picture (exact copy) makes each page or slide one picture with its text, like a PDF; Editable text (below) keeps the design and makes the text editable. A narrow centred sheet: two stacked option cards (icon, name, two-word hint), Picture first and selected by default, then a full-width Import button (office-import-confirm) and Cancel. Cancel imports nothing; the font question, if any, comes after this choice. With Editable text, each page or slide keeps its exact design and its text stays editable. The file is rendered on the device in an offline WebView (OfficeRenderer, bundled in assets/office); the renderer lifts the text off every page (office-renderer/src/text-blocks.js) and prints only the design to a PDF, so nothing is uploaded. Each notebook page gets three layers: Page (the design picture, locked), Text (one editable text block per text box or paragraph, at its original position, size, colour, bold/italic and alignment, with the line breaks as laid out) and Layer 1 for writing, which is where the pen starts (startLayer). Text blocks draw with the document’s own fonts: the renderer’s metric-compatible substitutes (Carlito for Calibri, Liberation for Arial and Times…), fonts embedded in the file and the Noto fonts for other scripts are copied into the notebook’s media as font-<sha256>.ttf (InkText.fontFiles, carried by .folio exports), so lines break as in the original. Rotated text boxes, gradient-filled text, charts, SmartArt and list numbers stay in the picture; EMF images may show as placeholders. If the renderer’s page count doesn’t match the PDF, the file imports as pictures with the text in them.

Writing systems the bundled fonts lack (Hindi and the other Indic scripts, Thai, Hebrew, Armenian, Georgian, Ethiopic, Khmer, Lao, Myanmar, Sinhala, Tibetan; issue #9): before rendering, OfficeFonts scans the file’s XML for those scripts (shared writingSystemsIn) and hands the renderer one Noto font per script: the phone’s own (/system/fonts), else a download through Android’s Downloadable Fonts (Google Play services fetches the free Noto font from Google Fonts and caches it; only the font name is sent), else the bundled Noto Sans Devanagari (assets/fonts). The download asks first: when a script has neither a phone font nor a bundled one (OfficeFonts.downloadsNeeded; Devanagari always has the bundled one), the import waits on a Download fonts? dialog naming the scripts (FontDownloadDialog, tags font-download-dialog, font-download-accept, font-download-decline). Download imports with the download allowed, Import without imports with the fonts the phone has, and dismissing the dialog cancels the import. The renderer serves them at ./fonts/ and passes them to the slide engine (openPresentation({ fonts })) and to Word layout (@font-face). Offline, a script with no font still imports, with that text drawn by the system fallback. Chinese, Japanese and Korean are not handled (their fonts are 15–25 MB).

Legacy Word (.doc) and PowerPoint (.ppt) 97–2003: imported as typed-text pages, like an EPUB: the text is read on the device without any library (shared LegacyOffice.kt: the OLE compound file, Word’s piece table, PowerPoint’s slide text atoms through the persist directory), and each slide starts a new page. Formatting, pictures and charts are left out; password-protected files and Word 95 or older are rejected with a message.

Open with: choosing Folio for a PDF or EPUB in a file manager opens it in the reader; a .docx, .pptx, .doc or .ppt is imported as a new notebook (MainActivity.openViewIntent). File managers that send a generic type (application/octet-stream, application/zip) still list Folio: a second intent filter matches the file name, and openViewIntent reads the display name to choose reader or notebook. Share: Folio is also in the share sheet for PDF, EPUB, Word and PowerPoint files (ACTION_SEND, ACTION_SEND_MULTIPLE with EXTRA_STREAM; only these types, never */*), so a file in Telegram, WhatsApp, Gmail or a file manager can be shared to Folio: Word and PowerPoint become notebooks (after the import choice), PDF and EPUB open in the reader, several files import one by one. Telegram’s “open” link (content://org.telegram.messenger.provider/…/Telegram Documents/<name>) carries the file name, so it matches the Open with filters even with a generic type.

The EPUB conversion reads the spine, turns each document into paragraphs (epubParagraphs), wraps them with Android’s StaticLayout and fills pages (paginateChapterLines). The two pure helpers live in shared/commonMain with tests. EPUBs stay readable in the reader, where you can highlight and annotate them.