NewHuxly MCP — Connect Claude, Cursor & Codex.Learn more
How to Generate PDFs in a Mobile App
Back to Blog
GuideNov 1, 20267 min read

How to Generate PDFs in a Mobile App

Contents

A PDF is useful when someone needs a stable copy of a quote, invoice, or report that they can read and share outside your app.

The hard part is making sure the document accurately represents the record at the time it was issued.

A screen capture is rarely enough. A good export includes complete information, sensible page breaks, readable typography, and a clear status. Start with one document type and the record it represents.

Key takeaway:

Generate the PDF from a saved document version, check it before sharing, and preserve issued copies. Test the exported file itself, including totals, long text, and page breaks.

Pick one document to build first

Choose a narrow example, such as a service quote. Define its fields: business name and contact details, recipient, quote number, issue and expiry dates, line items, subtotal, tax, total, notes, and acceptance instructions. Decide which fields are optional.

A PDF should not invent missing data. If a tax number or customer address is required for your use case, validate it before the user can generate the final document.

If legal or accounting requirements apply in a particular region, have a qualified reviewer check the final template.

Start with one template and one page size. Adding invoices and inspection reports later is easier when you already have reusable typography, spacing, and file naming conventions.

Choose live rendering or an issued snapshot

If a quote is still a draft, regenerating it from current data is reasonable. Once it has been sent to a client, you may need the exact version they received.

If someone edits a line item after sending, silently replacing the old PDF creates confusion.

A useful record structure has a quote ID, version, status, issued timestamp, totals, and a stored output reference.

When issuing a new version, keep the earlier copy or record enough information to reproduce it. Mark the document clearly as Draft, Issued, Revised, or Void according to your workflow.

Calculate money using precise decimal or integer minor units, and have one authoritative calculation path. The mobile UI and exported document should not each compute tax independently.

Generate on the device or on a server

Choose where to create the file based on how people will use it:

ApproachGood fitWhat to check
On the phoneA simple export the user requests, including offline useRendering, temporary storage, and sharing on each supported device
On the serverIssued copies, stored history, automated email, or high volumeVersion control, access checks, and the official template

For Expo apps, Expo Print supports creating a PDF from HTML on iOS and Android. The generated file is saved in the app's cache, so it needs to be moved or uploaded if users must retrieve it later.

A useful split is to preview a draft on the device and issue the official copy from the server. Keep the template and calculation rules consistent, and test fonts and page breaks on the platforms you ship.

Produce a file you can actually keep

Build the export as a short review-and-save flow:

  1. Load the saved quote version and its calculated totals.
  2. Generate the PDF from that version.
  3. Preview the file so the user can check the recipient, amount, and page layout.
  4. Save the issued copy where authorized users can retrieve it later.
  5. Let the user share that copy or return to it without generating a different version.

Use a filename such as quote-1042-v2.pdf. Show progress and a retry action if uploading the file to protected storage fails. Canceling the share sheet should leave the document available for later review.

Keep these states separate:

StateWhat it confirms
GeneratedThe PDF file was created
SavedThe copy reached its intended storage location
Shared through the device sheetThe user opened the sharing workflow; delivery is not confirmed
Sent or deliveredYour own delivery system confirmed the corresponding event

Choose storage according to sensitivity and how long the copy is needed. A temporary cache is useful during generation; it is not a promise of permanent access. Clear temporary files on an appropriate schedule and keep their contents out of logs.

Design for paper, not just the phone screen

A long item name should wrap without overlapping the price. A line-items table should repeat its column headings when it spans pages, where your renderer supports it. Keep totals and payment instructions together. Leave room for addresses that take several lines.

Use real text, not a flattened image of the whole document, so recipients can search and select it. Choose fonts that include the characters your customers use. Test currency symbols, accented names, and right-to-left text if your audience needs them.

Define what happens when a document has no logo, twenty line items, a long note, or a tall photo. Those cases expose layout faults early.

Keep data and presentation separate

Generate the document from a validated document model, not directly from whatever happens to be visible on a form. A quote export model might contain issuer, recipient, line items with quantities and unit prices, currency, totals, terms, and version metadata.

Normalize dates and numbers before handing them to the template. Escape user-entered text when using HTML so a customer name cannot break the layout. If you embed photos in an inspection report, resize them appropriately and keep the originals separately when necessary.

For multi-tenant apps, validate that the signed-in person can access the document before retrieving data or a stored PDF. An unguessable file URL is not a replacement for access control.

Decide how edits affect the PDF

A common failure: the mobile record says $420 while an old attached PDF says $390.

Make the current version visible in the UI and avoid showing an old document as if it were the latest. A revised quote can link back to its earlier version.

If clients can accept a quote, store the exact version accepted. A signature or approval against "the current quote" is ambiguous if the quote can change afterward. The same rule matters for inspection reports and invoices.

Test content and behavior

Make a short test set: empty optional fields, maximum length fields, zero and many line items, discounts, tax, very large amounts, unusual characters, and a three-page document.

Check totals against the app record. Open the generated file in at least two PDF viewers.

Test on iPhone and Android if you support both. Try no network, little storage space, canceled sharing, interrupted upload, and reopening an issued document after the app restarts. Confirm whether generated files still exist when you expect them to.

Build your PDF workflow with Huxly

Use Huxly to build PDF preview and export around a saved quote version. Specify the line items, totals, draft label, page layout, and how earlier issued copies remain accessible after a revision.

Start building with Huxly with a realistic two-page quote. Open the exported file and check it with someone who would send it to a customer.

FAQ

Should I generate the PDF on the phone or server?

On-device generation suits simple, user-triggered exports. Server generation is useful when you need authoritative versions, automated sending, or consistent templates across platforms.

Can I just use a screenshot?

A screenshot often cuts off content and makes it hard to search or print. A document template produces a more useful file.

How do I keep exported totals correct?

Calculate totals in one authoritative path, store the issued values, and test the PDF against the source record with varied amounts.

Where should PDFs be stored?

Store them according to how long users need access and how sensitive the contents are. An app cache alone is unsuitable for a document you promise to retrieve months later.

Can a PDF include photos and signatures?

Yes. Keep images legible without making the file enormous, and record which document version the signature applies to.

What should happen when a quote changes?

Issue a new version and clearly identify the current one. Preserve or distinguish older PDFs if someone may have already received them.

Keep reading