K.FluentPdf Designer for Visual Studio
The Visual Studio extension supports both visual .kfpdf editing and code-first preview of existing
C# documents. You can preview a document made entirely in code without creating a design file.
Requirements
- Visual Studio 2022 17.14 or later, or Visual Studio 2026, x64 or Arm64.
- The .NET 10 runtime for the separate preview process.
- The
K.FluentPdf NuGet package in projects that compile generated documents.
Open or create a design
- Open an existing
.kfpdf file. It opens in the Designer by default.
- In Solution Explorer, right-click a project or folder and choose Add > K.FluentPdf Design....
- Or choose Add > New Item > K.FluentPdf Design.
The designer writes a .kfpdf JSON design. To inspect or repair the JSON directly, use Open With >
Source Code (Text) Editor.
Workspace
- Toolbox: search supported components, grouped under Basic Elements, Layout, Tables, and Advanced.
Click a component to insert it at the current selection, or drag it onto the page or document outline.
- Data: search available fields and drag a field into text or a table. Build the project and refresh
fields to inspect the real data type.
- Outline: navigate the page hierarchy. Search selects matching elements; press Enter to cycle
through matches. The selected element is shared with the page and Properties panel.
- Page: select an element with a click. Double-click text or a table cell to edit it; Enter commits,
Shift+Enter adds a line, and Escape cancels.
- Properties: edit the selected object. The inspector groups settings into content, typography,
layout, spacing, borders/background, and component-specific sections. Color swatches and file pickers
are available for supported properties.
Panel widths can be adjusted with the splitters between the toolbox, page, and Properties panel. The
toolbox tabs keep components, data fields, and outline separate while leaving more space for the page.
Place and edit components
In normal flow mode, drop feedback shows where the item will be inserted. Supported containers accept
children; invalid parent/child combinations are rejected. Drag outline entries to reorder items. Use
Duplicate, Move up, Move down, and Delete on the toolbar or the outline context menu.
Turn on Free placement to place a dropped component at the pointer position. Existing free-area
and overlay elements can be dragged to update their coordinates. Free areas remain in the document
flow and contain positioned children; overlays sit above the page content. This does not turn ordinary
flow elements into absolute-positioned elements.
Table commands are available when a table is selected: add or remove rows and columns, add header rows,
merge cells, unmerge cells, and toggle a diagonal cell border.
The Toolbox contains the following supported design elements:
| Category |
Element |
What it adds |
| Basic Elements |
Text |
A paragraph of static or bound text. |
| Basic Elements |
Heading |
Large, bold text. |
| Basic Elements |
Image |
An image from a file or embedded in the design. |
| Basic Elements |
Line |
A horizontal rule. |
| Basic Elements |
Spacer |
Vertical blank space. |
| Basic Elements |
Page number |
Current page and total page count. |
| Layout |
Column |
Stacks child elements vertically. |
| Layout |
Row |
Places child elements side by side. |
| Layout |
Box |
Wraps one child with padding, border, rounded corners, or background. |
| Layout |
Free area |
Holds elements positioned at exact coordinates within an area. |
| Layout |
Page break |
Continues content on a new page. |
| Tables |
Table |
A grid of rows and columns; supports headers, cell merging, and diagonal cells. |
| Advanced |
Data field |
Text bound to a data value, such as {{Customer.Name}}. |
Use Ctrl+Z and Ctrl+Y to undo and redo. Ctrl+S saves the design.
Preview and data
Choose Design to edit or Preview to see the rendered pages without selection adorners. Use the
zoom list for a fixed zoom, Fit page, or Fit width. The page controls navigate multi-page output.
Refresh renders the design again; errors appear in the preview area and the last successful render
remains available.
Sample data is for preview only. With it enabled, fields are simulated from their names and types;
collections get representative rows. New sample changes the sample. To use your actual data shape:
- Set Data > TypeName on the design to a fully qualified class name, such as
MyApp.Invoice.
- Build the project.
- Open the Data tab and refresh fields.
The preview creates a sample instance of that class without calling your application's API or database.
For fixed preview values, place <design-name>.sample.json next to the design or set Data > SampleFile.
Sample data never replaces data in your application.
Save, generate C#, and export
Saving writes the .kfpdf file and, when Code generation > GenerateOnSave is enabled, a sibling
.g.cs file. Do not edit the generated file; save or use Generate C# to recreate it. In an SDK-style
project it is compiled automatically. Add the package if needed:
dotnet add package K.FluentPdf --prerelease
Use Export PDF to render the design to a PDF file. Relative image and font paths resolve relative
to the design when code is generated; set the assets to copy to the application's output folder or
embed images in the design.
Preview a document written directly in C#
This workflow is independent of .kfpdf designs and generated .g.cs files. Open the C# source,
place the caret inside a method that returns a FluentPdf Document, then right-click and choose
Preview K.FluentPdf Document. You can also open View > Other Windows > K.FluentPdf Preview.
The extension builds the project and runs the selected document method in its separate preview process.
Methods that need arguments receive simulated sample objects; alternatively, use a parameterless method
that constructs the sample data you want to inspect. The preview renders the document returned by your
existing code.
Troubleshooting
- Preview host not found or fails to start: install the .NET 10 runtime and reopen the design.
- Typed fields are missing: set the fully qualified
TypeName, build the project, and refresh the
Data tab.
- An image fails to load: confirm its path is relative to the design or embed it, and verify the
file contains supported, complete image data.
- Generated output differs from preview: check the design's sample values and the application's
image/font paths. Preview uses sample data unless configured otherwise.
- Design does not open: the
.kfpdf file must contain valid JSON. Open it with the text editor to
inspect an invalid or empty file.