You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SWT now provides native PDF generation capabilities through a new `PDFDocument` class, enabling direct export of widget content to PDF files without requiring external libraries.
42
+
43
+
Applications can now export SWT widget content to PDF using the standard `Control.print(GC)` API with the familiar GC drawing operations, or create fully customized PDF documents programmatically.
44
+
45
+
#### Platform Support
46
+
47
+
| Platform | Implementation |
48
+
|----------|----------------|
49
+
| GTK (Linux) | Cairo PDF surface |
50
+
| Cocoa (macOS) | Core Graphics CGPDFContext |
51
+
| Win32 (Windows) | Microsoft Print to PDF |
52
+
53
+
#### Example Usage
54
+
55
+
```java
56
+
// Create a PDF document
57
+
PDFDocument pdf =newPDFDocument(display, "output.pdf", 595, 842); // A4 size in points
58
+
59
+
// Print a control to the PDF
60
+
GC gc =newGC(pdf);
61
+
control.print(gc);
62
+
gc.dispose();
63
+
64
+
// Dispose the document when done
65
+
pdf.dispose();
66
+
```
67
+
68
+
This enhancement eliminates the need for external PDF libraries and provides a native, platform-integrated solution for PDF generation in SWT applications. See Snippet388 for a complete working example.
0 commit comments