GetPageAsMetafile

  • Hello Julian,
    In TextDynamic, to get a graphical presentation of page, we have to use Memo.GetPageAsMetafile. But it is very difficult to work with Metafile format.

    In the WPTools there is a perfect possibility to print a page on any canvas:
    Memo.PaintRTFPage(Pg, 0, 0, Bmp.Width, Bmp.Height, Bmp.Canvas);
    Is it possible in the TextDynamic?
    Or is there any other solution to get the page at last as Bitmap?

    Thanks,
    Konstantin

    • Offizieller Beitrag

    Hi Konstantin,

    I could implement GetPageAsPNG if this would help.

    The problem with the metafiles is probably that they are standard EMF but .NET expects EMF+, which is unfortunately an undocumented format and only partly backwards compatible to EMF. (EMF+ uses GDIComments to store additional data, so a EMF+ file can be seen as EMF, but vice versa information is missing)

    Printing on a HDCU would also be possible of course.

    What do you need to do - create bitmaps only?

    Julian

  • Hi Julian,
    Great, that is a very good news!
    But in any case could you pls implement GetPageAsPNG method or Printing on a HDCU , this will be more flexible for us (developers) in case we have to create specific tiff files (or any other formats) by own. Because there are situations, when you need a very specific tif file (with certain dimension, resolution, compression, with certain tags specific values, color bitdepth and so on)(for example if you have to send this tif file to specific fax card/service for transmission).
    Thanks in advance, Konstantin.

    • Offizieller Beitrag

    Hi,

    I implemented TIFF, BMP and PNG export.

    Commands to control the bitmap export:

    21: Set the export resolution to the value of param. The default is 200 dpi. Please avoid too large values if you war exporting color images. The memory consumption of the working bitmap is huge. (The string parameter is ignored)

    22: Select the bit count. param=1 select monochrome (=default), param=2 selects 24 bit color. (The string parameter is ignored)

    23: Export one page to a BMP file. param=page number (0..), the string param is the filename

    24: Export one page to a PNG file. param=page number (0..), the string param is the filename

    Code
    private void button1_Click1(object sender, System.EventArgs e)      {         wpdllInt1.Memo.TextCommandStr(24, 0, @"c:\Page_one.png");      }


    TIFF Export:

    TextDynamic: requires "Premium" or "Server" License!
    wRTF2PDF TextDynamic Server: requires "Server" License!


    25: Start a new TIFF file - the string parameter contains the file name. Result = "OK" if successful, otherwise an error message.

    26: Closes the current TIFF file. If successful, the page count is returned.

    27: Exports one page in the current TIFF file. If successful "OK" is returned. Otherwise the result string is empty or an error message. It uses the parameters defined with the commands 21 and 22. By default the resolution is 200 dpi, monochrome.

    This example exports the complete document into a single TIFF file.

    Note: It is possible to load a different document and export pages into the already opened TIFF file.

  • Hello Julian,
    Thanks for updates. Testing them right now.
    Could I suggest some more things? :)

    1) Now it is possible to export page as BMP and PNG to file.
    Is it possible to prevent working with files and get page as System.Drawing.Image object. (Because now I have to export first to temporary file at hard drive, than load again)

    2) It has to be possible to set different resolution for X and Y.

    Thanks a lot for your efforts.
    Konstantin.

    • Offizieller Beitrag

    Hi,

    Did You also try the TIFF export? It was the main work to implement it.

    1) Working with System.Drawing.Image could be added in future by passing a PNG memory block. But this is much more complicated.

    2) It has to be possible to set different resolution for X and Y.

    I have not tried. It should be possible since this is like skaling. I check it when I have time.

    Julian

    • Offizieller Beitrag

    Hi,

    thanks for the test.

    There is an update now:

    Use Command 21 to select X and Y resolution:

    Memo.TextCommandStr( 21, XRes + YRes*10000, '')

    I fixed the monochrome TIFF export and colored text will be also printed black.

    I cannot set the resolution in the created files. The resolution values are used to set the dimension of the bitmaps.

    Julian