{-# LANGUAGE ScopedTypeVariables #-} module Application.XournalConvert.Job where import Data.List import Graphics.Xournal.Render.Simple import Graphics.Rendering.Cairo import Data.Xournal.Simple import Text.Xournal.Parse import Text.StringTemplate -- import Text.StringTemplate.Helpers import System.Directory import System.FilePath import System.IO import Paths_xournal_convert render1 :: [(String,String)] -> String -> String render1 attribs tmpl = render . setManyAttrib attribs . newSTMP $ tmpl svgFileName :: String -> Int -> String svgFileName fname_wo_ext pnum = fname_wo_ext ++ "_Page_" ++ show pnum <.> "svg" startJob :: IO () startJob = do putStrLn "job started" startMakeSVG :: FilePath -> Maybe FilePath -> IO () startMakeSVG fname mdest = do xojcontent <- read_xournal fname case mdest of Nothing -> return () Just dest -> setCurrentDirectory dest let (fname_wo_ext,_fname_ext) = splitExtension fname let pages = xoj_pages xojcontent names = map (svgFileName fname_wo_ext) [1..] -- names = map (\x -> fname_wo_ext ++ show x ++ ".svg") [1..] namePages = zip names pages let Dim w h = page_dim (head pages) putStrLn $ " w = " ++ show w putStrLn $ " h = " ++ show h let svgoutfn x = withSVGSurface (fst x) w h (\s -> renderWith s (cairoDrawPage (snd x))) mapM_ svgoutfn namePages makeHtmlJavascriptPage "index.html" $ zip [1..] (map fst namePages) putStrLn "test ended" onePageTemplate :: String onePageTemplate = "
\n\n" onerule :: String onerule = "