<font size="-1">

  • Follow


I can put out a Word Doc from PHP but if I try and manipulate the font
size in the PHP part it outputs a blank Word Document.

Here is what I have:
<?php
  $fname="report.doc";
    $handle = fopen( $fname, "rb" );
    $buf = fread( $handle, filesize( $fname ));
    fclose( $handle );
    $len = strlen( $buf );
    header( "Pragma: public" );
    header( "Cache-Control: private" );
    header( "Connection: close" );
    header( "Content-Type: application/msword" );
    header( "Content-Length: $len" );
    header( "Content-Disposition: inline; filename=\"$fname\"" );
    print $buf;
>
<table border="1">
<tr>
<td>FieldOneHeader</td>
<td>FieldTwoHeader</td>
<td>FieldThreeHeader</td>
....
<td>FieldTenHeader</td>
</tr>
<?php
//Oracle DB Connection username and password etc here

$s = OCIParse($connection. "select * from theTable");
OCIExecute($s, OCI_DEFAULT);
while (OCIFetch($s)) {
   print '<tr><td><font size="-1">' . ociresult($s, "FIELDONENAME") .
'</font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDTWONAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDTHREENAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDFOURNAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDFIVENAME"). '</
font></td>';
   //rest here .......
   print '<td><font size="-1">' . ociresult($s, "FIELDNINENAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDTENNAME"). '</
font></td></tr>';
}
print '</table>';


?>


The wierd part is if I only put font size in the first 5 fields it
will work:
   print '<tr><td><font size="-1">' . ociresult($s, "FIELDONENAME") .
'</font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDTWONAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDTHREENAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDFOURNAME"). '</
font></td>';
   print '<td><font size="-1">' . ociresult($s, "FIELDFIVENAME"). '</
font></td>';
   //rest here .......
   print '<td>' . ociresult($s, "FIELDNINENAME"). '</td>';
   print '<td>' . ociresult($s, "FIELDTENNAME"). '</td></tr>';



Please advise.

0
Reply teser3 (98) 6/13/2007 11:36:27 PM

teser3@hotmail.com wrote:

> I can put out a Word Doc from PHP but if I try and manipulate the font
> size in the PHP part it outputs a blank Word Document.

No; you are outputting HTML, not a MS Office document.

The problem is about MS Word's HTML parser, not about PHP.

-- 
----------------------------------
Iv�n S�nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
0
Reply ISO 6/13/2007 11:58:03 PM


..oO(teser3@hotmail.com)

>I can put out a Word Doc from PHP but if I try and manipulate the font
>size in the PHP part it outputs a blank Word Document.
>
>Here is what I have:
><?php
>  $fname="report.doc";
>    $handle = fopen( $fname, "rb" );
>    $buf = fread( $handle, filesize( $fname ));
>    fclose( $handle );

file_get_contents() exists.

>    $len = strlen( $buf );
>    header( "Pragma: public" );

'Pragma' is a request header, usage in a response is not defined.
Additionally the only defined directive for this header is 'no-cache'.

>    header( "Cache-Control: private" );
>    header( "Connection: close" );
>    header( "Content-Type: application/msword" );
>    header( "Content-Length: $len" );
>    header( "Content-Disposition: inline; filename=\"$fname\"" );
>    print $buf;
>>
><table border="1">
><tr>
>[...]

Now I'm confused - do you want to output the .doc document _and_ the
following together on the same page? That's not going to work.

Micha
0
Reply netizen9200 (1825) 6/14/2007 12:14:10 AM

Michael Fesser wrote:

>>    header( "Content-Type: application/msword" );
>>    header( "Content-Disposition: inline; filename=\"$fname\"" );

> Now I'm confused - do you want to output the .doc document _and_ the
> following together on the same page? That's not going to work.

No - He's forcing MS Word to open, then feeding HTML to it. He's not feeding
Word anything else.

-- 
----------------------------------
Iv�n S�nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Funciona mejor si lo enchufas
0
Reply ISO 6/14/2007 12:33:30 PM

..oO(Iv�n S�nchez Ortega)

>Michael Fesser wrote:
>
>>>    header( "Content-Type: application/msword" );
>>>    header( "Content-Disposition: inline; filename=\"$fname\"" );
>
>> Now I'm confused - do you want to output the .doc document _and_ the
>> following together on the same page? That's not going to work.
>
>No - He's forcing MS Word to open, then feeding HTML to it. He's not feeding
>Word anything else.

Hmm, but he opens and sends a .doc file, followed by some ugly HTML ...

Micha
0
Reply netizen9200 (1825) 6/14/2007 3:23:45 PM

Michael Fesser wrote:

> Hmm, but he opens and sends a .doc file, followed by some ugly HTML ...

WTF???!!!

-- 
----------------------------------
Iv�n S�nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
0
Reply ISO 6/14/2007 3:32:37 PM

On Jun 14, 12:36 am, "tes...@hotmail.com" <tes...@hotmail.com> wrote:
> I can put out a Word Doc from PHP but if I try and manipulate the font
> size in the PHP part it outputs a blank Word Document.
>
> Here is what I have:
> <?php
>   $fname="report.doc";
>     $handle = fopen( $fname, "rb" );
>     $buf = fread( $handle, filesize( $fname ));
>     fclose( $handle );
>     $len = strlen( $buf );
>     header( "Pragma: public" );
>     header( "Cache-Control: private" );
>     header( "Connection: close" );
>     header( "Content-Type: application/msword" );
>     header( "Content-Length: $len" );
>     header( "Content-Disposition: inline; filename=\"$fname\"" );
>     print $buf;
>
> <table border="1">
> <tr>
> <td>FieldOneHeader</td>
> <td>FieldTwoHeader</td>
> <td>FieldThreeHeader</td>
> ...
> <td>FieldTenHeader</td>
> </tr>
> <?php
> //Oracle DB Connection username and password etc here
>
> $s = OCIParse($connection. "select * from theTable");
> OCIExecute($s, OCI_DEFAULT);
> while (OCIFetch($s)) {
>    print '<tr><td><font size="-1">' . ociresult($s, "FIELDONENAME") .
> '</font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDTWONAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDTHREENAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDFOURNAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDFIVENAME"). '</
> font></td>';
>    //rest here .......
>    print '<td><font size="-1">' . ociresult($s, "FIELDNINENAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDTENNAME"). '</
> font></td></tr>';}
>
> print '</table>';
>
> ?>
>
> The wierd part is if I only put font size in the first 5 fields it
> will work:
>    print '<tr><td><font size="-1">' . ociresult($s, "FIELDONENAME") .
> '</font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDTWONAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDTHREENAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDFOURNAME"). '</
> font></td>';
>    print '<td><font size="-1">' . ociresult($s, "FIELDFIVENAME"). '</
> font></td>';
>    //rest here .......
>    print '<td>' . ociresult($s, "FIELDNINENAME"). '</td>';
>    print '<td>' . ociresult($s, "FIELDTENNAME"). '</td></tr>';
>
> Please advise.




Why don't you use this:

http://sourceforge.net/projects/php-doc-xls-gen/



Sounds a lot better than trying to force things . Some people may have
no Word installed, this would suck with Doc headers for HTML.


Cheers!


Vladimir

0
Reply vladimir8221 (22) 6/14/2007 5:56:59 PM

Iv�n S�nchez Ortega <ivansanchez-alg@rroba-escomposlinux.-.punto.-.org>
wrote:

>Michael Fesser wrote:
>
>>>    header( "Content-Type: application/msword" );
>>>    header( "Content-Disposition: inline; filename=\"$fname\"" );
>
>> Now I'm confused - do you want to output the .doc document _and_ the
>> following together on the same page? That's not going to work.
>
>No - He's forcing MS Word to open, then feeding HTML to it. He's not feeding
>Word anything else.

Yes, he is.  I think you missed the "print $buf;" statement, where he
copies a Word document to stdout.

Note, however, that Internet Explorer does not trust the Content-Type; it
will often examine the first part of the file to determine how to process
it.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
0
Reply timr (1382) 6/15/2007 6:03:35 AM

"No - He's forcing MS Word to open, then feeding HTML to it. He's not
feeding
Word anything else.

Hmm, but he opens and sends a .doc file, followed by some ugly
HTML ... "


I am forcing the MS Word to open and feeding Oracle Database records
with HTML into it.
It works until I get to over 25 records and then it doesnt show
anything on the page.
Please advise how I can get a Word Document to open from a PHP web
page where it shows all the Database records because the way I am
doing it doesnt work when I get over 25 records.

I am in an environment where I cant download any foreign software so I
need to do it using PHP code.
Please advise.

0
Reply teser3 (98) 6/16/2007 12:03:55 AM



---------- Forwarded message ----------
From: "tes...@hotmail.com" <tes...@hotmail.com>
Date: Jun 15, 8:03 pm
Subject: <font size="-1">
To: comp.lang.php


"No - He's forcing MS Word to open, then feeding HTML to it. He's not
feeding
Word anything else.

Hmm, but he opens and sends a .doc file, followed by some ugly
HTML ... "

I am forcing the MS Word to open and feeding Oracle Database records
with HTML into it.
It works until I get to over 25 records and then it pops open a Word
Document that is blank.
Please advise how I can get a Word Document to open from a PHP web
page where it shows all the Database records because the way I am
doing it doesnt work when I get over 25 records.

I am in an environment where I cant download any foreign software so I
need to do it using PHP code.
Please advise.

0
Reply teser3 (98) 6/16/2007 12:05:29 AM

..oO(teser3@hotmail.com)

>I am forcing the MS Word to open and feeding Oracle Database records
>with HTML into it.
>It works until I get to over 25 records and then it doesnt show
>anything on the page.

I'm surprised you see anything at all. From Word's point of view you're
sending an invalid document. It's like taking an image file, appending
some random bytes to it and then expecting the image viewer to still
recognize it as an image.

>Please advise how I can get a Word Document to open from a PHP web
>page where it shows all the Database records because the way I am
>doing it doesnt work when I get over 25 records.

Well, you would have to create that Word document on the server and then
deliver it to the browser ...

Or maybe Word is capable of recognizing plain HTML? Then all you would
have to do is to send an appropriate Content-Type header (as you already
do), followed by the HTML content. No reason to send any .doc file.

Micha
0
Reply netizen9200 (1825) 6/16/2007 12:27:26 AM

teser3@hotmail.com wrote:
> "No - He's forcing MS Word to open, then feeding HTML to it. He's not
> feeding
> Word anything else.
> 
> Hmm, but he opens and sends a .doc file, followed by some ugly
> HTML ... "
> 
> 
> I am forcing the MS Word to open and feeding Oracle Database records
> with HTML into it.
> It works until I get to over 25 records and then it doesnt show
> anything on the page.
> Please advise how I can get a Word Document to open from a PHP web
> page where it shows all the Database records because the way I am
> doing it doesnt work when I get over 25 records.
> 
> I am in an environment where I cant download any foreign software so I
> need to do it using PHP code.
> Please advise.
> 

Forget about Word and create correct HTML that any browser can understand.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
Reply jstucklex (14356) 6/16/2007 1:26:31 AM

On Jun 15, 9:26 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> tes...@hotmail.com wrote:
> > "No - He's forcing MS Word to open, then feeding HTML to it. He's not
> > feeding
> > Word anything else.
>
> > Hmm, but he opens and sends a .doc file, followed by some ugly
> > HTML ... "
>
> > I am forcing the MS Word to open and feeding Oracle Database records
> > with HTML into it.
> > It works until I get to over 25 records and then it doesnt show
> > anything on the page.
> > Please advise how I can get a Word Document to open from a PHP web
> > page where it shows all the Database records because the way I am
> > doing it doesnt work when I get over 25 records.
>
> > I am in an environment where I cant download any foreign software so I
> > need to do it using PHP code.
> > Please advise.
>
> Forget about Word and create correct HTML that any browser can understand.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -

Okay, I guess the main thing is how do I create a Print Friendly
report?   I was using Word Doc so I oould create a Printer Friendly
report that could be seen in Word Document and also downloaded as a
Word Document.

0
Reply teser3 (98) 6/16/2007 10:05:15 PM

teser3@hotmail.com wrote:
> On Jun 15, 9:26 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> tes...@hotmail.com wrote:
>>> "No - He's forcing MS Word to open, then feeding HTML to it. He's not
>>> feeding
>>> Word anything else.
>>> Hmm, but he opens and sends a .doc file, followed by some ugly
>>> HTML ... "
>>> I am forcing the MS Word to open and feeding Oracle Database records
>>> with HTML into it.
>>> It works until I get to over 25 records and then it doesnt show
>>> anything on the page.
>>> Please advise how I can get a Word Document to open from a PHP web
>>> page where it shows all the Database records because the way I am
>>> doing it doesnt work when I get over 25 records.
>>> I am in an environment where I cant download any foreign software so I
>>> need to do it using PHP code.
>>> Please advise.
>> Forget about Word and create correct HTML that any browser can understand.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================- Hide quoted text -
>>
>> - Show quoted text -
> 
> Okay, I guess the main thing is how do I create a Print Friendly
> report?   I was using Word Doc so I oould create a Printer Friendly
> report that could be seen in Word Document and also downloaded as a
> Word Document.
> 

If you need to create something which is exact, create a PDF. 
Otherwise, code good html and CSS to make your pages fluid.  For the 
latter, try alt.html for help.



-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
Reply jstucklex (14356) 6/17/2007 12:16:04 AM

On Jun 16, 8:16 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> tes...@hotmail.com wrote:
> > On Jun 15, 9:26 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> >> tes...@hotmail.com wrote:
> >>> "No - He's forcing MS Word to open, then feeding HTML to it. He's not
> >>> feeding
> >>> Word anything else.
> >>> Hmm, but he opens and sends a .doc file, followed by some ugly
> >>> HTML ... "
> >>> I am forcing the MS Word to open and feeding Oracle Database records
> >>> with HTML into it.
> >>> It works until I get to over 25 records and then it doesnt show
> >>> anything on the page.
> >>> Please advise how I can get a Word Document to open from a PHP web
> >>> page where it shows all the Database records because the way I am
> >>> doing it doesnt work when I get over 25 records.
> >>> I am in an environment where I cant download any foreign software so I
> >>> need to do it using PHP code.
> >>> Please advise.
> >> Forget about Word and create correct HTML that any browser can understand.
>
> >> --
> >> ==================
> >> Remove the "x" from my email address
> >> Jerry Stuckle
> >> JDS Computer Training Corp.
> >> jstuck...@attglobal.net
> >> ==================- Hide quoted text -
>
> >> - Show quoted text -
>
> > Okay, I guess the main thing is how do I create a Print Friendly
> > report?   I was using Word Doc so I oould create a Printer Friendly
> > report that could be seen in Word Document and also downloaded as a
> > Word Document.
>
> If you need to create something which is exact, create a PDF.
> Otherwise, code good html and CSS to make your pages fluid.  For the
> latter, try alt.html for help.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================- Hide quoted text -
>
> - Show quoted text -

Thanks,  I was also trying to find info on PHP to PDF but cant seem to
find anything on that.
I would like to output my Oracle records using PHP to PDF report.
Please advise.

0
Reply teser3 (98) 6/17/2007 12:48:38 AM

..oO(teser3@hotmail.com)

>Thanks,  I was also trying to find info on PHP to PDF but cant seem to
>find anything on that.

http://www.google.com/search?q=php+create+pdf

There's _a lot_ of informations available! There are many different
libraries available for use with PHP, some commercial, some free.

Check out

http://fpdf.org/
http://sourceforge.net/projects/pdf-php

I haven't used them yet, so I can't provide examples. For FPDF there are
tutorials available on their site.

Micha
0
Reply netizen9200 (1825) 6/17/2007 1:34:17 AM

teser3@hotmail.com wrote:
> On Jun 16, 8:16 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> tes...@hotmail.com wrote:
>>> On Jun 15, 9:26 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>> tes...@hotmail.com wrote:
>>>>> "No - He's forcing MS Word to open, then feeding HTML to it. He's not
>>>>> feeding
>>>>> Word anything else.
>>>>> Hmm, but he opens and sends a .doc file, followed by some ugly
>>>>> HTML ... "
>>>>> I am forcing the MS Word to open and feeding Oracle Database records
>>>>> with HTML into it.
>>>>> It works until I get to over 25 records and then it doesnt show
>>>>> anything on the page.
>>>>> Please advise how I can get a Word Document to open from a PHP web
>>>>> page where it shows all the Database records because the way I am
>>>>> doing it doesnt work when I get over 25 records.
>>>>> I am in an environment where I cant download any foreign software so I
>>>>> need to do it using PHP code.
>>>>> Please advise.
>>>> Forget about Word and create correct HTML that any browser can understand.
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================- Hide quoted text -
>>>> - Show quoted text -
>>> Okay, I guess the main thing is how do I create a Print Friendly
>>> report?   I was using Word Doc so I oould create a Printer Friendly
>>> report that could be seen in Word Document and also downloaded as a
>>> Word Document.
>> If you need to create something which is exact, create a PDF.
>> Otherwise, code good html and CSS to make your pages fluid.  For the
>> latter, try alt.html for help.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================- Hide quoted text -
>>
>> - Show quoted text -
> 
> Thanks,  I was also trying to find info on PHP to PDF but cant seem to
> find anything on that.
> I would like to output my Oracle records using PHP to PDF report.
> Please advise.
> 

Try www. fpdf.org.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
Reply jstucklex (14356) 6/17/2007 1:34:34 AM

Michael Fesser wrote:

> I'm surprised you see anything at all. From Word's point of view you're
> sending an invalid document. It's like taking an image file, appending
> some random bytes to it and then expecting the image viewer to still
> recognize it as an image.

If you're using GIF, then this will work flawlessly. The GIF spec states
that any additional data found at the end of a file must be ignored.

Interestingly the ZIP spec says the inverse: any extra data found at the
*beginning* of a file must be ignored. ("Header" data for ZIP files is
stored at the *end* of the file rather than what is common for most file
formats: the beginning of the file. This is because ZIP files would often
span multiple floppy disks, and the header would need to be the last bit
of data to be written.) Thus it is possible to create a file which is both
a perfectly valid GIF *and* a perfectly valid ZIP -- nice way of hiding
arbitrary data in an image file, though it swells the size of the file
significantly.

-- 
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 114 days, 1 min.]

       You're Not Allowed to Take Pictures of the US Embassy in Rome
            http://tobyinkster.co.uk/blog/2007/06/16/us-embassy/
0
Reply usenet200706 (48) 6/17/2007 4:22:32 PM

17 Replies
9 Views

(page loaded in 0.169 seconds)


Reply: