<div dir="ltr">2013/1/30 Tobias Diekershoff <span dir="ltr"><<a href="mailto:tobias.diekershoff@gmx.net" target="_blank">tobias.diekershoff@gmx.net</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Dear list,<br>
<br>
I have a problem compiling PowerPDF and seek your knowledge to solve it.<br>
<br>
I've written a program on Linux where the PowerPDF works perfectly, but<br>
when I tried to compile it on the machine at work (Windows XP) it gives<br>
an<br>
<br>
"Illegal type conversion 'Short String' to 'PChar'"<br>
<br>
in powerpdf/pdftypes.pas lines 1007, 1010 and 1146 (see below).<br>
<br>
I'm using Lazarus 1.0, FPC 2.6.0 and PowerPDF 0.9.9.<br>
<br>
Thanks in advance<br>
Tobias<br>
<br>
------ Code Sniplet (lines 1005 to 1011)-----<br>
{$IFNDEF UNIX}<br>
Len := MultiByteToWideChar(0, CP_ACP,<br>
PChar(Value), Length(Value), nil, 0);<br>
GetMem(PW, Len * 2);<br>
Len := MultiByteToWideChar(0, CP_ACP,<br>
PChar(Value), Length(Value), PW, Len * 2);<br>
{$ELSE}<br>
<br>
------ Code Sniplet (lines 1143 to 1147)-----<br>
// _WriteString<br>
procedure _WriteString(const Value: string; AStream: TStream);<br>
begin<br>
AStream.Write(PChar(Value)^, Length(Value));<br>
end; <br></blockquote></div><div><br></div><div style>Hm... I'm using PowerPDF fine on Windows 7.</div><div style><br></div><div style>I even managed to remove the dependency of LCL to be able to create PDFs and CGI applications:<br>
</div><div style><br></div><div style><a href="https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/powerpdf">https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/powerpdf</a><br></div>
<div style><br></div><div style><a href="http://silvioprog.com.br/cgi-bin/cgi2">http://silvioprog.com.br/cgi-bin/cgi2</a><br></div><div style><br></div><div style><div>program project1;</div><div><br></div><div>{$mode objfpc}{$H+}</div>
<div><br></div><div>uses</div><div> Classes,</div><div> FPimage,</div><div> FPReadJPEG,</div><div> FPWriteJPEG,</div><div> PdfDoc,</div><div> PdfFonts,</div><div> PdfTypes;</div><div><br></div><div> function CreateImage(AImage: TFPCustomImage): TPdfImage;</div>
<div> var</div><div> VWriter: TFPWriterJPEG;</div><div> begin</div><div> Result := TPdfImage.CreateStream(nil);</div><div> VWriter := TFPWriterJPEG.Create;</div><div> try</div><div> with Result do</div>
<div> try</div><div> AImage.SaveToStream(Stream, VWriter);</div><div> with Attributes do</div><div> begin</div><div> AddItem('Type', TPdfName.CreateName('XObject'));</div>
<div> AddItem('Subtype', TPdfName.CreateName('Image'));</div><div> AddItem('ColorSpace', TPdfName.CreateName('DeviceRGB'));</div><div> AddItem('Width', TPdfNumber.CreateNumber(AImage.Width));</div>
<div> AddItem('Height', TPdfNumber.CreateNumber(AImage.Height));</div><div> AddItem('BitsPerComponent', TPdfNumber.CreateNumber(8));</div><div> PdfArrayByName('Filter').AddItem(TPdfName.CreateName('DCTDecode'));</div>
<div> end;</div><div> except</div><div> Result.Free;</div><div> raise;</div><div> end;</div><div> finally</div><div> VWriter.Free;</div><div> end;</div><div> end;</div>
<div><br></div><div>var</div><div> VPdf: TPdfDoc;</div><div> VFile: TFileStream;</div><div> VImage: TFPMemoryImage;</div><div>begin</div><div> VPdf := TPdfDoc.Create;</div><div> VFile := TFileStream.Create('print.pdf', fmCreate);</div>
<div> VImage := TFPMemoryImage.Create(0, 0);</div><div> try</div><div> VPdf.NewDoc;</div><div> VPdf.AddPage;</div><div> VImage.LoadFromFile('image.jpg');</div><div> VPdf.AddXObject('Image', CreateImage(VImage));</div>
<div> VPdf.Canvas.DrawXObject(80, 650, VImage.Width, VImage.Height, 'Image');</div><div> VPdf.Canvas.TextOut(90, 770, 'Print OK!');</div><div> VPdf.SaveToStream(VFile);</div><div> WriteLn('Print OK!');</div>
<div> finally</div><div> VImage.Free;</div><div> VFile.Free;</div><div> VPdf.Free;</div><div> end;</div><div>end.</div></div><div><br></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>