WPCubed Product Support

Printing issues, Images not printing

With this code below, i can open a file into a visual editor (stock placed component no modifications) and send it to a printer and everything prints fine

Var  vEditor: TWPRichText;begin  vEditor := TWPRichText.CreateDynamic;  try    vEditor.PrinterSetup;    editor.SaveToStream(FStream);    if FStream.Size > 0 then    begin      FStream.Position := 0;      vEditor.LoadFromStream(FStream);      vEditor.PrintParameter.PrintOptions := vEditor.PrintParameter.PrintOptions + [wpAlwaysHideFieldmarkers];      vEditor.Print();      vEditor.Clear;    end;  finally    FreeAndNil(vEditor);  end;

AND!

Var
  vEditor: TWPRichText;
begin
  vEditor := TWPRichText.CreateDynamic;
  try
    vEditor.PrinterSetup;
    editor.SaveToStream(FStream);
    if FStream.Size > 0 then
    begin
      FStream.Position := 0;
      vEditor.LoadFromStream(FStream);
      vEditor.PrintParameter.PrintOptions := vEditor.PrintParameter.PrintOptions + [wpAlwaysHideFieldmarkers];
      vEditor.Print();
      vEditor.Clear;
    end;
  finally
    FreeAndNil(vEditor);
  end;

BUT!

When the same code is executed via a service on a remote machine, the printing does not print out any headers at all.

Any ideas on why this would be the case ?

The only difference on the server side the data is streamed from a TBlobfield into a memory stream then the same process is followed to print a document and the printer to send to is returned dynamically from a database.

Any particular reason why this would not print out a documents headers ?

(Yes the physical printer is setup correctly)

#1 ♥ 0
4.5k Views 2 users read 3 min
support

Hi,

there is a "WithClear = true" missing:

vEditor.LoadFromStream(FStream, true);

#2 ♥ 0

That doesnt make a difference, it still prints out a document that contains no images in the header.

this appears to only happen when running a service.

If we run this as an application, there is no problems.

************ EDIT ****************
ALSO note that when trying to convert to PDF using TWPPDFExport first then opening the PDF in a viewer the images are not printed as well.
Also without alling ReformatAll(True, False), the method pdfExport.Print will access violate in a service.

var
  pdfExport:  TWPPDFExport;
  vCount:     Integer;
begin
  try
    pdfExport := TWPPDFExport.Create(nil);
    pdfExport.InMemoryMode := True;
    pdfExport.Filename := Copy(inFilename, 1, Pos('.', inFilename)-1) + '.pdf';
    pdfExport.Source := inEditor;
    pdfExport.Source.ReformatAll(True, False);
    pdfExport.PageCount := pdfExport.Source.CountPages;
    pdfExport.Print;
  finally
    FreeAndNil(pdfExport);
  end;
#3 ♥ 0
support

Hi,

this could have various reasons, for example that the images cannot be accessed when the app is run as a service.

The only difference on the server side the data is streamed from a TBlobfield into a memory stream then the same process is followed to print a document and the printer to send to is returned dynamically from a database.

While debugging this I reccomend to dump a copy of the dara to a file using SaveToFile('c:\temp\databolb.wpt')

Julian

#4 ♥ 0
This category is archived. No new posts are possible.