#1 2020-05-27 09:35:53

Registered: 2014-07-19
Posts: 36

Problems with generated PDF in Adobe

in my project I use mORMotReport + SynPdf for generate output into PDF. The resulting PDF is rather complicated - with many drawings, several fonts, images, tables etc.

Everything worked fine till the last week.

Last week my client reported  some errors that occured when  he tried to print the generated pdf in Adobe Reader; he also reported another problem of incomplete drawing.

When I tried to print/display/analyze the generated PDF in other softwares (Edge, Mozilla, XFINIUM.PDF, Winking PDF analyzer) there was no error.

When analyzing the generated PDF in Adobe Acrobat DC - preflight module  I have found three unusual problems:

1) General File/Format error  The key /First must be present when key /Count is used
this error was caused by this part !!

1 0 obj
<</Type/Catalog/PageLayout/SinglePage/Outlines 2 0 R/Pages 4 0 R>>
2 0 obj
<</Type/Outlines/Count 0>>

To avoid this error I have set

UseOutlines := false;

2) when I checked the incomplete drawing I found out  there are at  no PDF syntax error on the page, however the list of the used fonts contains entries for Courier font ( which is not used in my PDF at all) and the texts that were reportedly using Courier were missing in the incomplete drawing
From this I have inferred that Adobe requires explicit setFont  in front of each text element now - this requires a small change in TPdfCanvas.SetPDFFont procedure

procedure TPdfCanvas.SetPDFFont(AFont: TPdfFont; ASize: Single);
  // check if this font is already the current font
  //  if (AFont=nil) or ((FPage.Font=AFont) and (FPage.FontSize=ASize)) then         <-- commented
  //    Exit;                                                                        <-- commented
  // add this font to the resource array of the current page
  if FPageFontList.ValueByName(AFont.ShortCut)=nil then
    FPageFontList.AddItem(AFont.ShortCut, AFont.Data);
  // change the font
  if FContents<>nil then
    SetFontAndSize(AFont.ShortCut, ASize); // e.g. SetFontAndSize('F0',12)
  FPage.Font := AFont;
  FPage.FontSize := ASize;

this change helped

3) the third reported warnings are of type Invalid content stream state (PathObject) for operator
and the mentioned operators  are:  Tf, Tw, rg and BT. I have no clue what is the problem.
For the reference I give the code which matters:

/F1 14.04 Tf
0.18 Tw
0.28 0.17 0.42 rg
28.32 800.36 Td
(Project: project 1) Tj


Board footer

Powered by FluxBB