1#!/bin/sh 2# $Id: starter_pdfa.tcl,v 1.1.2.1 2008/03/13 11:44:43 rjs Exp $ 3# 4# Hide the exec to Tcl but not to the shell by appending a backslash\ 5exec tclsh "$0" ${1+"$@"} 6 7# PDF/A starter: 8# Create PDF/A-compliant output 9# 10# required software: PDFlib/PDFlib+PDI/PPS 7 11# required data: font file, image file 12# 13# The lappend line is unnecessary if PDFlib has been installed 14# in the Tcl package directory 15set auto_path [linsert $auto_path 0 .libs .] 16 17package require pdflib 7.0 18 19 20# This is where the data files are. Adjust as necessary. 21set searchpath "../data" 22set imagefile "nesrin.jpg" 23set outfilename "starter_pdfa.pdf" 24 25set p [PDF_new] 26 27if { [catch { 28 PDF_set_parameter $p "SearchPath" $searchpath 29 30 # PDF/A-1a requires Tagged PDF 31 if {[PDF_begin_document $p $outfilename "pdfa=PDF/A-1b:2005"] == -1} { 32 puts stderr "Error: [PDF_get_errmsg $p]" 33 exit 34 } 35 36 # We use sRGB as output intent since it allows the color 37 # spaces, CIELab, ICC-based, grayscale and RGB. 38 # 39 # If you need CMYK color you must use a CMYK output profile. 40 41 PDF_load_iccprofile $p "sRGB" "usage=outputintent" 42 43 PDF_set_info $p "Creator" "PDFlib starter sample" 44 PDF_set_info $p "Title" "starter_pdfa" 45 46 PDF_begin_page_ext $p 595 842 "" 47 48 # $font embedding is required for PDF/A 49 set font [PDF_load_font $p "LuciduxSans-Oblique" "unicode" "embedding"] 50 if {$font == -1} { 51 puts stderr "Error: [PDF_get_errmsg $p]" 52 exit 53 } 54 PDF_setfont $p $font 24 55 56 PDF_fit_textline $p "PDF/A-1b:2005 starter" 50 700 "" 57 58 # We can use an RGB $image since we already supplied an 59 # output intent profile. 60 61 set image [PDF_load_image $p "auto" $imagefile ""] 62 if {$image == -1} { 63 puts stderr "Error: [PDF_get_errmsg $p]" 64 exit 65 } 66 67 # Place the $image at the bottom of the page 68 PDF_fit_image $p $image 0.0 0.0 "scale=0.5" 69 70 PDF_end_page_ext $p "" 71 72 PDF_end_document $p "" 73 74} result] } { 75 puts stderr "$result" 76} 77 78# delete the PDFlib object 79PDF_delete $p 80