Hi,
I've a software that i need generate a PDF File.
Today I m using, Printer.Canvas, but for build a PDF I'm need a virtual Printer PDF. Then I need to create this file without this virtual Printer.
I need to make a PDF mixing TIFF files, WpRichText, Barcode QRCode and Canvas for customize some things in pages.
Also I installed WPDF and i tried to use this component.
With the Printer.Canvas its worked but with WPPDFPrinter I can't.
All pages stayed white.
Code
function TForm1.CarregaPagina(Diretorio,Arquivo, pagina:String): Boolean;
var
Narisp:String;
begin
try
Xpress.Filename:= Diretorio + '\' + Arquivo;
Xpress.Deskew;
ReducaoL:= ILargura1 / (Xpress.IWidth / Xpress.IResX);
ReducaoA:= IAltura1 / (Xpress.IHeight / Xpress.IResY);
Xpress.PrinterWidth:= Trunc(ILargura1 * 1440);
Xpress.PrinterHeight:= Trunc(IAltura1 * 1440);
Xpress.PrinterTop:= Trunc( ( (AlturaImpressao1 - IAltura1) * 1440) /2);
Xpress.PrinterLeft:= Trunc( ( (LarguraImpressao1 - ILargura1) * 1440) /2);
Narisp := 'S000088988D';
Xpress.PrinterhDC:= WPPDFPrinter1.ReferenceDC;
WPPDFPrinter1.Canvas.TextOut(trunc(9/(2.54/resolucaoImpressao1)),100, Narisp+' '+ 'JAOZINHOC DA SILVA' + ' ' + '543234' + ' ' + '16/04/2020 08:20:25' + ' ' +' '+ pagina ); //todos cartorios
Result := true;
except
Result := false;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
WPPDFPrinter1.DLLName := 'C:\Arquivos de programas\wPDF\wPDF400DemoW.dll';
WPPDFPrinter1.Filename := 'C:\testeLeandro.pdf';
WPPDFPrinter1.BeginDoc;
for i := 1 to 4 do
begin
WPPDFPrinter1.StartPage( Round(21/2.54*300), Round(29.7/2.54*300), 72, 72, 0);
DC := WPPDFPrinter1.Canvas.Handle;
SaveDC(WPPDFPrinter1.Canvas.Handle);
ResolucaoImpressao1:= (GetDEviceCaps(DC, LOGPIXELSX));
LarguraImpressao1 := (GetDEviceCaps(DC, PHYSICALWIDTH) / ResolucaoImpressao1 - 0.3);
AlturaImpressao1 := (GetDEviceCaps(DC, PHYSICALHEIGHT) / ResolucaoImpressao1 ) +0.5;
ILargura1:= LarguraImpressao1 * 0.9536586; // 85.36586% da largura do papel que está na impressora... 14.63414% p/ margem
IAltura1:= AlturaImpressao1 * 0.8415385; // 96.15385% da altura do papel que está na impressora... 3.84615% p/ margem
LarguraImpressao := GetDeviceCaps(DC,LOGPIXELSX);
AlturaImpressao := GetDeviceCaps(DC,LOGPIXELSY);
SetMapMode(DC, MM_ANISOTROPIC);
SetWindowExtEx(DC, ResolucaoImpressao, ResolucaoImpressao, nil);
SetViewPortExtEx(DC, ILargura, IAltura, nil);
SetViewPortOrgEx(DC, 0, 0, nil);
CarregaPagina('C:\PASTA_G\GED\LIVRO2\0001','0010020.'+ FormatCurr('000',i),IntToStr(i));
Printer.Canvas.Font.Name:='Times New Roman';
if i mod 2 = 0 then
begin
WPPDFPrinter1.Canvas.Font.Style:=[]; //decimo sexto
WPPDFPrinter1.Canvas.Font.Size:=12; //decimo sexto
WPPDFPrinter1.Canvas.TextOut(Trunc(((3.37/2.54) * ResolucaoImpressao1 )* ReducaoL)-120, Trunc(((4/2.54) * ResolucaoImpressao1)* ReducaoA)+10, FormatFloat('###,###',StrToInt(copy('1002',1,6))));
end else begin
CarregaPagina('Z:\PROGRAMA\','Frente2',IntToStr(i+1)); // Decimo
WPPDFPrinter1.Canvas.Font.Name:='Times New Roman';
WPPDFPrinter1.Canvas.Font.Style:=[]; //decimo sexto
WPPDFPrinter1.Canvas.Font.Size:=12; //decimo sexto
WPPDFPrinter1.Canvas.TextOut(Trunc(((3.40/2.54) * ResolucaoImpressao )* ReducaoL)-120, Trunc(((4/2.54) * ResolucaoImpressao)* ReducaoA)+10, FormatFloat('###,###',StrToInt(copy('1002',1,6))));
end;
WPPDFPrinter1.EndPage;
end;
WPPDFPrinter1.EndDoc;
end;
Alles anzeigen