Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

PDFPageMBS.addAnnotation(annotation as PDFAnnotationMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Methods allowing annotations to be added.

Feedback, Comments & Corrections

PDFPageMBS.annotationAtPoint(x as single, y as single) as PDFAnnotationMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Hit-testing method returns the annotation at point (or nil if none).
Notes: The point is in page-space.

Feedback, Comments & Corrections

PDFPageMBS.annotations as PDFAnnotationMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 9.6 Yes No No Yes, macOS only No
Function: Returns an array containing the page's annotations.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim doc as new PDFDocumentMBS(f)
dim page as PDFPageMBS = doc.pageAtIndex(0)
dim annotations(-1) as PDFAnnotationMBS = page.annotations

// show a msgbox with the types of all annotations
dim types(-1) as string

for each a as PDFAnnotationMBS in annotations
types.Append a.type
next

MsgBox Join(types)
Notes:
The elements of the array will most likely be typed to subclasses of the PDFAnnotation class.

Available in Mac OS X v10.4 and later.

Feedback, Comments & Corrections

PDFPageMBS.boundsForBox(box as Integer) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property PDFKit MBS MacControls Plugin 9.6 Yes No No Yes, macOS only No
Function: Returns the bounds for the specified PDF display box.
Notes:
The PDFDisplayBox enumeration defines the various box types.

Note that only the media box is required for a PDF. If you request the bounds for the crop box, but the PDF does not include a crop box, the bounds for the media box are returned instead. If you request the bounds for other box types, and the PDF does not includes these types, the bounds for the crop box are returned instead.

The coordinates for the box are in page space, so you might need to transform the points if the page has a rotation on it. Also, note that the bounds boundsForBox returns are intersected with the page's media box.

boundsForBox throws a range exception if box is not in range.
(Read and Write computed property)

Feedback, Comments & Corrections

PDFPageMBS.CalcTransformForBox(box as Integer) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 12.5 Yes No No Yes, macOS only No
Function: An utility function to calculate the transform needed to draw into a page.
Notes: Returns NSAffineTransformMBS object.

Feedback, Comments & Corrections

PDFPageMBS.CGPDFPageHandle as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 9.6 Yes No No Yes, macOS only No
Function: The CoreGraphics PDFPage handle.

Feedback, Comments & Corrections

PDFPageMBS.characterBoundsAtIndex(index as Integer) as NSRectMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Returns the bounds in page-space of the character at index.
Notes: In the unlikely event that more than one character are at the specified point, only the first character encountered is returned.

Feedback, Comments & Corrections

PDFPageMBS.characterIndexAtPoint(x as single, y as single) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Returns the index of the character at point (in page space).
Notes: Returns -1 if no character at point.

Feedback, Comments & Corrections

PDFPageMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: The constructor to create a custom PDF page.
Example:
dim doc as new PDFDocumentMBS
dim page as PDFPageMBS
dim f as FolderItem

page=new MyPDFPageMBS

doc.Creator="Realbasic"
doc.Title="Test file"

doc.insertPage page,0

f=SpecialFolder.Desktop.Child("test.pdf")

if doc.write(f) then
f.launch
end if
Notes: You draw the content using drawRect event.

See also:

Feedback, Comments & Corrections

PDFPageMBS.Constructor(image as NSImageMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Creates a PDFPage for the NSImage passed in.
Notes:
An easy way to create a PDFPage from an image to add to a PDFDocument.

Mac OS X 10.5 only.

See also:

Feedback, Comments & Corrections

PDFPageMBS.copy as PDFPageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 13.1 Yes No No Yes, macOS only No
Function: Creates a copy of the page object.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim p as new PDFDocumentMBS(f)

// make a new PDF
dim c as new PDFDocumentMBS

// get first page
dim page as PDFPageMBS = p.pageAtIndex(0)

// add copy of page to new pdf
c.insertPage page.copy, 0

// c now has one page
MsgBox str(p.pageCount)+" "+str(c.pageCount)

Feedback, Comments & Corrections

PDFPageMBS.Destructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 15.0 Yes No No Yes, macOS only No
Function: The destructor.

Feedback, Comments & Corrections

PDFPageMBS.Draw(g as NSGraphicsMBS, box as Integer = 0)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 12.1 Yes No No Yes, macOS only No
Function: Draws PDF page into graphics environment.
Notes: Use kPDFDisplay*Box constants for box parameter.

Feedback, Comments & Corrections

PDFPageMBS.drawWithBox(box as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 9.6 Yes No No Yes, macOS only No
Function: Draws the page within the specified box.
Notes: This method takes into account the page rotation and draws clipped to the specified box. If the page is set to display annotations, this method also draws them. This method does not clear the background. To clear the background before drawing, use NSRectFill with NSColor set (typically) to white.

Feedback, Comments & Corrections

PDFPageMBS.removeAnnotation(annotation as PDFAnnotationMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Methods allowing annotations to be removed.

Feedback, Comments & Corrections

PDFPageMBS.Render(dpi as Double = 72.0, box as Integer = 0, background as NSColorMBS = nil) as NSImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 10.3 Yes No No Yes, macOS only No
Function: Renders a PDF Page into an image.
Example:
dim f as FolderItem = GetFolderItem("Castles.pdf")
dim doc as new PDFDocumentMBS(f)
dim page as PDFPageMBS = doc.pageAtIndex(0)
dim image as NSImageMBS = page.Render

Backdrop = image.CopyPicture
Notes:
dpi: The resolution you want to have on the image. Default 72.0. To get a scaled image with factor x, pass 72.0*x.
box: The display box. Use one of the kPDFDisplayBox* constants.
background: optional NSColorMBS object to fill the background before drawing the PDF. This will affect only PDFs with transparent background.

Returns nil on any error.

Version 11.1pr8 adds code here to handle rotation better.
Due to bugs in Apple’s PDFKit you may see memory leaks with JPEG data from PDF pages (seen in macOS 10.12).

Feedback, Comments & Corrections

PDFPageMBS.selectionForLineAtPoint(left as single, top as single) as PDFSelectionMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Given a point in page-space, returns a selection representing a whole line at that point.
Notes: May return nil if no character (and by extension no line) under point.

Feedback, Comments & Corrections

PDFPageMBS.selectionForRange(position as Integer, length as Integer) as PDFSelectionMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Given a range, returns a selection representing text within that range.
Example:
dim MyPDFView as PDFViewMBS // your view

dim doc as PDFDocumentMBS = MyPDFView.document
dim page as PDFPageMBS = doc.pageAtIndex(0)
dim sel as PDFSelectionMBS = page.selectionForRange(0,5)
MyPDFView.currentSelection = sel
Notes: Will raise an exception if the range length is zero or if the range is outside the range of the characters on the page.

Feedback, Comments & Corrections

PDFPageMBS.selectionForRect(left as single, top as single, width as single, height as single) as PDFSelectionMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Given a rect in page-space, returns a selection representing enclosed text on page.

Feedback, Comments & Corrections

PDFPageMBS.selectionForWordAtPoint(left as single, top as single) as PDFSelectionMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Given a point in page-space, returns a selection representing a whole word at that point.
Notes: May return nil if no character (and by extension no word) under point.

Feedback, Comments & Corrections

PDFPageMBS.selectionFromPointToPoint(startleft as single, starttop as single, endleft as single, endtop as single) as PDFSelectionMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Returns a selection representing text between startPt and endPt.
Notes: Point are sorted first top to bottom, left to right.

Feedback, Comments & Corrections

PDFPageMBS.transformContextForBox(box as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 8.0 Yes No No Yes, macOS only No
Function: Given a display box, will transform the current context to take into account the rotation of the page as well as the origin of the box with repect to the page's base coordinates system.
Notes:
This is a convenient method to call from within drawPage or from within the draw method a PDFAnnotation subclass.

Mac OS X 10.5 only.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacControls Plugin.





Links
MBS Xojo Plugins