#1 2012-02-09 21:22:03

brk303
Member
Registered: 2012-02-09
Posts: 5

Missing elements

Hi,

First of all, congratulations on a great product.

I wrote a PDF export filter for FastReport using SynPdf. I'm using VCLCanvas and it's really simple to use and works well, but I have a problem with one report, some elements are missing from the PDF. I managed to simplify the report to only 2 text fields and 1 line and the problem is reproducible.

I found out that the metafile that is rendered in TPdfDocumentGDI.SaveToStream is correct. I added code to beginning of TPdfCanvas.RenderMetaFile that saves the metafile to a file and indeed it is correct.
However, the PDF produced from it only contains 1 text element, so another text element and a vertical line are missing. I am not using anything strange, Courier New font, English text.

I wonder if you have any ideas as to what I can try to fix this problem ?

Regards,
Danny

Last edited by brk303 (2012-02-09 21:25:59)

Offline

#2 2012-02-10 06:25:04

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

Re: Missing elements

Please post some code to reproduce the issue.

Or use EmfExplorer - see http://frazmitic.free.fr/emfexplorer/ - to inspect the metafile content.

I did not encounter such a problem yet, so I have to idea when it could come from, expect from a weird metafile content.

Offline

#3 2012-02-10 08:14:49

brk303
Member
Registered: 2012-02-09
Posts: 5

Re: Missing elements

Well I'm affraid the code won't reveal much, as it's a generic FastReport export filter, so what I do is

      TfrxView(Obj).Draw(PdfDocument.VCLCanvas , FDiv, FDiv, 0, FYOffset);

TfrxView being base visual class in FastReport, and the draw method is used for rendering on the screen too.

I downloaded EMFexplorer, and the vmf file displays fine. Here's the EMF as text output if that helps

R0001: [001] EMR_HEADER    (s=108)    {{ Bounds(35,144,759,283), Frame(0,0,27944,39572), ver(0x10000), size(1748), recs(33), handles(6), pals(0), dev_pix(1680,1050), dev_mil(592,370), pixf_size(0), pixf_ofs(0), openGL(0) }}
R0002: [027] EMR_MOVETOEX    (s=16)    { ptl(0,0)}
R0003: [082] EMR_EXTCREATEFONTINDIRECTW    (s=368)    {ihFont(1) ELF[name() style() vendor(0x7E42C2B2)] LOG[face(Tahoma), style(), charset(1),family(0),precision(0), height(-11), width(0)]}
R0004: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 1=OBJ_FONT}
R0005: [024] EMR_SETTEXTCOLOR    (s=12)    {0x00000000}
R0006: [038] EMR_CREATEPEN    (s=28)    {ihPen(2), style(0=PS_SOLID | COSMETIC), width(1), color(0x00000000)}
R0007: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 2=OBJ_PEN.(PS_SOLID | COSMETIC)}
R0008: [020] EMR_SETROP2    (s=12)    {iMode(13=R2_COPYPEN)}
R0009: [039] EMR_CREATEBRUSHINDIRECT    (s=24)    {ihBrush(3), style(0=BS_SOLID, color:0x00FFFFFF)}
R0010: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 3=OBJ_BRUSH.(BS_SOLID)}
R0011: [025] EMR_SETBKCOLOR    (s=12)    {0x00FFFFFF}
R0012: [018] EMR_SETBKMODE    (s=12)    {iMode(2=OPAQUE)}
R0013: [037] EMR_SELECTOBJECT    (s=12)    {Stock object: 13=OBJ_FONT}
R0014: [082] EMR_EXTCREATEFONTINDIRECTW    (s=368)    {ihFont(4) ELF[name() style() vendor(0x0000000F)] LOG[face(Courier New), style(), charset(1),family(0),precision(0), height(-13), width(0)]}
R0015: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 4=OBJ_FONT}
R0016: [024] EMR_SETTEXTCOLOR    (s=12)    {0x00000000}
R0017: [018] EMR_SETBKMODE    (s=12)    {iMode(1=TRANSPARENT)}
R0018: [084] EMR_EXTTEXTOUTW    (s=172)    { TXT=[RUUKKI METALS OY] [exScale(35.238094) eyScale(35.238094) iGraphicsMode(1), Bounds(76,144,203,159)] TxOPT[fOptions(4|ETO_CLIPPED), nChars(16), offDx(108), ptlRef(76,144), rcl(76,144,398,164)] Spacing[8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 => Total(128) =>xPtRefRight(203)]}
R0019: [095] EMR_EXTCREATEPEN    (s=56)    {ihPen(5), style(65792=PS_SOLID | GEOMETRIC | ENDCAP_SQUARE), width(1), brush(0=BS_SOLID, elpColor:0x00000000)}
R0020: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 5=OBJ_EXTPEN.(PS_SOLID | GEOMETRIC | ENDCAP_SQUARE)}
R0021: [027] EMR_MOVETOEX    (s=16)    { ptl(38,280)}
R0022: [054] EMR_LINETO    (s=16)    { ptl(756,280)}
R0023: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 2=OBJ_PEN.(PS_SOLID | COSMETIC)}
R0024: [040] EMR_DELETEOBJECT    (s=12)    {ihObject(5)}
R0025: [037] EMR_SELECTOBJECT    (s=12)    {Stock object: 13=OBJ_FONT}
R0026: [037] EMR_SELECTOBJECT    (s=12)    {Table object: 4=OBJ_FONT}
R0027: [024] EMR_SETTEXTCOLOR    (s=12)    {0x00000000}
R0028: [018] EMR_SETBKMODE    (s=12)    {iMode(1=TRANSPARENT)}
R0029: [084] EMR_EXTTEXTOUTW    (s=304)    { TXT=[C/O RFS RUUKKI POLSKA, UL. WOLOWSKA 18] [exScale(35.238094) eyScale(35.238094) iGraphicsMode(1), Bounds(76,200,379,215)] TxOPT[fOptions(4|ETO_CLIPPED), nChars(38), offDx(152), ptlRef(76,200), rcl(76,200,398,220)] Spacing[8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 => Total(304) =>xPtRefRight(379)]}
R0030: [037] EMR_SELECTOBJECT    (s=12)    {Stock object: 7=OBJ_PEN.(PS_SOLID | COSMETIC)}
R0031: [037] EMR_SELECTOBJECT    (s=12)    {Stock object: 5=OBJ_BRUSH.(BS_NULL)}
R0032: [037] EMR_SELECTOBJECT    (s=12)    {Stock object: 13=OBJ_FONT}
R0033: [014] EMR_EOF    (s=20)    {nPalEntries:0, offPalEntries:16, nSizeLast:20}

Edit:
I have uploaded the wmf and resulting pdf

http://www.2shared.com/file/4I9ptyRe/test.html
http://www.2shared.com/document/XwGoaf7p/test.html

Last edited by brk303 (2012-02-10 08:29:14)

Offline

#4 2012-02-10 09:53:32

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

Re: Missing elements

In fact, I looked at the EMF content, and it had an invalid EMR_SELECTOBJECT entry, referring to an inexisting GDI object.
EmfExplorer just did not show it (since it was invalid), and ignore it.
But this entry was there, and SynPDF was not happy about it. sad

With the previous implementation, such an error did stop the rendering.

I've modified the code so that EMF rendering will not stop TMetaFile enumeration in case of invalid EMF content (e.g. if the EMR_SELECTOBJECT refers to an out-of-range object).

In fact, this is the default behavior of GDI and GDI+ rendering engines (and our SynGdiPlus), so we'll stay to it - may fix issue with some badly formatted objects, just like in your emf content.

See http://synopse.info/fossil/info/574924f044

Thanks for the report - I'm happy helping out!
smile

Offline

#5 2012-02-10 10:29:18

brk303
Member
Registered: 2012-02-09
Posts: 5

Re: Missing elements

Awesome, I can verify it fixed my problem. Thank you for such great support.

Offline

Board footer

Powered by FluxBB