#1 PDF Engine » Delphi: Copy PDF to a canvas » 2015-03-12 12:45:21

totaldata
Replies: 1

Hi,
Is it possible to copy a PDF (as a canvas image) from TPdfDocumentGDI to a printer's canvas or an Timage's canvas. Please be specific as I am a newbie.

I need to print PDF pages unattended, so it is not a solution to use adobe reader, as this requires user intervention, my thought was to copy the image from TPdfDocumentGDI to the printer canvas instead

regards Ib

#2 Re: PDF Engine » Newbie: Placing text on the page » 2013-09-25 00:02:46

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.

#3 Re: PDF Engine » Newbie: Placing text on the page » 2013-09-24 05:35:48

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

#4 Re: PDF Engine » Newbie: Placing text on the page » 2013-09-23 19:14:37

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

#5 PDF Engine » Newbie: Placing text on the page » 2013-09-22 21:32:36

totaldata
Replies: 8

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

Board footer

Powered by FluxBB