3131 * when those instances are no longer required.
3232 * </p>
3333 * <p>
34+ * <b>Note:</b> On Windows, this class uses the built-in "Microsoft Print to PDF"
35+ * printer which is available on Windows 10 and later.
36+ * </p>
37+ * <p>
3438 * The following example demonstrates how to use PDFDocument:
3539 * </p>
3640 * <pre>
@@ -76,6 +80,12 @@ static class PDFDocumentData extends DeviceData {
7680 /**
7781 * Constructs a new PDFDocument with the specified filename and page size.
7882 * <p>
83+ * The page size specifies the preferred dimensions in points (1/72 inch). On Windows,
84+ * the Microsoft Print to PDF driver only supports standard paper sizes, so the actual
85+ * page size may be larger than requested. Use {@link #getBounds()} to query the actual
86+ * page dimensions after construction.
87+ * </p>
88+ * <p>
7989 * You must dispose the PDFDocument when it is no longer required.
8090 * </p>
8191 *
@@ -87,35 +97,43 @@ static class PDFDocumentData extends DeviceData {
8797 * <li>ERROR_INVALID_ARGUMENT - if width or height is not positive</li>
8898 * </ul>
8999 * @exception SWTError <ul>
90- * <li>ERROR_NO_HANDLES - if the PDF context could not be created </li>
100+ * <li>ERROR_NO_HANDLES - if the PDF printer is not available </li>
91101 * </ul>
92102 *
93103 * @see PageSize
94104 * @see #dispose()
105+ * @see #getBounds()
95106 */
96107 public PDFDocument (String filename , PageSize pageSize ) {
97108 super (checkData (filename , pageSize ));
98109 }
99110
100111 /**
101- * Constructs a new PDFDocument with the specified filename and page dimensions.
112+ * Constructs a new PDFDocument with the specified filename and preferred page dimensions.
113+ * <p>
114+ * The dimensions specify the preferred page size in points (1/72 inch). On Windows,
115+ * the Microsoft Print to PDF driver only supports standard paper sizes, so the actual
116+ * page size may be larger than requested. Use {@link #getBounds()} to query the actual
117+ * page dimensions after construction.
118+ * </p>
102119 * <p>
103120 * You must dispose the PDFDocument when it is no longer required.
104121 * </p>
105122 *
106123 * @param filename the path to the PDF file to create
107- * @param widthInPoints the width of each page in points (1/72 inch)
108- * @param heightInPoints the height of each page in points (1/72 inch)
124+ * @param widthInPoints the preferred width of each page in points (1/72 inch)
125+ * @param heightInPoints the preferred height of each page in points (1/72 inch)
109126 *
110127 * @exception IllegalArgumentException <ul>
111128 * <li>ERROR_NULL_ARGUMENT - if filename is null</li>
112129 * <li>ERROR_INVALID_ARGUMENT - if width or height is not positive</li>
113130 * </ul>
114131 * @exception SWTError <ul>
115- * <li>ERROR_NO_HANDLES - if the PDF context could not be created </li>
132+ * <li>ERROR_NO_HANDLES - if the PDF printer is not available </li>
116133 * </ul>
117134 *
118135 * @see #dispose()
136+ * @see #getBounds()
119137 */
120138 public PDFDocument (String filename , double widthInPoints , double heightInPoints ) {
121139 this (filename , new PageSize (widthInPoints , heightInPoints ));
@@ -237,9 +255,13 @@ public void newPage() {
237255 * This method should be called after completing the content of one page
238256 * and before starting to draw on the next page.
239257 * </p>
258+ * <p>
259+ * <b>Note:</b> On Windows, changing page dimensions after the document
260+ * has been started may not be fully supported by all printer drivers.
261+ * </p>
240262 *
241- * @param widthInPoints the width of the new page in points (1/72 inch)
242- * @param heightInPoints the height of the new page in points (1/72 inch)
263+ * @param widthInPoints the preferred width of the new page in points (1/72 inch)
264+ * @param heightInPoints the preferred height of the new page in points (1/72 inch)
243265 *
244266 * @exception IllegalArgumentException <ul>
245267 * <li>ERROR_INVALID_ARGUMENT - if width or height is not positive</li>
@@ -258,9 +280,13 @@ public void newPage(double widthInPoints, double heightInPoints) {
258280 }
259281
260282 /**
261- * Returns the width of the current page in points.
283+ * Returns the actual width of the current page in points.
284+ * <p>
285+ * On Windows, this may be larger than the preferred width specified
286+ * in the constructor due to standard paper size constraints.
287+ * </p>
262288 *
263- * @return the width in points (1/72 inch)
289+ * @return the actual width in points (1/72 inch)
264290 *
265291 * @exception SWTException <ul>
266292 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
@@ -272,9 +298,13 @@ public double getWidth() {
272298 }
273299
274300 /**
275- * Returns the height of the current page in points.
301+ * Returns the actual height of the current page in points.
302+ * <p>
303+ * On Windows, this may be larger than the preferred height specified
304+ * in the constructor due to standard paper size constraints.
305+ * </p>
276306 *
277- * @return the height in points (1/72 inch)
307+ * @return the actual height in points (1/72 inch)
278308 *
279309 * @exception SWTException <ul>
280310 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
@@ -287,8 +317,8 @@ public double getHeight() {
287317
288318 /**
289319 * Returns the DPI (dots per inch) of the PDF document.
290- * PDF documents work in points where 1 point = 1/72 inch,
291- * so the DPI is always 72 .
320+ * Since the coordinate system is scaled to work in points ( 1/72 inch) ,
321+ * this always returns 72 DPI, consistent with GTK and Cocoa implementations .
292322 *
293323 * @return a point whose x coordinate is the horizontal DPI and whose y coordinate is the vertical DPI
294324 *
@@ -305,6 +335,10 @@ public Point getDPI() {
305335 /**
306336 * Returns a rectangle describing the receiver's size and location.
307337 * The rectangle dimensions are in points (1/72 inch).
338+ * <p>
339+ * On Windows, this returns the actual page size which may be larger
340+ * than the preferred size specified in the constructor.
341+ * </p>
308342 *
309343 * @return the bounding rectangle
310344 *
0 commit comments