[RESOLVED] Error installing Power PDF on Mac lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- pasquale · 2012-03-24 09:39 Hello, everybody. When I try to compile PowerPDF on my iMac, I get an error message that prevents me from completing the compilation. Attached you will find a screenshot with the error I get. First of all, is PowerPDF compatible with Mac? If it is, what am I doing wrong? Should I try to install the package instead of compiling it? Thanks in advance. ---------------------------------------------------------------------- jwdietrich · 2012-03-24 10:08 What do you need PowerPDF for? The Mac's Quartz engine natively uses PDF for every graphic operation, therefore it would be selling coal to Newcastle to search for a third party solution in order to support PDF on Mac OS X. ---------------------------------------------------------------------- pasquale · 2012-03-24 10:18 Hi, I need PowerPDF because (under Windows) I learned how to use its graphic tools that allow me to design the printing interface of the form. In other words, instead of creating the layout of the page programmatically, PowerPDF allows me to draw the form that I can export in PDF format. I also hope that PowerPDF will help me resolve the problem I am currently having while trying to print out the contents of a ListBox. ---------------------------------------------------------------------- jwdietrich · 2012-03-24 10:33 Quote from: pasquale on March 24, 2012, 11:18:25 amHi, I need PowerPDF because (under Windows) I learned how to use its graphic tools that allow me to design the printing interface of the form. In other words, instead of creating the layout of the page programmatically, PowerPDF allows me to draw the form that I can export in PDF format. I also hope that PowerPDF will help me resolve the problem I am currently having while trying to print out the contents of a ListBox. However, this jeopardizes cross-platform compatibility. I wouldn't even try to compile PowerPDF under Mac OS X. ---------------------------------------------------------------------- pasquale · 2012-03-24 12:17 QuoteHowever, this jeopardizes cross-platform compatibility. I wouldn't even try to compile PowerPDF under Mac OS X. Does that mean that PowerPDF was only created for Windows? I thought it was a cross-platform component. ---------------------------------------------------------------------- marcov · 2012-03-24 12:57 The code seems to have two stale "if(n)def" linux conditionals that assume "not linux"="windows". One in pdftypes the other in pdfimages. In these two cases, change "linux" to "unix", and retry. If it works, then file a bug to have it changed in SVN ---------------------------------------------------------------------- pasquale · 2012-03-24 13:41 Quote from: marcov on March 24, 2012, 01:57:54 pm The code seems to have two stale "if(n)def" linux conditionals that assume "not linux"="windows". One in pdftypes the other in pdfimages. In these two cases, change "linux" to "unix", and retry. If it works, then file a bug to have it changed in SVN Great! Your amendments worked. Thanks a lot. ---------------------------------------------------------------------- Stefano · 2012-04-24 21:03 I have the same problem with Lazarus 0.9.28.2 and Mac OS 10.7 Lion. I can not run PowerPDF. I have no problems using PowerPDF version 0.9.1 under Linux and Windows. I can install version 0.9.1 of Lazarus 0.9.28.2 and Mac OS Lion and I can rebuild Lazarus with no errors. But when I compile my project, which works well under Linux and Windows, I get the following error in the form PdfTypes.pas: Code: [Select]_WriteString procedure (const Value: String; aStream: TStream); begin   AStream.Write (PChar (Value) ^, Length (Value)); end; Code: [Select]Error: Illegal type conversion: "ShortString" to "^ Char" Even replacing Linux with Unix in compiler directives, and replacing with ZLib PasZLib in the uses clause, this error remains. If I try to install version 0.9.7 downloaded from the Lazarus CCR, or the svn version (0.9.7.1), I get this error, always PdfTypes.pas: Code: [Select]TPdfObject = class; Error: Identifier not found "class". With the help of the Italian forum I managed to compile my project using version 0.9.1, replacing with ZLib PasZLib, Linux and Unix compiler directives, and also adding the following changes: 1) PdfTypes.pas: Code: [Select]_WriteString procedure (const Value: String; aStream: TStream); begin   AStream.Write (PChar (Value) ^, Length (Value)); end; replaced with: Code: [Select]_WriteString procedure (const Value: String; aStream: TStream); begin   AStream.Write (Value [1], Length (Value)); end; 2) PdfImages.pas: Code: [Select]Fpc} {$ ifndef         for y: = 0 to Height - 1 do         begin           pb: ScanLine = [y];           x: = 0;           while x <* PIXEL_COLOR_SIZE Width - 1 do           begin             b: = pb [x];             pb [x]: = pb [x +2];             pb [x +2]: = b;             Stream.Write (pb [x], 3);             x: = x + PIXEL_COLOR_SIZE;           end; Else {$}         for y: = 0 to aintfimage.Height - 1 do         begin           New (pb);           for x: = 0 to aintfimage.Width-1 do           begin             aColor: aIntfImage.Colors = [x, y];             pb [0]: = acolor.red shr 8;             pb [1]: = acolor.green shr 8;             pb [2]: = acolor.blue shr 8;             Stream.write (pb [0], 3);           end;           dispose (pb); {$ Endif}           Attributes.AddItem ('ColorSpace', TPdfName.CreateName ('DeviceRGB')); replaced by adding a ^: Code: [Select]pb ^ [0]: = acolor.red shr 8; pb ^ [1]: = acolor.green shr 8; pb ^ [2]: = acolor.blue shr 8; otherwise it gave this error: Code: [Select]PdfImages.pas (275.35) Error: Incompatible types: got "LongWord" expected "TByteArray" and also by placing in the modules PowerPDF compiler directives: Code: [Select]UNIX} {$ DEFINE {$} SEFINE LAZ_POWERPDF After these changes I can compile my project. But when I try to print I get the following error: Code: [Select]Error reading PReport1.Author: Access violation Press OK to ignore and risk data corruption. Press Cancel to kill the program Unfortunately I can not use versions 0.9.30 and later due to some bugs. Sorry for my bad English. Thanks in advance. ---------------------------------------------------------------------- Stefano · 2012-04-25 15:17 I solved it. I was able to install version 0.9.7 of PowerPDF downloaded from Lazarus CCR. The problem was to add the path to the component PowerPDF in the file /private/etc/fpc.cfg: Code: [Select]-Fu/Developer/lazarus/components/powerpdf It must be added at the beginning of all modules. Pas PowerPDF compiler directives: Code: [Select]{$DEFINE UNIX} {$DEFINE LAZ_POWERPDF} Finally we must add a module in ^ PdfImages.pas, otherwise there is error when you go to complete a project that uses PowerPDF: Code: [Select]pb [0]: = acolor.red shr 8; pb [1]: = acolor.green shr 8; pb [2]: = acolor.blue shr 8; becomes: Code: [Select]pb^[0]: = acolor.red shr 8; pb^[1]: = acolor.green shr 8; pb^[2]: = acolor.blue shr 8; A big thank you to Stilgar of the Italian Forum of Lazarus who gave me the advice to add the character ^. I hope this can help others. Stefano