Index: fppdf.pp
===================================================================
--- fppdf.pp	(revisión: 33164)
+++ fppdf.pp	(copia de trabajo)
@@ -396,8 +396,10 @@
   private
     FKey: TPDFName;
     FObj: TPDFObject;
+    FHidden: Boolean;
   protected
     procedure Write(const AStream: TStream);override;
+    property Hidden : Boolean read FHidden write FHidden;
   public
     constructor Create(Const ADocument : TPDFDocument; const AKey: string; const AValue: TPDFObject);
     destructor Destroy; override;
@@ -2397,10 +2399,13 @@
 
 procedure TPDFDictionaryItem.Write(const AStream: TStream);
 begin
-  FKey.Write(AStream);
-  TPDFObject.WriteString(' ', AStream);
-  FObj.Write(AStream);
-  TPDFObject.WriteString(CRLF, AStream);
+  if not FHidden then
+  begin
+    FKey.Write(AStream);
+    TPDFObject.WriteString(' ', AStream);
+    FObj.Write(AStream);
+    TPDFObject.WriteString(CRLF, AStream);
+  end;
 end;
 
 constructor TPDFDictionaryItem.Create(Const ADocument : TPDFDocument;const AKey: string; const AValue: TPDFObject);
@@ -2484,7 +2489,7 @@
 var
   ISize,i, NumImg, NumFnt: integer;
   Value: string;
-  M : TMemoryStream;
+  M, Buf : TMemoryStream;
   E : TPDFDictionaryItem;
   D : TPDFDictionary;
 begin
@@ -2520,18 +2525,29 @@
           if Pos('Length1', E.FKey.Name) > 0 then
           begin
             M:=TMemoryStream.Create;
+            Buf:=TMemoryStream.Create;
             try
               Value:=E.FKey.Name;
               NumFnt:=StrToInt(Copy(Value, Succ(Pos(' ', Value)), Length(Value) - Pos(' ', Value)));
               m.LoadFromFile(Document.FontFiles[NumFnt]);
+              // write buffer with compressed (if requested) fontfile stream
+              ISize := TPDFEmbeddedFont.WriteEmbeddedFont(Document, M, Buf);
+              D:=Document.GlobalXRefs[AObject].Dict;
+              // if compression was enabled write Filter
+              if poCompressFonts in Document.Options then
+              begin
+                D.AddName('Filter','FlateDecode');
+                LastElement.Write(AStream);
+              end;
               // write fontfile stream length in xobject dictionary
-              D:=Document.GlobalXRefs[AObject].Dict;
-              D.AddInteger('Length',M.Size);
+              D.AddInteger('Length',ISize);
               LastElement.Write(AStream);
               WriteString('>>', AStream);
               // write fontfile stream in xobject dictionary
-              TPDFEmbeddedFont.WriteEmbeddedFont(Document, M, AStream);
+              Buf.Position := 0;
+              Buf.SaveToStream(AStream);
             finally
+              Buf.Free;
               M.Free;
             end;
           end;
@@ -3099,8 +3115,8 @@
 
 begin
   FDict:=CreateGlobalXRef.Dict;
-  FDict.AddName('Filter','FlateDecode');
   FDict.AddInteger('Length1 '+IntToStr(EmbeddedFontNum),StrToInt(FontDef.FOriginalSize));
+  FDict.LastElement.Hidden := not (poCompressFonts in Options);
 end;
 
 procedure TPDFDocument.CreateImageEntry(ImgWidth, ImgHeight, NumImg: integer);
