I am using Delphi 7.0 /ADO/MS Access DB.
I need to print some Adobe Acrobat files, which the path to resides in
a database field. Each files uses the same path, just different file
name.
I Then use the following to print:
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString), nil, nil, SW_NORMAL);
to print the files. Which seems to work great when sent to a local
printer. However, to print to a network printer, I sometimes miss some
of the children, or the parent for that matter.
Any help on this would be greatly appreciated!
See entire code below:
procedure TfrmMain.btnPrintParentClick(Sender: TObject);
var
PrintChildren: Boolean;
begin
if FileExists(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString) then
begin
frmData.qryGetChildren.Close;
frmData.qryGetChildren.SQL.Clear;
frmData.qryGetChildren.SQL.Add('Select * From Children Where
ParentId=:AParentId');
frmData.qryGetChildren.Parameters.ParamByName('AParentId').DataType:=
ftInteger;
frmData.qryGetChildren.Parameters.ParamByName('AParentId').Value:=
frmData.tblParents.FieldByName('Id').asInteger;
frmData.qryGetChildren.Prepared:= True;
frmData.qryGetChildren.Open;
if frmData.qryGetChildren.RecordCount > 0 then
begin
if MessageDlg('Print Child Drawings?', mtConfirmation, [mbYes,
mbNo], 0) = mrYes then
PrintChildren:= True
else
PrintChildren:= False;
end
else
PrintChildren:= False;
frmPrinting.Show;
frmPrinting.Update;
Application.ProcessMessages;
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString), nil, nil, SW_NORMAL);
if PrintChildren = True then
begin
frmData.qryGetChildren.First;
while not frmData.qryGetChildren.Eof do
begin
if FileExists(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString) then
begin
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString), nil, nil,
SW_NORMAL);
end //if FileExists(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString) then
else
ShowMessage('CHILD DRAWING : ' + #10#13 + PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString + #10#13 + ' does
not exist!');
frmData.qryGetChildren.Next;
end; //while not frmData.qryGetChildren.Eof do
frmData.qryGetChildren.Next;
end;
frmData.qryGetChildren.Close;
end
else
ShowMessage('PARENT DRAWING : ' + #10#13 + PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString + #10#13 + ' does not
exist!');
frmPrinting.Hide;
frmPrinting.Close;
Application.ProcessMessages;
end;
I need to print some Adobe Acrobat files, which the path to resides in
a database field. Each files uses the same path, just different file
name.
I Then use the following to print:
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString), nil, nil, SW_NORMAL);
to print the files. Which seems to work great when sent to a local
printer. However, to print to a network printer, I sometimes miss some
of the children, or the parent for that matter.
Any help on this would be greatly appreciated!
See entire code below:
procedure TfrmMain.btnPrintParentClick(Sender: TObject);
var
PrintChildren: Boolean;
begin
if FileExists(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString) then
begin
frmData.qryGetChildren.Close;
frmData.qryGetChildren.SQL.Clear;
frmData.qryGetChildren.SQL.Add('Select * From Children Where
ParentId=:AParentId');
frmData.qryGetChildren.Parameters.ParamByName('AParentId').DataType:=
ftInteger;
frmData.qryGetChildren.Parameters.ParamByName('AParentId').Value:=
frmData.tblParents.FieldByName('Id').asInteger;
frmData.qryGetChildren.Prepared:= True;
frmData.qryGetChildren.Open;
if frmData.qryGetChildren.RecordCount > 0 then
begin
if MessageDlg('Print Child Drawings?', mtConfirmation, [mbYes,
mbNo], 0) = mrYes then
PrintChildren:= True
else
PrintChildren:= False;
end
else
PrintChildren:= False;
frmPrinting.Show;
frmPrinting.Update;
Application.ProcessMessages;
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString), nil, nil, SW_NORMAL);
if PrintChildren = True then
begin
frmData.qryGetChildren.First;
while not frmData.qryGetChildren.Eof do
begin
if FileExists(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString) then
begin
ShellExecute( 0, 'print', PAnsiChar(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString), nil, nil,
SW_NORMAL);
end //if FileExists(PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString) then
else
ShowMessage('CHILD DRAWING : ' + #10#13 + PDFPath + '\' +
frmData.qryGetChildren.FieldByName('File').asString + #10#13 + ' does
not exist!');
frmData.qryGetChildren.Next;
end; //while not frmData.qryGetChildren.Eof do
frmData.qryGetChildren.Next;
end;
frmData.qryGetChildren.Close;
end
else
ShowMessage('PARENT DRAWING : ' + #10#13 + PDFPath + '\' +
frmData.tblParents.FieldByName('File').asString + #10#13 + ' does not
exist!');
frmPrinting.Hide;
frmPrinting.Close;
Application.ProcessMessages;
end;