You are not logged in.
Pages: 1
PDF Engine 1.15
I`m creating a PDF GDI and saving to a stream. During the save progress, a access violation occours (accessing a NIL value)
I have done a workaround (but I dont known if is correct) in SynPdf.pas added after line 3047:
procedure TPdfDictionary.AddItem(const AKey: PDFString; AValue: TPdfObject;
AInternal: Boolean);
var FItem: TPdfDictionaryElement;
begin
RemoveItem(AKey);
if AValue = nil then Exit; /// <<<<<<<< THIS IS MY W.A. <<<<<<<<<<
if AValue.ObjectType = otDirectObject then
The exception cause comes from (line 6490, SynPdf.pas):
procedure TPdfFontTrueType.PrepareForSaving;
....
if fDoc.PDFA1 or not WinAnsiFont.fFixedWidth then begin
WR.Add('['); // fixed width will use /DW value
// WinAnsiFont.fUsedWide[] contains glyphs used by ShowText
for i := 0 to n-1 do
with WinAnsiFont.fUsedWide[i] do
if int<>0 then
WR.Add(Glyph).Add('[').Add(Width).Add(']');
Descendant.AddItem('W',TPdfRawText.Create(WR.Add(']').ToPDFString));
end;
Descendant.AddItem('FontDescriptor',WinAnsiFont.fFontDescriptor); //// BUG: WinAnsiFont.fFontDescriptor = nil !!! WHY ?
fDoc.FXref.AddObject(Descendant);
This is the stacktrace :
[0080BEBD] SynPdf.TPdfDictionary.AddItem (Line 3048, "JJWCommon\Third Part\pdf\SynPdf.pas" + 3) + $3
[0080BEB5] SynPdf.TPdfDictionary.AddItem (Line 3046, "JJWCommon\Third Part\pdf\SynPdf.pas" + 1) + $6
[0080BF78] SynPdf.TPdfDictionary.AddItem (Line 3062, "JJWCommon\Third Part\pdf\SynPdf.pas" + 1) + $19
[00815974] SynPdf.TPdfFontTrueType.PrepareForSaving (Line 6491, "JJWCommon\Third Part\pdf\SynPdf.pas" + 28) + $13
[0080BF11] SynPdf.TPdfDictionary.AddItem (Line 3052, "JJWCommon\Third Part\pdf\SynPdf.pas" + 7) + $9
[0081010C] SynPdf.TPdfDocument.SaveToStream (Line 4631, "JJWCommon\Third Part\pdf\SynPdf.pas" + 15) + $3
[00817AB5] SynPdf.TPdfDocumentGDI.SaveToStream (Line 7119, "JJWCommon\Third Part\pdf\SynPdf.pas" + 12) + $C
Sorry about my english!
Bye.
Offline
I do not understand why WinAnsiFont.fFontDescriptor could be nil, since the fFontDescriptor is created in TPdfFontTrueType.Create constructor.
Are you using only non WinAnsi characters within this pdf?
Without the FontDescriptor element within the Font resource, the pdf layout will be invalid, in all cases.
Could you provide some code to reproduce it?
Offline
This PDF is only created drawing Metafiles (renderMetafile method)...
In this metafiles exists custom fonts (created by windows API CreateFont http://msdn.microsoft.com/en-us/library … s.85).aspx ). This fonts are created based on Courier New and has diferent fixed widths.
Can this be the problem? If yes, how can I fix this? (I cannot stop using the CreateFont because of my Report Generator)
Offline
Example at:
http://www.4shared.com/file/U8fV6lTV/SynPdfBUG.html
Decompress, open in delphi, run and click on the button!
The example creates a TPdfDocumentGDI and render 24 metafiles on it. At the TPdfDocumentGDI.savetostream the A.V. occours.
Bye.
Offline
Thanks to your feedback and the code to reproduce the issue, I think I've found its root cause.
In fact, there was an issue when the first time a font was used was for an Unicode character (which occurred at page 14 of your emfs).
See http://synopse.info/fossil/info/4de0e6641f
I suspect that it will work without using UniScribe also.
Offline
Working 100%, nice work!
Ps.: I also need to use UniScribe=true to render the PDF correctly....
Thanks!
bye!
Offline
Pages: 1