Hi Sridhar,
The problem is, that the fonts embeded in the PDF document, only are
abailable while the document is printed. Especially because PDF renames the
embedded fonts to something new.
So the trick is to enumerate the fonts from the EMF file, and then make
copies of them for embedding(They could be added to the EMF file via GDI
Comments Records). Then when you wnat to use the EMF the next time, just
install the embedded fonts againe.
Here some example code in Delphi:
procedure TPrintThreadBase.ExtractFontData(EMFFileName: String);
var
EmfFile : TMemoryStream;
EMRRecord : PEMR;
i : integer;
FontRec :PEMRExtCreateFontIndirect;
FontName : WideString;
FontHandle : HFONT;
FontBufferSize : Cardinal;
FontBuffer : TMemoryStream;
GDIRet : dword;
HiddenDC : HDC;
begin
EmfFile := TMemoryStream.Create;
try
EmfFile.LoadFromFile(EMFFileName);
HiddenDC := CreateDC(‘DISPLAY’,nil,nil,nil);
if HiddenDC = 0 then
RaiseLastWin32Error;
try
EMRRecord := EmfFile.Memory;
while EMRRecord <> nil do begin
if EMRRecord^.iType = EMR_EOF then
Break
else if EMRRecord^.iType = EMR_EXTCREATEFONTINDIRECTW then begin
FontRec := PEMRExtCreateFontIndirect(EMRRecord);
FontName :=FontRec.elfw.elfLogFont.lfFaceName;
//check if already extracted
CriticalSection.Enter;
try
i := FFontList.IndexOf(FontName);
finally
CriticalSection.Leave;
end;
if i = -1 then begin
FontHandle := CreateFontIndirectW(FontRec.elfw.elfLogFont);
if FontHandle = 0 then
RaiseLastWin32Error;
try
GDIRet := SelectObject(HiddenDC,FontHandle);
if (GDIRet = 0) or (GDIRet = HGDI_ERROR) then
RaiseLastWin32Error;
FontBufferSize := 0;
FontBufferSize :=
GetFontData(HiddenDC,0,0,nil,FontBufferSize);
if (FontBufferSize <> GDI_ERROR) and (FontBufferSize >0) then
begin
FontBuffer := TMemoryStream.Create;
FontBuffer.SetSize(FontBufferSize);
FontBufferSize :=
GetFontData(HiddenDC,0,0,FontBuffer.Memory,FontBufferSize);
if FontBufferSize = GDI_ERROR then
RaiseLastWin32Error;
//add font to list
CriticalSection.Enter;
try
FFontList.AddObject(FontName,FontBuffer);
finally
CriticalSection.Leave;
end;
end;
finally
Win32Check(DeleteObject(FontHandle));
end;
end;
end;
EMRRecord := Pointer(Integer(Pointer(EMRRecord))+EMRRecord.nSize);
end; // while
finally
Win32Check(DeleteDC(HiddenDC));
end;
finally
EmfFile.Free;
end;
end;
Best regards,
Christoph Lindemann
-----Original Message-----
From: Sridhar Krishnan [mailto:xxxxx@ureach.com]
Sent: 15 jan 03 23:59
To: NT Developers Interest List
Subject: [ntdev] EMF Driver question
Hi,
We have developed a EMF driver. It works fine with all the
microsoft applications meaning it creats emf files properly
when a print job is given using EMF driver. But It doesn’t work
properly with PDF files. It creats EMF files when a print job
is given from Adobe acrobat reader. It works when I open the
EMF file using emf viewer. But if I reboot the system I won’t
see the proper characters, the EMF viewer displays junk text.
Can anyone help me to solve this problem?
Thanks,
Sridhar
Get your own “800” number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
This mail has been Checked by KAV Exchange At Danish Company ApS