DocumentGitHub

PDTPortableocumentransferrotocolAnimated Squares

PortableDocumentTransferProtocol (PDTP) enables fast and reliable PDF viewing in congested networks by splitting content into text, images, and fonts for efficient transfer.

  • Stable Viewing in Congested Networks

    PDF files can be viewed smoothly and reliably even in congested network environments.

  • Content Splitting Transfer

    Splits PDFs into components such as text, low-resolution images, font data, and high-resolution images, and transfers the necessary data efficiently.

  • Optimized Data Transmission

    Reduces overall data transmission by transferring only necessary parts, enabling comfortable use even in mobile environments.

Installation

Web Client

Install the package via npm:

npm install @pdtp/core

API Server with Golang

Install the package via go get:

go get github.com/pdtp-workbench/pdtp-go

Usage

Web Client

Usage of the package is simple. Just import the package and use it as shown below:

import { PdtpProvider, PdtpRenderer } from "@pdtp/react";

const App = () => {
  return (
    <PdtpProvider
      options={{
        file: "example.pdf",
        base: 1,
        start: 1,
        end: 5,
      }}
    >
      <PdtpRenderer />
    </PdtpProvider>
  );
};

export default App;

API Server with Golang

Usage of the package is simple. Just import the package and use it as shown below:


package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/pdtp-workbench/pdtp-go"
)


func main() {
	http.HandleFunc("/pdtp", pdtp.NewPDFProtocolHandler(
		pdtp.Config{
			HandleOpenPDF: func(fileName string) (pdtp.IPDFFile, error) {
				file, err := os.Open(fileName)
				return file, err
			},
			CompressionMethod: pdtp.ZstdCompression{},
		},
	))

	fmt.Println("PDF Protocol Server listening on http://localhost:8080")
  log.Fatal(http.ListenAndServe(":8080", nil))
}