Documentation
¶
Overview ¶
Package pdf provides utilities for creating and manipulating PDF documents.
This package includes functions for:
- Converting HTML content to PDF documents
- Extracting plain text from PDF files
- Merging multiple PDF files into a single document
- Splitting a PDF into multiple files based on page ranges
Index ¶
- func ConvertHTMLFileToPDF(inputPath string, outputPath string) error
- func ConvertHTMLToPDF(htmlContent string, outputPath string) error
- func ExtractTextFromPDF(inputPath string) (string, error)
- func MergePDFs(inputFiles []string, outputFile string) error
- func SplitPDF(inputFile string, pageRanges []string, outputDir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertHTMLFileToPDF ¶
ConvertHTMLFileToPDF reads an HTML file at inputPath and converts it to a PDF saved at outputPath. Supports the same HTML elements as ConvertHTMLToPDF.
func ConvertHTMLToPDF ¶
ConvertHTMLToPDF converts an HTML string into a PDF document and saves it to the specified output path.
Supported HTML elements:
- Headings: <h1> through <h6>
- Paragraphs: <p>
- Bold: <b>, <strong>
- Italic: <i>, <em>
- Line breaks: <br>
- Links: <a href="..."> (rendered as underlined text)
- Images: <img src="..."> (local file paths only)
This function does not support CSS stylesheets, JavaScript, or complex HTML layouts such as tables or flexbox.
func ExtractTextFromPDF ¶
ExtractTextFromPDF extracts the plain text content from all pages of a PDF file and returns it as a single string. Pages are separated by a newline.
func MergePDFs ¶
MergePDFs combines multiple PDF files into a single output document. The pages from each input file are appended in the order provided. At least two input files must be specified.
func SplitPDF ¶
SplitPDF splits a PDF file into multiple smaller PDF files based on the specified page ranges. Each range produces a separate output PDF.
Page ranges are specified as strings such as "1-3", "5", or "7-10". Output files are saved in the specified directory with names like "pages_1-3.pdf", "pages_5-5.pdf", etc.
Types ¶
This section is empty.