johnnyv Posted October 8, 2002 Report Share Posted October 8, 2002 unsure if this should go under software or whatever but here goes. I can use fpdf www.fpdf.org to make pdf files using php. I need the pdf's for printing as html is not suitable for printing. i want to pipe generated pdfs through the pdf2ps program to generate ps files and send them directly to a printer eg is there a single command to convert a pdf to a ps file and then print it on the default or specified printer? eg) pdf2ps invoice.pdf invoice.ps - something to make it print the invoice.ps; or can it only be done with 2 commands eg) pdf2ps invoice.pdf invoice.ps; lpr invoice.ps [RET]; // if using lpr for example. any gostscript gurus here? I'm fairly sure it can't be done in one command :( but im not knowledgable on gostscript so... Quote Link to comment Share on other sites More sharing options...
johnnyv Posted October 9, 2002 Author Report Share Posted October 9, 2002 I will just call a perl script through php like this <? // stuff to make the pdf file exec('perl scriptname.pl > /dev/null'); // routing the exec to /dev/null means you won't stall your php script and it can continue // executing, if you don't do this the php script will stall untill the perl script has finished // executing( which would be a problem for a slow perl script as php has a 30sec timeout by // default, not to mention > 5 sec is a long time in userland). ?> scriptname.pl //--------------------------------------------------------------------------- #! /usr/bin/perl # called from php after generating pdf file using fpdf # if your perl script is not in the directory where your pdf and ps file will be you need to # include the path to the files. if(invoice.ps) { unlink("invoice.ps"); #delete previously generated .ps file } system "pdf2ps","invoice.pdf","invoice.ps"; #call pdf2ps to convert the pdf to a ps file system "lpr", "invoice.ps"; # prints the ps file # you could specify a printer if you wish, else the default printer is used # cups supports lpr commands if(invoice.pdf) { unlink("invoice.pdf"); #delete pdf file } //----------------------------------------------------------------------------- Incase anyone was interested :roll: Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted October 9, 2002 Report Share Posted October 9, 2002 HTML is suitable for printing if you use the proper CSS rules for the printer media, and of course if your browser supports media distinction in CSS. Back in late 1999/early 2000, only IE could do that (distinguish screen and printer output in CSS); mozilla M17 (IIRC) could not. But it seems that Mozilla 1.0 is able to render different CSS rules for screen and printer. Yves. Quote Link to comment Share on other sites More sharing options...
johnnyv Posted October 9, 2002 Author Report Share Posted October 9, 2002 what css stuff for printing? I know about the page break stuff etc.. <style type="text/css"> dontBreak { page-break-inside: avoid; } </style> Last time i looked the above only worked in opera, but moz probably supports it now. with a pdf for example its really easy to put stuff anywhere you like on the page and it always comes out right on the printer. I use html to display on the browser but it contains additional info that is not displayed on the printed page which is generated from a template(invoices etc.. this is intranet stuff). If you have any links to good tutorials or infomation on accurate printing using html they would be most welcome. Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted October 10, 2002 Report Share Posted October 10, 2002 Just W3C: http://www.W3.org/Here's an example of something I did: body { background: rgb(255,255,255); color: rgb(0,0,0); } h1, h2, h3, h4, h5, h6, p, ul, ol, dl, li, td, th { font-family: sans-serif; } h1 { text-align: center; color: rgb(255,0,0); font-weight: 800; } h2, h3, h4, h5, h6 { text-align: left; color: rgb(255,102,0); font-weight: 600; } h6 { font-size: 0.8em; } h5 { font-size: 1.0em; } h4 { font-size: 1.2em; } h3 { font-size: 1.4em; } h2, h1 { font-size: 1.6em; } p { font-size: 1.0em; text-align: justify; text-indent: 5ex; margin: 1ex 0 0 1ex; } code, pre { font-family: monospace; font-size: 0.8em; } code { display: inline; white-space: normal; color: rgb(159,95,63); } pre { display: block; white-space: pre; margin: 0 1ex; padding: 0; } ul, ol { display: list-item; list-style: outside; text-align: justify; } ol { list-style-type: upper-roman; } ol ol { list-style-type: decimal; } ol ol ol { list-style-type: lower-alpha; } ul { list-style-type: disc; } ul ul { list-style-type: circle; } table { border: 1px outset rgb(75%,75%,75%); margin: 1ex; } tr { border: 0 none rgb(255,255,255); } td, th { border: 1px inset rgb(75%,75%,75%); } td { vertical-align: top; } dl { text-align: justify; margin: 1ex 0 0 1ex; font-size: 0.9em; font-weight: 400; font-style: normal; } dt { font-weight: 700; text-decoration: none; font-style: italic; } blockquote { margin: 1ex 1ex 0 5ex; font-size: 0.9em; text-align: left; } iframe { display: block; margin: 0 1ex; padding: 1em; border: thin solid rgb(159,95,63); background: rgb(95%,95%,85%); width: 100%; height: 350px; } em { color: rgb(255,102,0); text-decoration: none; font-weight: 400; font-style: italic; } sup, sub { font-size:80%; line-height: 125% } sup { vertical-align: top; } sub { vertical-align: bottom; } a:hover, .index a:hover, .language-description a:hover { /* CSS2 */ color: rgb(0,37,102); background-color: rgb(255,102,0); } address { font-size: 10px; color: rgb(191,0,0); text-align: right; font-style: normal; margin: 0; padding: 0; } ins, ins a, ins em, ins code, ins td, ins dl { font-size: 110%; color: rgb(20%,40%,60%); text-decoration: none; } del, del a, del em, del code, del td, del th, del dl, del li, del .keywd, del .param { font-size: 90%; color: rgb(50%,50%,50%); text-decoration: line-through; } /* * Classes modificatrices de tags HTML */ p.follow { /* comme après un BR */ text-indent: 0; margin-top: 0; } pre.in-list { margin-left: 10em; } pre.code { padding: 0 1ex; border: thin solid rgb(159,95,63); background: rgb(95%,95%,85%); } pre.code-in-container { padding: 0 1ex; margin: 0; } .contains-pre-code { border: thin solid rgb(159,95,63); background: rgb(95%,95%,85%); } pre.wrong-code { padding: 0 1ex; border: thin solid rgb(0,0,0); background: rgb(95%,95%,85%); color: rgb(255,0,0); } dl.language-description { font-family: monospace; text-align: left; color: rgb(159,95,63); font-size: 0.8em; } dl.note { color: rgb(191,0,0); } div.section { /* partie de document spéciale (sommaire, index...) */ } /* * Classes et identifiants fonctionels */ .keywd { font-weight: 700; text-decoration: none; font-style: normal; } .param { font-weight: 400; text-decoration: none; font-style: italic; } .index { text-align: left; } .index a { color: rgb(0,37,102); font-weight: 400; text-decoration: none; font-style: normal; } .language-description a { color: rgb(159,95,63); font-weight: 400; text-decoration: none; font-style: normal; } .warning { background-color: rgb(255,255,127); } div#ref-doc { font-size: 10px; color: rgb(191,0,0); background: transparent; text-align: right; margin: 0; padding: 0; /* CSS2 */ z-index: 10; /* CSS2 */ position: fixed; /* CSS2 */ top: 0; right: 0; } div#front-page p { font-size: 1.2em; line-height: 2em; vertical-align: bottom; } div#front-page h1 { border: 2px rgb(0,0,0) solid; line-height: 1.5em; margin: 3em 0; } div#front-page table { width: 100%; margin: 1.5em 0; } div#front-page table, div#front-page tr, div#front-page th, div#front-page td { border: none; } div#front-page th, div#front-page td { line-height: 1.5em; vertical-align: middle; } div#front-page th { font-style: italic; text-align: left; } div#front-page .document-type { font-weight: bold; font-style: normal; font-size: 1.2em; line-height: 2.5em; vertical-align: middle; border: 2px rgb(0,0,0) solid; } div#front-page table.references { font-weight: 600; border: 1px solid rgb(0,0,0); } div#front-page table.references th, div#front-page table.references td { border: 1px solid rgb(0,0,0); } div#front-page div#copyright { border: 1px solid rgb(50%, 50%, 50%); color: rgb(50%, 50%, 50%); text-align: center; } /* CSS2: */ @media print { h1, h2, h3, h4, h5, h6 { font-weight: 600; color: rgb(0,0,0); text-decoration: underline; } body, td, th { font-size: 90%; } /* bug: IE ne répercute pas dans table */ p, ul, ol, dl, li, td { font-family: serif; } h6 { font-size: 1.0em; } h5 { font-size: 1.2em; } h4 { font-size: 1.4em; } h3 { font-size: 1.6em; } h2, h1 { font-size: 1.8em; } code, pre.wrong-code, em { color: rgb(25%,25%,25%); } dl, dl.language-description, a, #ref-doc { color: rgb(0,0,0) } a { text-decoration: none; font-weight: 600; } .warning { background-color: transparent; text-decoration: underline; } del, del a, del em, del code, del td, del th, del dl, del li, del .keywd, del .param { display: none; } div#front-page h1 { text-decoration: none; } /* PAGE BREAKS : (->CSS2->) */ div#front-page { page-break-after: always; } div.section h1 { page-break-before: always; } h1+h2, h2+h3, h3+h4, h4+h5, h5+h6 { page-break-before: avoid; } h1+p, h2+p, h3+p, h4+p, h5+p, h6+p { page-break-before: avoid; } address, iframe, ol, ul, tr, img { page-break-inside: avoid; } } One of my first tries with CSS, so there may be errors. Yves. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.