packages feed

line2pdf-0.0.4: line2pdf.hs

module Main where
import System.Exit
import System.Environment
import Text.LineToPDF
import qualified Data.ByteString.Lazy.Char8 as L

main :: IO ()
main = do
    args <- getArgs

    (lang, input) <- case args of
        []      -> do
            putStrLn "Usage: line2pdf [-big5|-gbk|-euc-jp|-euc-kr] input.txt > output.pdf"
            putStrLn "  (Form feed (^L) in input denotes a pagebreak.)"
            exitWith ExitSuccess
        ("-big5":i:_)   -> return (TraditionalChinese, i)
        ("-gbk":i:_)    -> return (SimplifiedChinese, i)
        ("-euc-jp":i:_) -> return (Japanese, i)
        ("-euc-kr":i:_) -> return (Korean, i)
        (i:_)           -> return (Latin, i)

    src <- L.readFile input
    lineToPDF $ defaultConfig lang src