#1 Re: GDI+ » Draw and scale EMF to TImage.Canvas does not show text » 2019-07-23 10:06:46

Hi to all.

I tested some other options to solve the problems:


1. Windows-GDI-functions "SetStretchBltMode" and "StretchBlt"
2. GDI+ API by http://www.progdigy.com
3. Resample with GraphicEx-Unit by Mike Lischke


To use these 3 options the EMF-Files must be converted to Bitmaps first.
The converted Bitmaps can be scaled in a very good quality with all 3 options!

Unfortunately the conversion from EMF to Bitmap lasts up to one second, depending
on the size and content of the source-EMF-Files.
(In my tests the source-EMF-Files must be converted in original size to keep the quality.)
After the conversion the scaling-process of option 1. and 2. is very fast.

The scaling/resampling-process of option 3. with GraphicEx lasts sometimes
up do 2 seconds for each Bitmap.

So the good thing of all 3 options is, that every EMF-File can be scaled in a
very good quality. I get no problems or error-messages. All files I tested work
fine. And all works fine on all Windows-Systems (Windows XP, Windows 7, Windows 10).

But the disadvantage is, that this 3 options take to much time for processing.

Using SynGdiPlus I can scale the EMF-Files directly (no need to convert to Bitmap)
and the scaling-process is very fast und result in a very good quality.
So I would prefer to use SynGdiPlus.
But unfortunately I get all the described problems and errors.


Somebody out there with any ideas to this?

#2 Re: GDI+ » Draw and scale EMF to TImage.Canvas does not show text » 2019-07-17 10:18:04

Thanks for your answer.
Here some more information about my tests:

I'm testing on 32-Bit-Windows-XP (I have to...) and on 64-Bit-Windows-7

On my 32-Bit-Windows-XP-PC I get several error-messages testing different emf-files:
- with some emf-Files the text is not shown  (see my first post and the link to the example-file which can be downloaded from mediafire)
- some emf-files the graphic is not shown collectly
- some emf-files result in an divide by zero error and nothing is shown

On my 64-Bit-Windows-7-PC there is just one Problem:
- with some emf-Files the text is not shown (see my first post and the link to the example-file which can be downloaded from mediafire)

The same emf-files which causes the problems on the XP-PC are shown correctly on the Win7-PC.
So I think the reason is a newer GDIPLUS.DLL.

But all files which causes problems with the code from my first post from SynGdiPlus are shown correctly and with very good quality
if I open them with windows-paint, windows-picture and fax viewer, EMFExplorer or IrfanView! Even on my XP-PC!
And I think all these tools also use GDI. So the GDIPLUS.DLL on my XP-PC should be ok.

It's all a little bit frustrating...

@ab: did you have some time to test my emf-file?

#3 GDI+ » Draw and scale EMF to TImage.Canvas does not show text » 2019-07-05 11:48:56

DonMartin
Replies: 3

Hello,

I'm using Delphi 6 and I try to draw EMF-Files on a TImage.Canvas. I use the newest SynGdiPlus.pas. I just added the Unit to the uses-part.

I try the following code:


var 
   MF: TMetaFile;
   Rect1: TRect;
begin
   Gdip := TGDIPlusFull.Create;
   MF := TMetaFile.Create;

   MF.LoadFromFile('Test_Synopse.emf');

   Rect1.Left := 0;
   Rect1.Top := 0;
   Rect1.Right := Image2.Width;
   Rect1.Bottom := Image2.Height;

   Gdip.DrawAntiAliased(MF, Image2.Canvas.Handle, Rect1);   

   MF.Free;
   Gdip.Free;
end;


Most files work fine with this code. Some Files are shown just with the Lines included but not with the Text included.

Here one of the problem-files could be downloaded:
http://www.mediafire.com/file/f64b3f84k … e.EMF/file

If this file is drawn on the Image2.Canvas with the code above you can not see any text.
Somebody knows what I am doing wrong?

My second question:
The last line in my code above (Gdip.Free) results in an exception. Somebody knows why?

Thanks
Don

#4 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-07-14 08:29:53

Thanks again for your support so far!

I'll go on looking at the changes and there are a lot of features,
except this pdf/a-stuff, that are very usefull.
It's still a great project!

#5 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-29 08:54:31

you're right, it's all very confusing, even to me. but I didn't know this at the beginning
of my posts. so, sorry for that.

I was just looking for a way to create PDF/A.
And cause it's for a commercial product of my company I am responsible for the
new changes and so I decided to check and test all changes before they could
be released in the new version.

I didn't know much about PDF/A before this and I really didn't know that
different validation-tools for PDF/A seem to validate not in the same way.

So unfortunately you made some modifications on account of my former questions,
that now seem to be made in vain. That was not my intention. So sorry, again.

As I realized that those validation-tools didn't work the same way, I decided to
consider only one of them. So I choosed the "pdfToolbox" from Callas-Software,
cause they made the Preflight-Functions for Adobe Acrobat and I think they really
must have the knowledge to validate PDF/A.

So the last validation-results from "pdfToolbox" are the only ones we have to
look at. And I think if the PDF/A-Files from PDF Engine passes the validation
of "pdfToolbox" without errors everything really must be ok.
And you can be sure, that I will not test any other tool...  :-)

Additional to the validation-problem there is still the problem with the Logo,
which is not visible after conversion... Hope there will be also a solution for this.

So I hope you understand that I didn't want you to make needless changes.  :-)
I also just needed some time to understand all this pdf/a-stuff.

I really still prefer to use the PDF Engine for the changes in our product.

#6 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-28 12:37:23

Did you have time to look at the validations and
are you planning any changes for the pdf/a-problem?

Sorry for asking again...   :-)

#7 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-22 14:32:26

Something I forgot:
If there are too many problems with "PDF/A-1a"-Format, maybe it's possible to just create "PDF/A-1b"-Files with PDF Engine?
Maybe this is easier to do and the validation will succeed...

#8 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-22 14:23:45

ok, I finally tested the PDF-Files with "pdfToolbox" from Callas-Software:

The PDF-Format is detected as "PDF/A-1a" and the validation shows 4 errors in both tested files.
(same files as I described in my last post)

You can download the results here: http://www.divshare.com/download/15153187-774
(sorry, it's all in german)

I think the validation with "pdfToolbox" from Callas-Software must be the only one, which we have to believe,
cause they made the Preflight-Functions for Adobe Acrobat.
So the online-validation and the validation with Intarsys-Software seem to be not working correct.

I checked also PDFCreator with "pdfToolbox": The detected Format here is "PDF/A-1b" and validation runs without any problems.
(and no problems with the logo here)

I still would rather use your PDF Engine before having to use the external PDFCreator. The PDF/A-Format is
also better than in PDFCreator.
Maybe the results of my test with "pdfToolbox" give you some hints for not noticed bugs in the PDF Engine?

If you make some changes in PDF Engine: My Demo-Version of "pdfToolbox" ends in 14 days from today.
After that I can't validate any more except I would buy the full version.

#9 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-21 09:36:42

I tested all with your newest SynPdf.pas (which works with online-validation)

You can download the results of the tests with the Intarsys-Software (CABAReT Stage 5.1)
here: http://www.divshare.com/download/15145237-53c

I zipped two Screen-Shots of the validation-results:

1.  Converting my Test-EMF-File with your example-code you first send me (where I got the EZeroDivide-Exception first
     and where now the logo isn't displayed)
     This Screen-Shot named "intarsys_validation_RenderMetaFile.bmp" (cause of the usage of "RenderMetaFile")

2.  Testing your example with "ExportPDF" of SQLite3Pages.pas (http://synopse.info/forum/viewtopic.php?pid=1304#p1304) as I wrote.
     This Screen-Shot named "intarsys_validation_ExportPDF.bmp"


I now read that the "preflight" - Function of Adobe Acrobat Prof. (Adobe-Validation of PDF/A) was originally from
Callas-Software (http://www.callassoftware.com) and so I downloaded a DEMO-Version of "callas pdfToolbox 5!"
to validate the files again.

But this is the last "validation-thing" I will do. If I just get this logo visible I really want to use the PDF Engine
whatever validation-results are coming...   I think the PDF/A - Format will anyway change from time to time and
all must be constantly adapted.

#10 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-20 16:33:16

Many thanks to your changes to SynPdf.pas!!

And yes, I think you could be very proud of this open source project and all the other synopse-projects!! :-)

So the online-validation of pdf/a-files created with "ExportPDF" of SQLite3Pages.pas works fine!
And I don't get any more EZeroDivide-Exception with "RenderMetaFile". But, as you say, the logo of my example-file
is not displayed.

I'm testing also the tool "PDFCreator" to create PDF/A - Files but the online-validation of those files also failed.
And I don't want to use another external software, I really would like to use your PDF Engine!

To get sure that the online-validation works correct, I looked for another possibility to check this and I found a
tool named "PDF/A Live!" here: http://www.intarsys.de/produkte/pdfa-live
(Download-File: http://www.intarsys.de/misc/downloads/s … 5.1.2.exe)

This Tool says that the PDF/A - Files created by "PDFCreator" and created by your PDF-Engine are both not PDF/A-Conform.

Maybe I shouldn't believe all this validation-stuff....

If this is ok for you I want to explain the whole problem:

I'm working on a Delphi4-Project in which you can do 3 several print-outputs:
1. Printing with an ActiveX-Component "THighEditPro". It's from Heiler-Software (http://www.heiler.de)
    This component is no longer supported from Heiler-Software since 1999 (!!) but I still have to handle it.
     (and still have to do this in a Delphi4-Project...)
2. Printing with Word over OLE-Automation (--> Word_TLB.pas)
3. Printing with QuickReport

So in 2004 I had to find a solution to archive all printed documents. I found the vprinter-component of mabuse.de
and I thought it's the easiest and best way to "grab" the emf-files out of the spool-files after being send to the printer.

All this works fine all the years. (the fact that I used the emf-format is just because those format is saved within the spool-files)

Now the archived documents should also be saved in other formats like TIF and PDF/A. So that's the reason I'm "ending" here...   :-)

If there is another way (without vprinter) to directly save all print-output above in MetaFiles, I would do so.
But I don't know how to do this. QuickReport uses MetaFiles internal (as you also wrote here in the forum),
but HighEditPro doesn't. And I don't know if I could save Word-Dokuments over OLE directly in EMF or PDF/A...

So this is the problem. Maybe there's another solution with "RenderMetaFile" so that the logo in my emf-example-file
is displayed. Then I could use vprinter in combination with PDF-Engine to solve all problems.

If all would be ok, I want to create a Delphi6-DLL to call from the Delphi4-Projekt. (cause PDF-Engine doesn't work with delphi4, as
mentioned here in the forum)

So if you have any ideas, let me know...   :-)

#11 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-17 11:32:25

@ab:

I'm trying to use your example creating pdf/a with "ExportPDF" of SQLite3Pages.pas
see: http://synopse.info/forum/viewtopic.php?pid=1304#p1304

I activated the last two lines and deactivated "ShowPreviewForm"
For testing I activated also the pdf-export-options above.

A PDF-File is created but if testing it online on http://www.pdf-tools.com/pdf/pdfa-online-pruefen.aspx
it says that it's no PDF/A - Format!

What's wrong here?  ("ExportPDFA1" is set to "True")

I'm a little confused now...

#12 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-16 08:38:15

Converting to JPG and TIFF works fine now with the global SaveAs() procedure (Sometimes I'm a little too blind...)

I have also no problems now with BMP-Size-Handling...

But I do still get the EZeroDivide-Exception when trying to convert to PDF/A    :-(
TGDIPlusFull.Create is only once called in your example-project "TestSynGdiPlusMain" (I didn't change the code)

Did you have time to look at my example-emf-file?

Thanks again!

#13 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-14 13:20:26

I think I could fix the bugs from Virtual Printer. I had some conversation with mabuse.de in 2004 telling
them about the bugs and they wanted to fix the code if they get time...
So obviously they hadn't the time till today...

EMF to PDF/A - Error:
If this helps: I get the same error starting your example-project "TestSynGdiPlusMain". I think the problem
is "FormCreate" in line "Gdip := TGDIPlusFull.Create('gdiplus.dll');"
There are several versions of this file on my xp-machine. Maybe this is a problem?

Another question(s) to creating BMP/JPG/TIFF:
I'm trying to convert my TEST.EMF - File to BMP with the functions of SynGdiPlus.pas.
My Code:

   MF := TMetaFile.Create;
   MF.LoadFromFile('TEST.EMF');
   Bmp := Gdip.DrawAntiAliased(MF, 100, 100);
   Bmp.SaveToFile('TEST.BMP');

A correct BMP-File is created but it's size is more than 30 MB. This is of course to big.
(Converting with "normal" Delphi-Units I get a 5 MB - BMP-File.) Probably I did someting wrong again? :-)

How do I convert to JPG and TIFF with SynGdiPlus?  Do you have any examples?

Sorry for asking so much...

#14 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-14 08:10:13

I create EMF-Files mit Parts of the "Virtual Printer" from mabuse.de (http://www.mabuse.de/tech-vprinter.mhtml)

I use this since 2004 in a Delphi 4 - Projekt. I use only parts of Virtual Printer and as I downloaded
it in 2004 some of the parts were buggy. I fixed all parts I needed and all works great.

You have to set the print-processor of any printer-driver to emf-output and so with the parts of Virtual Printer
you can "filter" the emf-files out of the spool-files.

We use this to archive documents in our software.

The new request is to save those documents also in other formats like, JPG, TIFF and PDF/A.
So I found your PDF-Engine.
(Maybe I should use your GDI+ to create TIFF or JPG? Is it better than the "normal" components from Graphics.pas or jpeg.pas?)

In my example-emf-file is a little picture and some formatted text. I can open it with EmfExplorer without problems.
You can download the emf-file here: http://www.divshare.com/download/15093007-80e

Thanks!

#15 Re: PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-10 14:20:11

Thanks a lot for the code!

I'm trying it with an example emf-file, but I get an EZeroDivide-Exception
in procedure "ScaleMatrix" in SynPdf.pas

I just replaced the var "aMetaFileName" with a full path to my example-emf-file.

I didn't change anything else from your code.

Don't know what I'm doing wrong?
Maybe this is the same problem: http://synopse.info/forum/viewtopic.php?id=257   ?



PS: God save the MPL license!  :-)

#16 PDF Engine » Convert EMF-Files to PDF/A-Files in Delphi 6 » 2011-06-09 07:05:44

DonMartin
Replies: 20

Hi to all,

I'm new to the PDF Engine and it looks like a really great
component!
One of the best components you can get for free, I think.

(Is it correct, that you can use it for free even in
commercial projects?)

I'm now looking for code-examples to convert EMF-Files to PDF/A-Files in Delphi 6

Maybe somebody has an example for this?

Thanks in advance!

Don

Board footer

Powered by FluxBB