β‘ High-performance multi-backend document rendering (PDFium / PDFBox / WebView2), source code syntax rendering, zero-copy pixel buffers, and .previewbin binary cache for Java.
FastPreview replaces slow and heavy Swing/JavaFX preview components. It renders PDFs, Markdown, HTML, source code, and screenshots directly into GPU-friendly FastImage ARGB buffers with native speed and sub-millisecond .previewbin streaming.
import fastpreview.api.*;
import java.io.File;
import java.util.List;
public class Demo {
public static void main(String[] args) {
// 1. Initialize FastPreview engine
FastPreview engine = new FastPreview();
// 2. Render document preview
File doc = new File("C:\\Docs\\architecture.pdf");
PreviewRequest request = new PreviewRequest(doc, 1920, 1080);
PreviewResult result = engine.render(request);
if (result.isSuccess()) {
System.out.printf("Rendered preview in %d ms via %s\n",
result.getRenderTimeMs(), result.getBackendUsed());
}
// 3. Compact FastFileFormat Binary Metadata Cache (.previewbin)
PreviewRecord record = new PreviewRecord(
doc.getAbsolutePath(), result.getRenderTimeMs(), 1920, 1080,
result.getBackendUsed() != null ? result.getBackendUsed().name() : "NATIVE",
result.isSuccess()
);
byte[] binary = PreviewCodec.encode(List.of(record));
List<PreviewRecord> restored = PreviewCodec.decode(binary);
}
}- π Multi-Engine Document Rendering β Hybrid PDF rendering supporting both native PDFium and Apache PDFBox 3.0.
- π» Syntax & Markup Previews β Ultra-fast rendering of Markdown, HTML, and Java/C/Rust source code files.
- β‘ Zero-Copy FastImage Output β Direct pixel buffer rasterization ready for DirectX, Vulkan, and Swing integration.
- π¦ FastFileFormat
.previewbinCache β Compact VarInt binary serialization for preview metadata caches (Payload ID0x0009).
- π Enterprise Document Portals β Generating instantaneous high-resolution previews for large document repositories.
- π» IDEs & Code Browsers β High-speed file previews and multi-language syntax previews without spinning up full editor instances.
- π File Explorers β Fast content preview panes for PDFs, SVGs, HTML, and markdown documents.
FastPreview is profiled using JMH to guarantee zero bottleneck during high-concurrency document rendering.
| Benchmark Operation | Score (ops/ms) | Throughput | Memory Overhead |
|---|---|---|---|
Binary Preview Cache Decoding (.previewbin) |
~162,000 ops/ms | > 162 Million records/sec | Zero-Copy Streaming |
Binary Preview Cache Encoding (.previewbin) |
~36,500 ops/ms | > 36.5 Million records/sec | Compact VarInt Delta Buffer |
Run the benchmarks locally: .\run-benchmark.bat
| Method / Class | Description |
|---|---|
new FastPreview() |
Initializes core document rendering engine. |
engine.render(request) |
Renders document to ARGB pixel buffer using default backend. |
engine.render(request, backend) |
Renders document with specified backend (PDFBOX, NATIVE). |
PreviewCodec.encode(records) |
Serializes preview metadata records into compressed FastFileFormat bytes. |
PreviewCodec.decode(bytes) |
Deserializes .previewbin bytes back into List<PreviewRecord>. |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Live Document Preview Demo | Demo.java | run-demo.bat |
Multi-format rendering and .previewbin binary cache serialization. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
High-throughput binary codec serialization and streaming benchmarks. |
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastPreview</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastTokenize</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastThumb</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastImage</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastFileFormat</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastPreview:0.1.1'
implementation 'com.github.andrestubbe:FastTokenize:0.1.0'
implementation 'com.github.andrestubbe:FastThumb:0.1.0'
implementation 'com.github.andrestubbe:FastImage:0.1.1'
implementation 'com.github.andrestubbe:FastFileFormat:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- π FastPreview-0.1.1.jar (Document Preview Engine)
- β‘ FastTokenize-0.1.0.jar (Zero-Copy Syntax Scanner)
- πΌοΈ FastThumb-0.1.0.jar (Shell Thumbnail Extractor)
- π¨ FastImage-0.1.1.jar (Zero-Copy Image Manipulation)
- π FastFileFormat-0.1.0.jar (Dual Binary & Text File Format)
- βοΈ FastCore-0.1.0.jar (Foundation Library)
- REFERENCE.md: Full API reference and method signatures.
- PHILOSOPHY.md: Architectural design principles and rendering pipeline.
- CHANGELOG.md: Release history and version notes.
- ROADMAP.md: Future milestones and planned features.
- COMPILE.md: Instructions for compiling from source.
MIT License. See LICENSE file for details.
- FastThumb β Native Windows Shell thumbnail & icon extractor
- FastImage β SIMD-accelerated image scaling and pixel buffers
- FastFileFormat β Universal dual-format binary & text document engine
Part of the FastJava Ecosystem β Making the JVM faster. Small package. Maximum speed. Zero bloat. ππ