Pasting an image into UseDefEditor

  • I was hoping that I could just copy and paste some text and a graphic in from Word and when I save it, it would be a compressed image. I see my users wanting to do this a lot.

    The resulting image + text = 112KB.
    In Word the .dot with it in is about 30KB, so I am guessing it is being stored as an uncompressed bitmap.

    Is there something I can do before saving the text in userDefEditor.pas to convert to a png?

    Regards,

  • <bump> as they say.

    i am trying to get a number of documents live and they are still 120K+ instead of 30K+ and people are about to start producing large numbers of documents based on these templates.

    Cheers,

    JAC.

  • Julian,

    I have 5.23.6 standard and have rebuilt UserDefEditor.dpr with wpobj_image.pas added to teh uses of the project (i.e. in UserDefEditor.dpr).
    I have loaded my RTF and saved as and it is still 115KB for a doc header, which seems far too high.

    When you said

    Zitat

    In the altest wptools image unit

    Is this in your latest of the release that I have?

    Basically they we can't afford for all the documents to be 120+KB.

    Regards,
    Jason Chapman.

  • I have sent you the test file.

    I can't remember how I embedded the image, probably edit copy and edit paste from a word document or a graphics package.

    Zitat

    assume the problem is a bitmap. If you use PNG images this will be also compatible. You can use PNGLib to use PNG images in WPTools.


    When I went Insert Image and selected a png file, gave me an exception.

    Zitat


    Please see the notes in unit WPObj_image.


    I have, but have always been reluctant to change 3rd party or VCL code. I did add the unit to the project WPOBJ_Image, but did not add any defines.

    Is the following correct:
    If I have an rtf with embedded images and want my program to do mailmerge and save compressed images I need to:
    Add WPObj_image to my application (although this on its own doesn't work with example program userdef....).
    --- Do I also need to add {$DEFINE something in my project file?

    Sorry for being dense.

  • I think I see now. I try to avoid digging around in components, but I can see the power that having these compiler options give.

    So general advice. For a company logo, would you recommend:
    COMPRESSBITMAPASJPEG
    PNGIMG
    GRAPHICEX

    And I am assuming I will need to download and install additional components to use
    PNGIMG or GRAPHICEX

    I have not used either library and would prefer not to have to unless required. Am I on the right track?

    Regards,

  • OK, I tried adding:
    {$DEFINE COMPRESSBITMAPASJPEG}
    {$DEFINE PNGIMG}

    To the beginning of the Project unit and rebuild, and it has made no difference to the size of the file when I load & save, load, cut image, paste it back in and save.

  • But the notes in the pas file say that if you add {$DEFNIE COMPRESSBITMAPASJPEG} then it will save them compressed.

    The userdefEditor does not allow me to select a PNG, even if I change the filter. I changed the "acceptFiles" of the WPRichText to true.

    The top of the project unit looks like:

    If I drag a png, nothing gets pasted in, if I drag a text file, it works fine. So I am still doing something wrong?
    [/code]

    • Offizieller Beitrag

    Hi,

    With Delphi compiler defines are only valid in the unit which is currently beeing compiled.

    So the $defines you make here are not know when the compiler works on WPObj_Image.

    You need to either add those defines to WPINC.INC or, better, add them under "Conditionals" in the options dialog of your project. After doing so make sure to make a "Build all".

    Julian

  • Silly me, should have realised that.

    I added COMPRESSBITMAPASJPEG to the project | Options | Conditional and now get a much better 15KB.

    When I did the same for PNGIMG it obvioulsy wanted the units that I need to download from sourceforge etc.

    I think JPG may be all we need (although I need to print out on their hi-res printers to ensure quality is OK).

    What might be useful would be a demo, demonstrating how to enable these features (even though some of it is not a WPTools issue e.g. defines).

    Also any tweaks to change the default compression of the JPG's.

    So now I have my mailmerge tool that handles:
    - sections that can be optional / mandatory choices o-n, 1-n, n.
    - Includes
    - nested fields (e.g. <vatdescription> -> "VAT NUMBER:<subtrust>" -> "VAT NUMBER: 012589388"
    - Tables with n rows fileld from a query.

    Thanks for your help and patience. Next is embedding fields that ask the user for input and save just the data that the user entered. I might do a talk for UKBug RE: what little I have learned about WPTools later in the year.
    Regards,

  • OK, so I opened the champagne too early. The letters actually end up being saved and users open them in Word and often print them from there. I currently have 2 problems and a question:
    1) The JPG has "fluffy" edges, which I should have guessed would happen. So I will try the PNG. I have opted for the PNG only library from sourceforge. I use envision components that also handle PNG, but I am guessing
    2) Will Word handle the PNG format with the RTF extension?
    3) When we print to one of our big printers, we have to adjust the contrast in Word for the image. Normally to 51% from 50% - it stops a very light grey background. It must eb a bug in one of the printers driverset as it doesn't happen on the other printer. When I saved a JPG I got the same thing. Can you adjust the contrast with PNG's - my guess is they have no concept of contrast.

    Regards,

  • And another observation. If I produce a PNG'd rtf and open in word and then save it leaps from 30KB -> 226KB. This causes us another problem as once the letters are produced, they may be edited by the user and they would probably do that in Word.

    Anyway, I think we are as far as we can get unless you have any other suggestions.

    I can build all the templates using RTF & PNG. I can produce letters and save as small files. We will have to live with the fact that one of the printers will not be able to be used and that if the file is subsequently edited in Word it becomes 6 times larger.
    Regards,

    • Offizieller Beitrag

    Hi,

    >>1) The JPG has "fluffy" edges, which I should have guessed would happen. So I will try the PNG. I have opted for the PNG only library from sourceforge. I use envision components that also handle PNG, but I am guessing <<It>>2) Will Word handle the PNG format with the RTF extension?

    Yes, PNGImage are defined for RTF and very comon.

    >>3) When we print to one of our big printers, we have to adjust the contrast in Word for the image. Normally to 51% from 50% - it stops a very light grey background. It must eb a bug in one of the printers driverset as it doesn't happen on the other printer. When I saved a JPG I got the same thing. Can you adjust the contrast with PNG's - my guess is they have no concept of contrast. <<I> 226KB. This causes us another problem as once the letters are produced, they may be edited by the user and they would probably do that in Word. <<

    Yes, Word will store then PNG and another copy (hex encoded!) as BMP or metafile. But I think this also happens when using JEPG. There is no way to avoid this in Word as far as I know.

    Kind Regards,

    Julian

  • Hi Julian, it's been a while as they say. They have been using the system with the 32 letters I put in there, but I think we are about to have a big push at getting more letters / reports in.

    One of the problems I have at the moment is back to the company logo at the top of the page. They actually use word to print the documents we produce and they may tweak the letter and re-save it, so the letter goes from 30K -> 300K (in fact 500K in office 2007).

    You said:

    Zitat

    Yes, Word will store then PNG and another copy (hex encoded!) as BMP or metafile. But I think this also happens when using JEPG. There is no way to avoid this in Word as far as I know.

    Do you have any further thoughts on that. Basically we:
    - take an RTF file produced in WPTools editor
    - include other files, all of which are from WPTools editor (one has logo and header)
    - save RTF file.
    - Launch in word
    - they normally just print and close, but often tweak / save it.

    In a month we start doing print runs of 1500, so worse case scenario, the storage goes from 30 x 1500 = 43MB -> 732MB for that one run.

    Do you have any ideas.
    Users are using a mix of Office 2003 / 2007.
    TIA.
    Jason