On Fri, 17 Aug 2012, Leonardo M. Ramé wrote:

I'm using xhtml2pdf to convert html text to pdf. If I use from the
command line, I can do this:

cat /var/www/cgi-bin/salida.html | xhtml2pdf - -

or this:

xhtml2pdf - - < /var/www/cgi-bin/salida.html

The parameters "- -" mean, take input from StdIn and send output to
StdOut.

When I try to execute the same using TProcess, it apparently never
receives the input.

Here's a modified snippet I copied from 
http://wiki.freepascal.org/Executing_External_Programs

procedure TForm1.Button1Click(Sender: TObject);
var
 lProcess: TProcess;
 lStr: TStringList;
 lText: string;

begin
 lProcess := TProcess.Create(nil);
 lStr := TStringList.Create;
 try
   lStr.LoadFromFile('/var/www/cgi-bin/salida.html');
   lProcess.Options := [poUsePipes, poStderrToOutPut];
   lProcess.CommandLine := '/usr/bin/xhtml2pdf - -';
   lProcess.Execute;
   lText := lStr.Text;
   lProcess.Input.Write(lText[1], Length(lText));

You should probably close the input. xhtml2pdf has no way of knowing it 
received all input.

Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to