|
Enhanced EMF/WMF Metafile Support
Общ преглед
HotPDF вече предлага значително подобрена поддръжка за форматите Enhanced Metafile (EMF) и Windows Metafile (WMF) Новата имплементация включва автоматично разпознаване на формата, няколко опции за позициониране, разширен контрол на мащабирането и подобрено качество на рендиране на векторна графика в PDF документи
Key Enhancements
- Automatic EMF/WMF format detection and appropriate processing
- Multiple positioning options (center, top-left, custom coordinates)
- Enhanced scaling and aspect ratio control
- Direct EMF rendering for vector graphics preservation
- Bitmap conversion option for compatibility
- Improved memory management for large metafiles
- Better handling of complex vector graphics and text
Опции за контрол на позицията
Поддръжката на разширени metafile-и включва гъвкави опции за позициониране:
- mpCenter: Metafile, центриран на страницата (поведение по подразбиране)
- mpLeftTop: Metafile, показан в горния ляв ъгъл (X=0, Y=0)
- mpCustom: Metafile, показан на зададена позиция (изисква параметрите X, Y)
Примери за употреба
Основна употреба (центрирано показване по подразбиране)
// Delphi example - Default centered display
procedure ShowMetafileDefault;
var
PDF: THotPDF;
MetaFile: TMetafile;
begin
PDF := THotPDF.Create(nil);
MetaFile := TMetafile.Create;
try
PDF.BeginDoc;
PDF.AddPage;
// Load metafile
MetaFile.LoadFromFile('diagram.emf');
// Display centered on page (default)
PDF.CurrentPage.ShowMetafile(MetaFile);
PDF.EndDoc;
finally
MetaFile.Free;
PDF.Free;
end;
end;
Използване на контрол на позицията
// Delphi example - Advanced positioning
procedure ShowMetafileAdvanced;
var
PDF: THotPDF;
MetaFile: TMetafile;
begin
PDF := THotPDF.Create(nil);
MetaFile := TMetafile.Create;
try
PDF.BeginDoc;
PDF.AddPage;
MetaFile.LoadFromFile('chart.wmf');
// Top-left corner display
PDF.CurrentPage.ShowMetafile(MetaFile, mpLeftTop);
// Custom position display
PDF.CurrentPage.ShowMetafile(MetaFile, mpCustom, 100, 200);
PDF.EndDoc;
finally
MetaFile.Free;
PDF.Free;
end;
end;
Разширени методи
Разширената EMF/WMF поддръжка въвежда няколко нови метода:
Претоварвания на THPDFPage.ShowMetafile
ShowMetafile(MetaFile: TMetafile) - Центрирано показване по подразбиране
ShowMetafile(MetaFile: TMetafile; Position: THPDFMetafilePosition) - Контрол на позицията
ShowMetafile(MetaFile: TMetafile; Position: THPDFMetafilePosition; X, Y: Single) - Персонализирано позициониране
Разширени методи за обработка
EnhancedShowMetafile - Разширена обработка с допълнителни възможности
RenderEmfDirect - Директно EMF рендиране за запазване на вектора
RenderEmfAsBitmap - Конвертиране в bitmap за съвместимост
RenderWmfAsBitmap - WMF bitmap рендиране с контрол на позицията
Техническа реализация
Разширената EMF/WMF поддръжка е реализирана чрез единицата HPDFEmf.pas, която предоставя:
- THPDFEmfEnhanced: Основен клас за разширение за обработка на EMF
- THPDFEmfPatcher: Помощен клас за конвертиране и рендиране на EMF
- THPDFMetafilePosition: Изброим тип за контрол на позицията
- Enhanced EMF Record Processing: Поддръжка за разширени EMF записи
Advanced Features
EMF Record Support
- EMR_BITBLT - Bitmap operations
- EMR_STRETCHDIBITS - Stretched bitmap operations
- EMR_ALPHABLEND - Alpha blending operations
- Enhanced text rendering
- Complex path operations
Rendering Options
- Vector Preservation: Maintains vector graphics quality
- Bitmap Fallback: Automatic fallback for complex graphics
- Scaling Options: Automatic and manual scaling control
- Quality Control: Configurable rendering quality settings
Performance Optimizations
- Memory-efficient processing for large metafiles
- Optimized EMF record parsing
- Intelligent caching for repeated elements
- Reduced memory footprint during conversion
Compatibility and Standards
- Windows EMF 1.0 and Enhanced EMF support
- Windows Metafile (WMF) backward compatibility
- Cross-platform rendering consistency
- PDF vector graphics standards compliance
Troubleshooting
Common Issues and Solutions:
- Large Metafiles: Use bitmap rendering for very large or complex metafiles
- Text Rendering: Ensure fonts are available on the target system
- Complex Graphics: Consider direct EMF rendering for better quality
- Positioning Issues: Use custom positioning for precise placement
See Also
|