Documentation
¶
Index ¶
- Constants
- func RestoreMuPDFWarnings()
- func SuppressMuPDFWarnings()
- type PDFMetadata
- type PDFService
- func (s *PDFService) ClosePDF() error
- func (s *PDFService) GenerateThumbnail(filePath string, maxWidth int) (string, error)
- func (s *PDFService) GetMetadata() (*PDFMetadata, error)
- func (s *PDFService) GetPageCount() int
- func (s *PDFService) GetPageDimensions(pageNum int) (*PageDimensions, error)
- func (s *PDFService) OpenPDF() (*PDFMetadata, error)
- func (s *PDFService) OpenPDFByPath(filePath string) (*PDFMetadata, error)
- func (s *PDFService) RenderPage(pageNum int, dpi float64) (*PageInfo, error)
- func (s *PDFService) Startup(ctx context.Context)
- type PageDimensions
- type PageInfo
- type RecentFile
- type RecentFilesService
- func (s *RecentFilesService) AddRecent(filePath string, pageCount int) error
- func (s *RecentFilesService) ClearRecent() error
- func (s *RecentFilesService) GetRecent() []RecentFile
- func (s *RecentFilesService) RemoveRecent(filePath string) error
- func (s *RecentFilesService) Shutdown(timeout time.Duration) error
- func (s *RecentFilesService) Startup(ctx context.Context)
Constants ¶
const ( MinDPI = 10.0 MaxDPI = 600.0 PDFOpenTimeout = 120 * time.Second PDFRenderTimeout = 300 * time.Second MaxPDFFileSizeBytes = 1 * 1024 * 1024 * 1024 // 1GB maximum file size )
const (
DefaultMaxRecentFiles = 20
)
Variables ¶
This section is empty.
Functions ¶
func RestoreMuPDFWarnings ¶
func RestoreMuPDFWarnings()
RestoreMuPDFWarnings restores MuPDF warnings output
func SuppressMuPDFWarnings ¶
func SuppressMuPDFWarnings()
SuppressMuPDFWarnings redirects MuPDF warnings to /dev/null
Types ¶
type PDFMetadata ¶
type PDFMetadata struct {
Title string `json:"title"`
Author string `json:"author"`
Subject string `json:"subject"`
Creator string `json:"creator"`
PageCount int `json:"pageCount"`
FilePath string `json:"filePath"`
}
PDFMetadata contains metadata extracted from a PDF document.
type PDFService ¶
type PDFService struct {
// contains filtered or unexported fields
}
PDFService handles all PDF operations including opening, rendering, and metadata extraction. It uses go-fitz for PDF rendering and maintains thread-safe access to the current document.
func NewPDFService ¶
func NewPDFService(configService *config.Service) *PDFService
NewPDFService creates a new PDF service instance.
func (*PDFService) ClosePDF ¶
func (s *PDFService) ClosePDF() error
ClosePDF closes the currently open PDF document and releases resources.
func (*PDFService) GenerateThumbnail ¶
func (s *PDFService) GenerateThumbnail(filePath string, maxWidth int) (string, error)
GenerateThumbnail generates a 16:9 cropped thumbnail of the first page as base64 PNG.
func (*PDFService) GetMetadata ¶
func (s *PDFService) GetMetadata() (*PDFMetadata, error)
GetMetadata returns title, author, and other metadata for the open PDF.
func (*PDFService) GetPageCount ¶
func (s *PDFService) GetPageCount() int
GetPageCount returns the total number of pages in the open PDF.
func (*PDFService) GetPageDimensions ¶
func (s *PDFService) GetPageDimensions(pageNum int) (*PageDimensions, error)
GetPageDimensions returns the width and height of a page in PDF points.
func (*PDFService) OpenPDF ¶
func (s *PDFService) OpenPDF() (*PDFMetadata, error)
OpenPDF shows a file dialog, opens the selected PDF, and returns its metadata.
func (*PDFService) OpenPDFByPath ¶
func (s *PDFService) OpenPDFByPath(filePath string) (*PDFMetadata, error)
OpenPDFByPath opens a PDF file from the given path and returns its metadata.
func (*PDFService) RenderPage ¶
func (s *PDFService) RenderPage(pageNum int, dpi float64) (*PageInfo, error)
RenderPage renders the specified page at the given DPI and returns base64-encoded PNG data.
func (*PDFService) Startup ¶
func (s *PDFService) Startup(ctx context.Context)
Startup stores the app context and configures MuPDF. Called by Wails on app start.
type PageDimensions ¶
PageDimensions represents the dimensions of a PDF page
type PageInfo ¶
type PageInfo struct {
PageNumber int `json:"pageNumber"`
Width int `json:"width"`
Height int `json:"height"`
ImageData string `json:"imageData"` // Base64 encoded PNG
}
PageInfo contains information about a rendered PDF page including dimensions and image data.
type RecentFile ¶
type RecentFile struct {
FilePath string `json:"filePath"`
FileName string `json:"fileName"`
LastOpened time.Time `json:"lastOpened"`
PageCount int `json:"pageCount"`
}
RecentFile represents a recently opened PDF file
type RecentFilesService ¶
type RecentFilesService struct {
// contains filtered or unexported fields
}
RecentFilesService tracks recently opened PDF files with persistence.
func NewRecentFilesService ¶
func NewRecentFilesService() *RecentFilesService
NewRecentFilesService creates a new recent files service
func (*RecentFilesService) AddRecent ¶
func (s *RecentFilesService) AddRecent(filePath string, pageCount int) error
AddRecent adds or moves a file to the top of the recent files list.
func (*RecentFilesService) ClearRecent ¶
func (s *RecentFilesService) ClearRecent() error
ClearRecent removes all entries from the recent files list.
func (*RecentFilesService) GetRecent ¶
func (s *RecentFilesService) GetRecent() []RecentFile
GetRecent returns recent files, automatically removing entries for deleted files.
func (*RecentFilesService) RemoveRecent ¶
func (s *RecentFilesService) RemoveRecent(filePath string) error
RemoveRecent removes a specific file from the recent files list.
func (*RecentFilesService) Shutdown ¶
func (s *RecentFilesService) Shutdown(timeout time.Duration) error
Shutdown waits for pending saves to complete with the given timeout.
func (*RecentFilesService) Startup ¶
func (s *RecentFilesService) Startup(ctx context.Context)
Startup loads persisted recent files. Called by Wails on app start.