#1 2013-09-22 21:32:36

totaldata
Member
Registered: 2013-09-22
Posts: 5

Newbie: Placing text on the page

Hi,
I'm a newbie with the synPDF, so I hope this question is not too stupid.

I am developing a website that's output a pdf formula. The formula seems fine on my development computer, but when i place the program on our server the placement of text is changing. I would preciate some advice.

I am trying to print text in fx x=15 mm and y=40 mm, but it seems as a mm is longer on my server than on my development machine (missing the lower part of the printout, and also wider)

Here is what I am doing:

  lPdf := TPdfDocumentGDI.Create;
  lpdf.EmbeddedTTF:=true;  // embed fonts as the user might not have these
  lPdf.DefaultPaperSize   := psA4;
  lpdf.DefaultPageLandscape:=true;
  lPdf.ScreenLogPixels:=96; // is the problem here ??
  lPage := lPDF.AddPage;
  lPdf.VCLCanvas.Brush.Style:=bsClear;
  x_dot_mm := GetDeviceCaps(lPdf.VCLCanvas.Handle,HORZRES)/GetDeviceCaps(lPdf.VCLCanvas.Handle,HORZsize);
  y_dot_mm := GetDeviceCaps(lPdf.VCLCanvas.Handle,vertres)/GetDeviceCaps(lPdf.VCLCanvas.Handle,vertsize);

  xmm := round(x*x_dot_mm);
  ymm := round(Y*y_dot_mm);
  lpdf.vclCanvas.TextOut(xmm,ymm,tekst);

I would love to have the same printout from both PC's, how do i do that. (Please be specific as I am a newbie)

regards

Offline

#2 2013-09-23 07:25:56

Jumpy
Member
Registered: 2013-09-13
Posts: 7

Re: Newbie: Placing text on the page

totaldata wrote:

I am developing a website that's output a pdf formula. The formula seems fine on my development computer, but when i place the program on our server the placement of text is changing. I would preciate some advice.
[...]
(missing the lower part of the printout, and also wider)

Maybe that is related to the problem I have, where the output is different (in the lower part of the page). Here, too, on development computer and in a desktop environment everything looks fine. On the Webserver the output is different.

http://synopse.info/forum/viewtopic.php?id=1417

Offline

#3 2013-09-23 12:54:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Newbie: Placing text on the page

May indeed be related.

I was not able to find out the root cause.

What I find weird is that the VCL code is pretty stable and standard, and just writes into a regular GDI metafile.

Offline

#4 2013-09-23 16:29:40

Jumpy
Member
Registered: 2013-09-13
Posts: 7

Re: Newbie: Placing text on the page

I investigated my problem a little further and found out, that on the Webserver I can only print fewer lines on one page (related to totaldata's observation that a mm seems longer on his webserver).

Maybe it has todo with the fact that there's no printer or screen? Somewhere where the size of the Metafile is defined?

Last edited by Jumpy (2013-09-23 16:30:04)

Offline

#5 2013-09-23 19:14:37

totaldata
Member
Registered: 2013-09-22
Posts: 5

Re: Newbie: Placing text on the page

Hi All,
New member wrote: Maybe it has todo with the fact that there's no printer or screen? Somewhere where the size of the Metafile is defined?

Just to check this, I installed a printer on the server, and ran the program with an open remote window, but with no changes. I still have some "long" mm. By the way, my faulty application is running on an old MS Small Business Server 2003
regards

Offline

#6 2013-09-24 05:35:48

totaldata
Member
Registered: 2013-09-22
Posts: 5

Re: Newbie: Placing text on the page

I know this is very quick and extremely dirty, but for those of us who needs to solve the problem here and now, you must scale down the printout on the server. Of course the problem should be solved otherwise, but meanwhile:

I have to scale the x with approx 0.67 and y with approx 0.8 (done visual, but ok for me). It is rather simple to do this. you can figure out the OS with major and minor version in delphi and these are predefined in delphi (Win32MajorVersion, Win32MinorVersion):

    major.minor = 5.2 => Windows 2003 server or XP64
    major.minor = 6.0 => Windows Vista/2008 server
    major.minor = 6.1 => Windows 7/2008 server R2

My code now looks like (only server 2003 implemented in the code, you must change the condition if running other server version):

  lPdf := TPdfDocumentGDI.Create;
  lpdf.EmbeddedTTF:=true;  // embed font that the user might not have
  lPdf.DefaultPaperSize   := psA4;
  lpdf.DefaultPageLandscape:=true;
  lPdf.ScreenLogPixels:=96;
  lPage := lPDF.AddPage;
  lPdf.VCLCanvas.Brush.Style:=bsClear;
  scalex:=1;
  scaley:=1;
  if (Win32MajorVersion=5) and (Win32MinorVersion=2) then begin
    //•major.minor = 5.2 => Windows 2003 server or XP64
    //•major.minor = 6.0 => Windows Vista/2008 server
    //•major.minor = 6.1 => Windows 7/2008 server R2
    scalex :=0.67;
    scaley :=0.8;
  end;
  x_dot_mm := GetDeviceCaps(lPdf.VCLCanvas.Handle,HORZRES)/GetDeviceCaps(lPdf.VCLCanvas.Handle,HORZsize)*scalex;
  y_dot_mm := GetDeviceCaps(lPdf.VCLCanvas.Handle,vertres)/GetDeviceCaps(lPdf.VCLCanvas.Handle,vertsize)*scaley;

regards

Offline

#7 2013-09-24 11:21:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Newbie: Placing text on the page

Perhaps it will depend on the "virtual" desktop resolution, or DPI.

Offline

#8 2013-09-25 00:02:46

totaldata
Member
Registered: 2013-09-22
Posts: 5

Re: Newbie: Placing text on the page

You might be right. I was in doubt about using DESKTOPHORZRES instead of horzres and DESKTOPVERTRES instead of vertres

microsoft documentation state:

DESKTOPHORZRES    Windows NT only: Width, in pixels, of the virtual desktop. This value may be larger than HORZRES if the device supports a virtual desktop or multiple displays.
DESKTOPVERTRES    Windows NT only: Height, in pixels, of the virtual desktop. This value may be larger than VERTRES if the device supports a virtual desktop or multiple displays.

I need to have a solution to this problem, as it is stalling a company startup of a new service, and I have the CEO breating down my neck, so I have to make a QAD solution.

Offline

#9 2013-09-25 12:16:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Newbie: Placing text on the page

It is potentially ScreenLogPixels which is not good for you.

Could you try to remove the line, or change it to a custom value?

Offline

Board footer

Powered by FluxBB