#1 2016-01-19 16:22:16

betoneto.tbo
Member
From: Brasil
Registered: 2011-05-10
Posts: 29

PDF render error

My application generate EMF images and I render them into PDF using RenderMetaFile function.

Sometimes, not every, the resulting pdfs have render problems, normally when they contains images/logos.

Below 2 PDFs with the problem. They only work inside Chrome. Using another reader like Acrobat Reader they dont present errors.

  https://dl.dropboxusercontent.com/u/697 … %20151.pdf

This is the EMF source:

  https://dl.dropboxusercontent.com/u/697 … 0147-2.emf

I tried EMFExplorer, but I have no idea how to use it and what I need to search for.

Offline

#2 2016-01-19 16:30:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: PDF render error

I guess this is the forum thread for http://synopse.info/fossil/info/c20cbac8d43

Try to find out, using EmfExplorer, which EMF_* commands may be faulty.
Once you identified which part of SynPdf needs improvement, we may start looking into it.

How does your application generate the EMF?
Is it a known reporting tool/component?
If there is no image/logo, does it work as expected?
Which version of SynPDF are you using? Current from our source code repository is 1.18.2273.

Offline

#3 2016-01-20 10:26:38

betoneto.tbo
Member
From: Brasil
Registered: 2011-05-10
Posts: 29

Re: PDF render error

ab wrote:

Try to find out, using EmfExplorer, which EMF_* commands may be faulty.
Once you identified which part of SynPdf needs improvement, we may start looking into it.

I don't known how to do that, this is because that I'm here!

ab wrote:

How does your application generate the EMF?
Is it a known reporting tool/component?

It is generated using delphi native api (TMetafileCanvas, textOut, Draw, etc...)

ab wrote:

If there is no image/logo, does it work as expected?

Yes, it works!

ab wrote:

Which version of SynPDF are you using? Current from our source code repository is 1.18.2273.

I'm using version 1.18.1417.

Last edited by betoneto.tbo (2016-01-20 17:54:53)

Offline

#4 2016-01-20 11:11:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: PDF render error

First of all, try with the latest version.

Then detail how you create the image/logo in your code, using which type.

Offline

#5 2016-01-20 17:53:25

betoneto.tbo
Member
From: Brasil
Registered: 2011-05-10
Posts: 29

Re: PDF render error

I upgraded to the latest version.

But I made some extra changes. I realy think that the faulty is about the image drawing (StretchDraw and different types of image).

I was drawing using the canvas Draw(X,Y,Graphic) and StretchDraw(Rect,Graphic), the images were bitmaps, jpgs, pngs.

Now I changed it to always generate a bitmap with the expected result size and without transparency. Then I draw it (using Draw(X,Y,Bitmap)) to the MetafileCanvas. So now I have only bitmaps in the metafile, so as in the resulting PDF.

I'll let this changes in test in some of my customers, because I wasn't able to reproduce the problem. I'll update this thread with the results in some days.

Last edited by betoneto.tbo (2016-01-20 17:59:03)

Offline

#6 2016-01-20 19:20:03

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: PDF render error

StretchDraw() should not be faulty IMHO, since it is handled by the library.
AFAIK jpeg or png, added via Draw/StrechDraw, would always be stored as bitmap to the MetaFileCanvas.
Transparency is not handled at library level, so it should not be the problem.

We are waiting for your feedback.

Offline

#7 2016-01-26 17:53:47

betoneto.tbo
Member
From: Brasil
Registered: 2011-05-10
Posts: 29

Re: PDF render error

ab, problem solved!

I think the problem was around EMR_STRETCHBLT.

Below the complete solution that worked for me:

betoneto.tbo wrote:

I upgraded to the latest version.

But I made some extra changes. I realy think that the faulty is about the image drawing (StretchDraw and different types of image).

I was drawing using the canvas Draw(X,Y,Graphic) and StretchDraw(Rect,Graphic), the images were bitmaps, jpgs, pngs.

Now I changed it to always generate a bitmap with the expected result size and without transparency. Then I draw it (using Draw(X,Y,Bitmap)) to the MetafileCanvas. So now I have only bitmaps in the metafile, so as in the resulting PDF.

I'll let this changes in test in some of my customers, because I wasn't able to reproduce the problem. I'll update this thread with the results in some days.

Offline

#8 2016-03-11 13:19:08

betoneto.tbo
Member
From: Brasil
Registered: 2011-05-10
Posts: 29

Re: PDF render error

Hi!

I finally found the real BUG.

The problem occurrs when I use this windows API functions over the MetafileCanvas.

CreateRectRgnIndirect
SelectClipRgn

I create my MetafileCanvas setting a custom clip region to draw my stuff, and when I draw some images over the MetafileCanvas the PDF cannot render it correctly.

Here is the sample that reproduces the problem.

https://www.dropbox.com/s/ikoi2dv1wgzbf … g.zip?dl=0

To fix, I just removed my clip region!

Offline

Board footer

Powered by FluxBB