[Lazarus] compiling PowerPDF on win32
silvioprog
silvioprog at gmail.com
Wed Jan 30 11:21:06 CET 2013
2013/1/30 Tobias Diekershoff <tobias.diekershoff at gmx.net>
> Dear list,
>
> I have a problem compiling PowerPDF and seek your knowledge to solve it.
>
> I've written a program on Linux where the PowerPDF works perfectly, but
> when I tried to compile it on the machine at work (Windows XP) it gives
> an
>
> "Illegal type conversion 'Short String' to 'PChar'"
>
> in powerpdf/pdftypes.pas lines 1007, 1010 and 1146 (see below).
>
> I'm using Lazarus 1.0, FPC 2.6.0 and PowerPDF 0.9.9.
>
> Thanks in advance
> Tobias
>
> ------ Code Sniplet (lines 1005 to 1011)-----
> {$IFNDEF UNIX}
> Len := MultiByteToWideChar(0, CP_ACP,
> PChar(Value), Length(Value), nil, 0);
> GetMem(PW, Len * 2);
> Len := MultiByteToWideChar(0, CP_ACP,
> PChar(Value), Length(Value), PW, Len * 2);
> {$ELSE}
>
> ------ Code Sniplet (lines 1143 to 1147)-----
> // _WriteString
> procedure _WriteString(const Value: string; AStream: TStream);
> begin
> AStream.Write(PChar(Value)^, Length(Value));
> end;
>
Hm... I'm using PowerPDF fine on Windows 7.
I even managed to remove the dependency of LCL to be able to create PDFs
and CGI applications:
https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/powerpdf
http://silvioprog.com.br/cgi-bin/cgi2
program project1;
{$mode objfpc}{$H+}
uses
Classes,
FPimage,
FPReadJPEG,
FPWriteJPEG,
PdfDoc,
PdfFonts,
PdfTypes;
function CreateImage(AImage: TFPCustomImage): TPdfImage;
var
VWriter: TFPWriterJPEG;
begin
Result := TPdfImage.CreateStream(nil);
VWriter := TFPWriterJPEG.Create;
try
with Result do
try
AImage.SaveToStream(Stream, VWriter);
with Attributes do
begin
AddItem('Type', TPdfName.CreateName('XObject'));
AddItem('Subtype', TPdfName.CreateName('Image'));
AddItem('ColorSpace', TPdfName.CreateName('DeviceRGB'));
AddItem('Width', TPdfNumber.CreateNumber(AImage.Width));
AddItem('Height', TPdfNumber.CreateNumber(AImage.Height));
AddItem('BitsPerComponent', TPdfNumber.CreateNumber(8));
PdfArrayByName('Filter').AddItem(TPdfName.CreateName('DCTDecode'));
end;
except
Result.Free;
raise;
end;
finally
VWriter.Free;
end;
end;
var
VPdf: TPdfDoc;
VFile: TFileStream;
VImage: TFPMemoryImage;
begin
VPdf := TPdfDoc.Create;
VFile := TFileStream.Create('print.pdf', fmCreate);
VImage := TFPMemoryImage.Create(0, 0);
try
VPdf.NewDoc;
VPdf.AddPage;
VImage.LoadFromFile('image.jpg');
VPdf.AddXObject('Image', CreateImage(VImage));
VPdf.Canvas.DrawXObject(80, 650, VImage.Width, VImage.Height, 'Image');
VPdf.Canvas.TextOut(90, 770, 'Print OK!');
VPdf.SaveToStream(VFile);
WriteLn('Print OK!');
finally
VImage.Free;
VFile.Free;
VPdf.Free;
end;
end.
--
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130130/4f687d07/attachment-0003.html>
More information about the Lazarus
mailing list