Created
May 1, 2014 12:48
-
-
Save reite/33c9527daf8088ebb0bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System.Process | |
import GHC.IO.Handle | |
import Text.Blaze.Html (Html) | |
import Text.Blaze.Html.Renderer.Utf8 (renderHtml) | |
import qualified Data.ByteString as B | |
import qualified Data.ByteString.Lazy as BL | |
convertHtml :: Html -> IO B.ByteString | |
convertHtml html = do | |
(Just stdin, Just stdout, _, _) <- createProcess $ | |
(wkhtmltopdf ["-", "-"]) { std_out = CreatePipe | |
, std_in = CreatePipe | |
} | |
BL.hPutStr stdin (renderHtml html) >> hClose stdin | |
B.hGetContents stdout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment