Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Convert reports graphic type

edited December 2003 in General
Hi,

I now store all graphics in JPEG format. I have modified the appropriate
areas, but what is the best way to modify reports stored in rbItems so that
graphics are set to JPEG rather than BMP.

Thanks

Alex

Comments

  • edited December 2003
    Hi Alex,

    You will need to edit your report templates manually either using the Report
    Designer and saving them back to the database or editing them as text using
    a technique similar to the one used in the example below.

    http://www.digital-metaphors.com/tips/EditTemplatesAsText.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2003
    Hi Nico,

    Thanks for the info, it has helped alot. I have implemented code to modify
    templates but the result comes up with a stream read error when I try to
    view it from my app. I have in fact done the following expecting the saved
    result to be the same as the original as I do not make any changes other
    than reading then writing it back (for testing purposes).

    plItem.GetFieldAsStream('Template', lBinaryStream);
    lBinaryStream.Position := 0;
    ObjectBinaryToText(lBinaryStream, lTextStream);
    lTextStream.Position := 0;
    thisList.LoadFromStream(lTextStream);
    lTextStream.Position := 0;
    thisList.SaveToStream(lTextStream);
    lTextStream.Position := 0;
    ObjectTextToBinary(lTextStream, lBinaryStream);
    lBinaryStream.Position := 0;
    plItem.Edit;
    plItem.SetFieldFromStream('Template', lBinaryStream);
    plItem.Post;

    Before these process changes the reports can be accessed, after running the
    process I get a streaming error. is there something I am missing? I am
    using DBISAM, maybe that has something to do with it?

    Thanks

    Alex

  • edited December 2003
    Hi Alex,

    Sorry for the delay in this response. It took a little research to find the
    problem. For this to work with DBISAM, you need to write an extra EndList
    indicator following the ObjectTextToBinary call. Change your code below to
    look something like this and see if that helps.

    var
    lWriter: TWriter;

    plItem.GetFieldAsStream('Template', lBinaryStream);
    lBinaryStream.Position := 0;
    ObjectBinaryToText(lBinaryStream, lTextStream);
    lTextStream.Position := 0;
    thisList.LoadFromStream(lTextStream);
    lTextStream.Position := 0;
    thisList.SaveToStream(lTextStream);
    lTextStream.Position := 0;
    ObjectTextToBinary(lTextStream, lBinaryStream);

    lBinaryStream.Seek(0,soFromEnd);
    lWriter := TWriter.Create(lBinaryStream, 1024);

    try
    lWriter.Root := Self;
    lWriter.WriteListEnd;
    finally
    lWriter.Free;
    end;

    lBinaryStream.Position := 0;
    plItem.Edit;
    plItem.SetFieldFromStream('Template', lBinaryStream);
    plItem.Post;


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.