Difference between revisions of "Cookbook/PDF files"
< Cookbook
Jump to navigation
Jump to search
Line 13: | Line 13: | ||
main = do |
main = do |
||
let outputFileName= "test1.pdf" |
let outputFileName= "test1.pdf" |
||
⚫ | |||
let documentInfo = standardDocInfo |
let documentInfo = standardDocInfo |
||
⚫ | |||
runPdf outputFileName documentInfo defaultPageSize $ do |
runPdf outputFileName documentInfo defaultPageSize $ do |
||
Line 32: | Line 32: | ||
main = do |
main = do |
||
let outputFileName= "test2.pdf" |
let outputFileName= "test2.pdf" |
||
⚫ | |||
let documentInfo = standardDocInfo |
let documentInfo = standardDocInfo |
||
⚫ | |||
runPdf outputFileName documentInfo defaultPageSize $ do |
runPdf outputFileName documentInfo defaultPageSize $ do |
Revision as of 14:48, 23 April 2009
For the following recipes you need to install HPDF.
Creating an empty PDF file
runPdf generates a PDF file in the file system.
Let's create an empty PDF file with the name "test1.pdf":
import Graphics.PDF
main :: IO ()
main = do
let outputFileName= "test1.pdf"
let documentInfo = standardDocInfo
let defaultPageSize = PDFRect 0 0 200 300
runPdf outputFileName documentInfo defaultPageSize $ do
addPage Nothing
Pages with different sizes
If you pass "Nothing" to the function addPage, the default page size will be used for the size of the new page.
Let’s create three pages, the last two pages with different dimensions:
import Graphics.PDF
main :: IO ()
main = do
let outputFileName= "test2.pdf"
let documentInfo = standardDocInfo
let defaultPageSize = PDFRect 0 0 200 300
runPdf outputFileName documentInfo defaultPageSize $ do
addPage Nothing
addPage $ Just $ PDFRect 0 0 100 100
addPage $ Just $ PDFRect 0 0 150 150