Following works in 10.4 onwards: // Begin Sample Code - Requires FB5 with FBtoC include "Rntm Appearance.incl" include "Tlbx HIView.incl" toolbox fn CGPDFContextCreateWithURL( CFURLRef url, const CGRect *mediaBox, CFDictionaryRef auxiliaryInfo ) = CGContextRef toolbox CGPDFContextBeginPage( CGContextRef context, CFDictionaryRef pageInfo ) toolbox CGPDFContextEndPage( CGContextRef context ) local fn MakeMyPDF dim @ myCFURL as CFURLRef dim myRect as CGRect dim myContext as CGContextRef dim myX as double dim myY as double dim myH as double dim myW as double dim wndwidth as long dim wndheight as long myCFURL = 0 wndwidth = 500 wndheight = 300 myX = 0.0 myY = 0.0 myW = wndwidth myH = wndheight myRect = fn CGRectMake( myX, myY, myW, myH ) long if ( files$( _CFURLRefSave, "Save PDF File As", "My Sample PDF File.pdf", myCFURL ) ) long if ( myCFURL ) myContext = fn CGPDFContextCreateWithURL( myCFURL, @myRect, 0 ) fn CGPDFContextBeginPage( myContext, 0 ) // Draw using CG Quartz here: // Set line colour to black fn CGContextSetRGBStrokeColor( myContext, 0, 0, 1, 1 ) // Draw Rectangle border fn CGContextStrokeRectWithWidth( myContext, myRect, 10 ) // Draw curve fn CGContextSetLineWidth( myContext, 5 ) fn CGContextSetRGBStrokeColor( myContext, 1, 0, 1, 1 ) fn CGContextMoveToPoint( myContext, 250, 50 ) fn CGContextAddArcToPoint( myContext, 250, 250, 300, 250, 50 ) fn CGContextStrokePath( myContext ) // Draw circle fn CGContextSetLineWidth( myContext, 5.0 ) fn CGContextSetRGBStrokeColor( myContext, 1, 0, 0, 1 ) // Draw counterclockwise with start at 0 and end at 2*Pi fn CGContextAddArc( myContext, 300, 150, 30 , 0, 8.0 * ATN(1.0), 0 ) fn CGContextStrokePath( myContext ) // Draw rectangle with transparency fn CGContextSetRGBFillColor( myContext, 0.1, 0.8, 0.3, 0.5 ) myRect = fn CGRectMake( 200, 150, 150, 150 ) fn CGContextFillRect( myContext, myRect ) fn CGPDFContextEndPage( myContext ) fn CGContextRelease( myContext ) CFRelease( myCFURL ) end if end if end fn fn MakeMyPDF do handleevents until gFBquit // End Sample Code > From: Domokos Vekas <domika@...> > Reply-To: <futurebasic@...> > Date: Sun, 24 May 2009 22:39:21 +0200 > To: <futurebasic@...> > Subject: [FB] How to create pdf with specified rectangle under program control > > Hi all, > > I am moving my apps from QuickDraw to CoreGraphics, and I have nearly > finished the transition. But I still need a method to generate pdf > files instead of pict files, with a specified frame (rectangle). > > With QuickDraw, we can specify the upper-left and lower-right corners > of the rectangle surrounding the pict, in pixels, using the parameters > of the PICTURE ON statement: > > PICTURE ON (0, 0) - (wndwidth, wndheight) > 'drawing commands here > PICTURE OFF, pictHndl& > > then pictHndl& can be saved as a pict file, with the specified size. > > What is the modern equivalent of this? > > I know already how to print to a pdf under program control (without > using the print dialog) from Robert P's example file ("print to pdf" > on the FB 4.4.1 CD). But in that demo the default printer page rect > will determine the size of the pdf. > > Is it possible to manipulate from code the printer page rect, or would > I need a different solution? > (I need compatibility with FB4, too.) > > I would appreciate any help. Regards, > Domokos > > -- > To unsubscribe, send ANY message to: futurebasic-unsubscribe@...