PDF Widget
OverviewDirect link to Overview
The PDF widget allows you to display PDF documents directly in your interface. It renders PDFs using an iframe, and shows a placeholder when no source is provided (see Error Handling for the cases where a PDF cannot be loaded).

Configuration OptionsDirect link to Configuration Options
Global ConfigurationDirect link to Global Configuration
Basic SettingsDirect link to Basic Settings
Name
- Field: Widget name identifier
- Usage: Set a descriptive name for easy identification in the interface
- Example: "Contract Document", "User Manual"
Variable/Model
- Field: Model binding for dynamic PDF sources
- Usage: Bind to a variable that contains the PDF URL, on the same domain as the application
- Format: Variable name (e.g.,
documentUrl,pdfSource) - Dynamic: Can be updated programmatically to change the displayed PDF
Default Value
- Field: Source of the PDF (the empty field shows PDF link)
- Usage: Set the PDF to display while the Variable/Model is empty
- Plain URL: A URL on the same domain as the application, usually relative, used as written. It becomes the initial value of the variable when the page opens
- Dynamic source: A URL that holds
${…}expressions, computed from the variables of the page (see Dynamic Source) - Examples:
/uploads/<file id>/name/document.pdf/uploads/${#fiche.fichier}/name/document.pdf(dynamic source)

URL on the Same DomainDirect link to URL on the Same Domain
The reader expects a URL on the same domain as the application, usually a relative link such as /uploads/<file id>/name/document.pdf. After each load it reads the page received in its frame, and the browser forbids this for another domain. The CORS settings of the other server change nothing.
With a URL on another domain (https://…):
- In a plain Default Value: The reader reloads the document without end, as fast as the server answers
- In the variable, with no Default Value: The document is loaded, then hidden: the reader shows No PDF to read
- In the variable, with a Default Value: The reader replaces it with the Default Value
- In a dynamic source: The document is displayed, but a hidden frame of the reader requests it without end
To display a document stored elsewhere, upload it to Files and use its /uploads/… link.
Dynamic SourceDirect link to Dynamic Source
Since 8.6, the Default Value can hold ${…} expressions computed from the variables of the page. Before 8.6, such a source was a JavaScript error and the whole reader was missing from the page.
/uploads/${#fiche.fichier}/name/document.pdf
The reader opens the URL with the value of fiche.fichier and follows the variable: when the value changes, it opens the new document.
- What to write in
${…}: A page variable with#(#fiche.fichier) or a JavaScript expression without braces, for example with the connected user (SF_connectedUser._id). The{{…}}notation is not read in this field. - In a loop:
${#fichier}reads the row only if a widget of the loop has the modelfichier:/uploads/${#fichier}/name/document.pdfthen gives each row its own document. Otherwise it reads the page variablefichier, the same for all the rows. In a loop fed by data, with no widget for this field, write${SF_currentRow.fichier}. - The text around the expressions: It is kept as written.
#page=2is not a variable:/uploads/${#fiche.fichier}/name/document.pdf#page=2opens the document at page 2. - A missing value: An expression with no value, or one that fails, gives an empty text and the rest of the URL is kept (
/uploads//name/document.pdf). The server answers 404 and the reader shows this answer,{"error":"Not Found"}, not the placeholder. To show No PDF to read until the value is known, leave the Default Value empty and put the whole URL in the Variable/Model, for example with an action. A source limited to${#lienPdf}also starts on No PDF to read, but stays on it when the value arrives after the page has loaded. - An invalid expression: An expression that is not valid JavaScript (
${#fiche fichier}) stays as text in the URL. The page still opens, and the browser console lists it after SoftyFlow: parts of this page are ignored because they are not valid. - An expression with braces: A valid expression that holds
{or}(an object, a function with a block, for example${#a ? {x:1}.x : 2}) also stays as text in the URL, with no message in the console.
A dynamic source is displayed as long as the Variable/Model is empty, and the computed URL is not written into the variable. A plain URL, on the contrary, is copied into the variable when the page opens.
Several Readers and LoopsDirect link to Several Readers and Loops
Since 8.6, each PDF reader has its own frames, so several readers work on the same page and each row of a loop shows its own document.
A reader has up to two frames, each with its own id:
pdf-frame-<widget id>: The frame of the variable. A plain Default Value is copied into the variable, so this frame shows it toopdf-source-<widget id>: The frame shown while the variable is empty: that of a dynamic source, or of a plain Default Value once the variable has been emptied
While pdf-source-<widget id> is shown, pdf-frame-<widget id> stays in the page, hidden, and also loads the URL once: the document is downloaded twice, and the src of this frame holds this first URL although the variable is empty. To know which document is displayed, read pdf-source-<widget id> first when it exists; to know the value, read the variable and not the frame.
From the second row of a loop, the row number is added (pdf-frame-<widget id>_1), and every row carries data-sf-id="pdf-frame-<widget id>". Page code that reads the former fixed id pdf-frame must use these ids.
Content BehaviorDirect link to Content Behavior
The widget follows this priority order for PDF sources:
- Variable/Model value: If the variable has a value, it takes precedence
- Default Value: A plain URL or a dynamic source, used while the variable is empty
- Placeholder: Shows the No PDF to read message when neither source is available. No request is sent: before 8.6, the reader asked for the URL
undefined, which ended in a 403 error on every page holding a PDF reader with no source
A URL that fails can change this order: see Error Handling.

Validation ConfigurationDirect link to Validation Configuration
Screen-Based VisibilityDirect link to Screen-Based Visibility
The Validation card has one row per screen. A screen is a step of the page (for example Création, Correction or Validation manager), not a screen size or a device: see Managing Page Views with Screens.
Available
- Purpose: Controls whether the widget exists on the screen
- Options: Toggle on/off per screen
- Use Case: Leave the reader out of a step where the document does not exist yet, for example Création
Visible
- Purpose: Dynamic visibility based on conditions
- Options:
- Boolean toggle for simple show/hide
- Advanced conditions using JavaScript expressions
- Examples:
{{user.role}} === 'admin'- Only show for admin users{{documentType}} === 'contract'- Show only for contract documents
Required and Disable
These two switches have no effect at runtime on the PDF reader: it adds no rule to the form, and it stays usable whatever their value.

Style ConfigurationDirect link to Style Configuration
DimensionsDirect link to Dimensions
Width
- Field: Widget width in pixels
- Format: A number, without unit
- Example:
800 - Default:
0, which gives 100% (full container width)
Height
- Field: Widget height in pixels
- Format: A number, without unit
- Example:
600 - Default:
0, which gives 100% (full container height)
CSS StylingDirect link to CSS Styling
Class Names
- Field: Custom CSS classes for styling
- Format: Space-separated class names
- Examples:
pdf-viewer,document-container bordered - Usage: Apply custom styling or integrate with design systems
Dynamic Classes
The brush button (Dynamic classes) next to Class has no effect on a PDF reader: only the Class field is applied.

Advanced ConfigurationDirect link to Advanced Configuration
Error HandlingDirect link to Error Handling
Each time the frame pdf-frame-<widget id> finishes loading, the reader reads the text of the page it received. It does not know the HTTP code: only this text counts.
| What the frame received | With no Default Value | With a Default Value |
|---|---|---|
An empty page, a page that holds Error 403, Cannot GET, Page Not Found! or Argument passed in must be a single String of 12 bytes or a string of 24 hex characters, a page on another domain, or an address that cannot be reached | The frame is hidden and No PDF to read appears | The frame reloads the Default Value |
| Anything else, including a JSON error | Displayed as received | Displayed as received |
- A missing or refused file: The
/uploadsroute answers with a JSON error, which the reader shows in its frame as it is:{"err":"no files exist"}for a file that does not exist,{"error":"Not Found"}for an empty id (/uploads//name/document.pdf), a 401 answer holdingNot logged infor a private file without a session. There is no placeholder, and the Default Value does not take over. - A variable in error: With a Default Value, the reader displays the Default Value in place of the URL of the variable. The variable keeps its value.
- A Default Value in error: The reader reloads it without end, and the placeholder never appears.
- A dynamic source: The frame shown,
pdf-source-<widget id>, is not checked: it displays whatever the URL answers. The check runs on the hidden framepdf-frame-<widget id>, which reloads the source without end when the answer fails the check.
Loading StatesDirect link to Loading States
Initial Load
- With a URL, the frame appears at once: there is no loading indicator, the viewer of the browser takes over
- With no source and an empty variable, the placeholder appears and no request is sent
When the Source Changes
- A new value of the variable, or of a variable read by the dynamic source, opens the new URL
- The placeholder disappears as soon as the variable receives a document that passes the check
Use CasesDirect link to Use Cases
Document ViewerDirect link to Document Viewer
- Display contracts, manuals, or reports
- Provide in-app document review capabilities
- Eliminate need for external PDF applications
Form IntegrationDirect link to Form Integration
- Show terms and conditions during registration
- Display reference documents alongside form fields
- Preview generated documents before submission
Content ManagementDirect link to Content Management
- Browse document libraries
- Preview files before download
- Display documentation with contextual relevance
Educational ContentDirect link to Educational Content
- Show lesson materials or worksheets
- Display reference guides and tutorials
- Provide interactive learning resources
Best PracticesDirect link to Best Practices
Performance OptimizationDirect link to Performance Optimization
- Use appropriate dimensions: Don't make PDFs unnecessarily large
- Implement lazy loading: Use visibility conditions to load PDFs only when needed
- Optimize PDF files: Ensure source PDFs are web-optimized
- Consider mobile experience: PDFs may not display well on small screens
User ExperienceDirect link to User Experience
- Provide loading indicators: Users should know when content is loading
- Handle errors gracefully: Show meaningful messages for failed loads
- Ensure accessibility: Consider users who may need alternative document formats
- Test across browsers: PDF rendering may vary between browsers
Security ConsiderationsDirect link to Security Considerations
- Validate PDF sources: Ensure URLs point to legitimate PDF files
- Use HTTPS: Secure connections for PDF content
- Access control: Implement proper authentication for sensitive documents
- Content validation: Verify PDF content is appropriate and safe
TroubleshootingDirect link to Troubleshooting
Common IssuesDirect link to Common Issues
PDF not displaying
- Verify the source URL is accessible
- With a dynamic source, check the value of the variables and look for the expression in the browser console
- Use a URL on the same domain as the application: the CORS settings of another server change nothing
- If the reader shows a JSON text (
{"err":"no files exist"},{"error":"Not Found"}), the file does not exist or its id is empty: see Error Handling - Ensure the file is a valid PDF format
Layout problems
- Adjust width and height settings
- Check parent container CSS constraints
- Test responsive behavior across screen sizes
Performance issues
- Optimize PDF file sizes
- Implement conditional loading
- Consider pagination for large documents
Browser compatibility
- Test PDF rendering across different browsers
- Provide fallback options for unsupported browsers
- Consider using PDF.js for consistent rendering
Browser SupportDirect link to Browser Support
The PDF widget relies on browser native PDF support or plugins:
- Chrome/Edge: Native PDF viewer
- Firefox: Built-in PDF.js renderer
- Safari: Native PDF support
- Mobile browsers: May require external PDF apps
For guaranteed cross-browser compatibility, consider implementing PDF.js as a fallback renderer.