Recent

Author Topic: PostscriptPrinter  (Read 8260 times)

critlopaco

  • New member
  • *
  • Posts: 7
PostscriptPrinter
« on: January 04, 2010, 12:22:58 pm »
PostscriptCanvas doesn't support unicode charset.
Example: I'd like to make a postscript file with russion characters. They are OK on win32, but they aren't seen on Mac. (PostscriptCanvas.TextOut(...));
How can I set the options? (on english Lazarus)

« Last Edit: January 04, 2010, 12:29:21 pm by critlopaco »

jesusr

  • Sr. Member
  • ****
  • Posts: 499
Re: PostscriptPrinter
« Reply #1 on: January 04, 2010, 09:20:28 pm »
Can you provide a sample?. What Lazarus version? see help->about lazarus -> version tab, then right click to copy version info to clipboard.

critlopaco

  • New member
  • *
  • Posts: 7
Re: PostscriptPrinter
« Reply #2 on: January 05, 2010, 08:15:55 am »
Lazarus 0.9.29 r21438 FPC 2.2.4 i386-darwin-carbon (beta)
-------------------------
procedure TForm1.Postscript1Click(Sender: TObject);
var
x:utf8string;
PsCanvas: TPostscriptCanvas;
Begin
x:='абцдефгхиыйклмнопршщтвжъяю';
if SaveDialog1.Execute then
begin
Try  
PsCanvas := TPostscriptCanvas.Create;  
Canvas.BeginDoc;
PsCanvas.TextOut(20,20,x);
PsCanvas.SaveToFile(SaveDialog1.FileName);
PsCanvas.EndDoc;
finally
    PsCanvas.Free;
    ShowMessage('The PS file is ready.');
end;
end;
End;
« Last Edit: January 05, 2010, 04:15:41 pm by critlopaco »

jesusr

  • Sr. Member
  • ****
  • Posts: 499
Re: PostscriptPrinter
« Reply #3 on: January 05, 2010, 10:53:39 pm »
The first problem in your sample is that you are calling PsCanvas.SaveToFile() before PsCanvas.EndDoc, EndDoc is important as it instructs ps interpreter to show the page, SaveToFile should be called after EndDoc.

The second problem is that according to your version, postscriptcanvas now supports user defined resolution (by default 300 dpi is used) but there was a problem in Lazarus because no default paper height and width was assumed, so bounding box of output ended to be 0 width/height. In lazarus revision 23386 we have fixed this problem and now a A4 paper is assumed.

Both problems may or not affect the output depending on the ps interpreter. if it worked for you on windows it might mean that ps interpreter under mac is stricter.

In the mean time you can solve the problem by doing something like:

Code: [Select]
PsCanvas := TPostscriptCanvas.Create;
PsCanvas.PaperWidth := round(PSCanvas.XDPI*595/72);
PsCanvas.PaperHeight:=round(PSCanvas.YDPI*842/72);
PsCanvas.BeginDoc;
etc

once these two points are fixed, your sample worked fine here.

critlopaco

  • New member
  • *
  • Posts: 7
Re: PostscriptPrinter
« Reply #4 on: January 06, 2010, 09:01:07 am »
Sorry, I have copied briefly and wrongly. Really, the program work well and the created postscript file by Mac(Lazarus) is seen well with GSview on PC (russion characters).
Maybe, Preview of Leopard doesn't work well with Lazarus Postscript.
Thanks

 

TinyPortal © 2005-2018