Skip to content

Latest commit

Β 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FastPreview 0.1.1 [ALPHA] β€” Native Document, PDF & Code Rendering Engine

Status License: MIT Java Platform JitPack


⚑ 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.


Quick Start

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);
    }
}

Key Features

  • πŸ“„ 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 .previewbin Cache β€” Compact VarInt binary serialization for preview metadata caches (Payload ID 0x0009).

Real-World Scenarios

  • πŸ“‘ 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.

Performance Benchmarks

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


API Quick Reference

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>.

Technical Examples & Hero Demos

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.

Installation

Option 1: Maven (JitPack)

<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>

Option 2: Gradle (via JitPack)

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'
}

Option 3: Direct Download (No Build Tool)

Download the latest JARs directly to add them to your classpath:

  1. πŸ“„ FastPreview-0.1.1.jar (Document Preview Engine)
  2. ⚑ FastTokenize-0.1.0.jar (Zero-Copy Syntax Scanner)
  3. πŸ–ΌοΈ FastThumb-0.1.0.jar (Shell Thumbnail Extractor)
  4. 🎨 FastImage-0.1.1.jar (Zero-Copy Image Manipulation)
  5. πŸ“„ FastFileFormat-0.1.0.jar (Dual Binary & Text File Format)
  6. βš™οΈ FastCore-0.1.0.jar (Foundation Library)

Documentation


License

MIT License. See LICENSE file for details.


Related Projects

  • 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. πŸš€πŸ“‹

About

πŸ“„ High-performance document, PDF, and source code rendering engine for Java.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages