php-general Digest 6 Dec 2010 14:59:13 -0000 Issue 7072
Topics (messages 309866 through 309867):
Re: desire your recommendation for our specific HTML -> PDF project
309866 by: Steve Staples
Redirect output to a file on the web server
309867 by: Ferdi
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Fri, 2010-12-03 at 18:11 -0500, Govinda wrote:
> Hi all
>
> I have a question which I see from googling has been discussed at
> length.. but I want to know what you would recommend based on our
> particular needs. I want to be on the right track before I find out a-
> week-of-work later that I chose the wrong tool (a tool which works,
> but whose peculiarity, in the end, would rule it out for our project).
>
> We have a dynamic HTML page that displays 30 "address labels" within
> the dimensions of one single US-letter-size document. We want the
> user to be able to print the single letter-sized page and have the
> content line up perfectly (as it does in the browser) for the Avery
> address label (printed) sticker paper which they will use to then peel
> the 30 stickers and affix to physical product. The HTML page is ~
> 200k worth of HTML (<div>s and <table>s), text, gifs, jpgs, a barcode
> PNG graphic, and heavy use of exacting CSS - CSS2 as well as a touch
> of CSS3 (CSS3 property transform), i.e. this:
> /* --- for firefox, safari, chrome, etc. --- */
> -webkit-transform: rotate(90deg);
> -moz-transform: rotate(90deg);
> /* --- for ie --- */
> filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
>
> ...which I use to rotate (90 degrees) a barcode which I grab off of
> this site/service:
> http://www.barcodesinc.com/generator/index.php
>
> We could drop that barcode PNG/service only if I could easily replace
> it with another... and the barcode must be rotated 90 degrees - to
> thus fit in its tiny (vertically-oriented) alloted slot on each of the
> 30 "address label cells".
>
> A thread on stackOverflow has people making recommendations all over
> the map.. as I would expect - our needs and experiences are all over
> the map.
>
> - I wish we had budget for the server version of PrinceXML ;-) ... but
> no luck.
> - I have never used any PHP libraries like FPDF or TCPDF, but am
> concerned about speed; corporate users (on various browsers) will need
> the pdf in real time. They may be patient and wait for the final PDF
> if keep the solution free.. but if it takes minutes to generate, that
> is a minus point.
> Also I am not sure how good these are for HTML -> PDF (as opposed to
> straight PDF from scratch).. plus not sure how good is the CSS
> support. Our page is a bit of an HTML/CSS kludge.
> - I have used the command-line tools HTMLDOC and wkpdf, but the former
> lacked the CSS I need now, and the latter introduces margin that kills
> it for exact address-label formatting (plus this project is on Linux).
>
> My PHP skills are not super strong yet.. but I am willing to do
> whatever it takes to pull any solution together.
> In case you have any familiarity with any PDF generation tools that
> you feel would fit the need here, then *please advise*!
>
> Thanks!
> -Govinda
>
>
> ------------
> Govinda
> govinda(DOT)webdnatalk(AT)gmail(DOT)com
>
Personally, I use FPDF [1] to generate PDF's on the fly. It has a lot
of "addons" that people have created, and some of those, are barcodes.
use it to generate shipping/packing labels for a client, and it creates
about 1000+ at a time, each containing 5 code128, and 1 QR code (on the
same label). I've used the FPDF with the rendering that includes the
image from memory (as i have another app that creates all the barcodes
in memory).
Anyway, I would look into that if pdf is the way you're going. There is
also html2pdf, but if you're looking for exact specifications, and
sizes, then I wouldn't personally use pure CSS, i would create my own
PDF. my shipping labels take < 20 seconds to create a 1500page pdf,
with all those barcodes, so creating a 30 label page, i can't see taking
more than 1 second to do.
just my $0.02
Steve
[1] http://www.fpdf.org
--- End Message ---
--- Begin Message ---
Greetings List members,
I have a script that takes quite a while to run, one or two hours, I wish to
redirect the normal php output to a file on the webserver itself. I don't
mind if in the process, the browser displays a blank page. The reason I want
to do this is that if the script crashes or the browser Is closed by
mistake, I have absolutely no record of where the script stopped running.
I could use code like below
At the beginning of the script:
ob_start();
At the end of the script:
$page = ob_get_contents();
ob_end_flush();
$fp = fopen("output.html","w");
fwrite($fp,$page);
fclose($fp);
However, I see some problems with this:
I'm not too sure of the size of the output. It may balloon to over the
buffering limit (in PHP? Apache?) and then what happens?
Secondly, if the script crashes before the end, I won't get any output.
Finally, I am using a library in the script that outputs status and error
messages of its own. So, if I manually opened a file and used fwrite()
alongside echo for my messages, I would lose out on those messages.
Anybody has any pointers on how you could send the output not only to a
browser, but also to a file on the webserver? If not, at least to a file?
Thanks and regards,
Ferdi
--- End Message ---