Platforms to show: All Mac Windows Linux Cross-Platform

PDFDocumentMBS.appendPage(page as PDFPageMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 14.3 Yes No No Yes, macOS only No
Function: Appends a page to the document.

Feedback, Comments & Corrections

PDFDocumentMBS.beginFindString(text as string, options 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: Begins a find, searching the document for string.
Notes: Search results are handled via a DidFindMatch event in the delegate. Supported options are: NSCaseInsensitiveSearch, NSLiteralSearch, and NSBackwardsSearch.

Feedback, Comments & Corrections

PDFDocumentMBS.cancelFindString
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: Method to cancel a search.
Notes: Can be called from a user method being serviced by a find notification.

Feedback, Comments & Corrections

PDFDocumentMBS.Constructor
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 constructor to create a new pdf document in memory.
Example:
dim doc as new PDFDocumentMBS // new empty document
dim page as new PDFPageMBS // new empty page

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

doc.insertPage page,0

dim f as FolderItem=SpecialFolder.Desktop.Child("test.pdf")

if doc.write(f) then
f.launch
end if

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.Constructor(data as memoryblock)
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 new pdf document based on a string.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim b as BinaryStream = f.OpenAsBinaryFile(false)
dim s as string = b.Read(b.Length)

dim doc as new PDFDocumentMBS(s)

MsgBox doc.Title

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.Constructor(file as folderitem)
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 new pdf document based on a file.
Example:
dim p as PDFDocumentMBS
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.pdf")
p=new PDFDocumentMBS(f)

MsgBox "Text from first page:"+EndOfLine+EndOfLine+p.pageAtIndex(0).stringValue

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.Constructor(Handle as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 20.2 Yes No No Yes, macOS only No
Function: Creates a new object based on a given PDFDocument handle.
Notes:
Please pass in a non zero handle which points to a PDFDocument object.
For use with declares.

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.copy as PDFDocumentMBS
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 document object.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim p as new PDFDocumentMBS(f)

// make a copy
dim c as PDFDocumentMBS = p.copy

// remove second page
c.removePageAtIndex 1

// c has one page less
MsgBox str(p.pageCount)+" "+str(c.pageCount)
Notes:
For Mac OS X 10.7 and newer this function uses the framework function.
For Mac OS X 10.6 and older this function uses our own copy function to duplicate the document.

Feedback, Comments & Corrections

PDFDocumentMBS.dataRepresentation(QuartzFilter as Variant = nil) as memoryblock
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 11.2 Yes No No Yes, macOS only No
Function: Methods to record the current state of the PDFDocument as data string.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim doc as new PDFDocumentMBS(f)

dim o as FolderItem = SpecialFolder.Desktop.Child("out.pdf")
dim b as BinaryStream = o.CreateBinaryFile("")

b.Write doc.dataRepresentation
Notes: Optional for Mac OS X 10.6, you can pass a QuartzFilterMBS object to use that filter here.

Feedback, Comments & Corrections

PDFDocumentMBS.documentAttributes as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property PDFKit MBS MacControls Plugin 11.2 Yes No No Yes, macOS only No
Function: The PDF meta data as a Xojo Dictionary object.
Notes:
Returns a dictionary with PDF metadata. Metadata is optional for PDF's and so some of the keys may be missing or the entire dictionary may be empty.
(Read and Write computed property)

Feedback, Comments & Corrections

PDFDocumentMBS.documentRef as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 11.2 Yes No No Yes, macOS only No
Function: Returns a CGPDFDocumentRef value for this document.
Notes:
This is the CGPDFDocument associated with the PDFDocument object. With this object you can call many CoreGraphics API. May return 0 if the document was not created from an existing PDF file or data.

Use CGPDFDocumentMBS with Constructor taking a handle to call functions on this CGPDFDocument object.

Feedback, Comments & Corrections

PDFDocumentMBS.exchangePageAtIndexWithPageAtIndex(indexA as Integer, indexB 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: Exchanges the two pages with the given index.
Notes: Index is zero based.

Feedback, Comments & Corrections

PDFDocumentMBS.findString(text as string, options 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: Searches entire document for string and returns an array of PDFSelections representing all instances found.
Example:
dim p as PDFDocumentMBS
dim f as FolderItem
dim sa() as PDFSelectionMBS
dim i,c as Integer
dim s as PDFSelectionMBS

const NSCaseInsensitiveSearch=1

f=SpecialFolder.Desktop.Child("test.pdf")
p=new PDFDocumentMBS(f)

if p.pageCount=0 then
MsgBox "Failed to load the PDF."
Return
end if

sa=p.findString("Plugin",NSCaseInsensitiveSearch)

if ubound(sa)<0 then
MsgBox "no item found."
else
MsgBox str(ubound(sa)+1)+" items found."
end if

s=sa(0)
s.extendSelectionAtEnd(50)
s.extendSelectionAtStart(50)

MsgBox s.stringValue // shows a bit more text before and after the location found
Notes:
May return an empty array if nothing is found.
Returns nil on any error.

Supported options are:
NSCaseInsensitiveSearch, NSLiteralSearch, and NSBackwardsSearch.

Feedback, Comments & Corrections

PDFDocumentMBS.findStringFromSelection(text as string, selection as PDFSelectionMBS, options 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: Searches for only the next instance of string beginning after the last character of selection with options (or preceding the first character of the selection if NSBackwardsSearch is specified as a search option).
Notes: Returns next instance as a PDFSelection or nil if the end of the document is reached. Supported options are: NSCaseInsensitiveSearch, NSLiteralSearch, and NSBackwardsSearch. Passing in nil for selection will start the search from the beginning of the document (or end if NSBackwardsSearch is specified).

Feedback, Comments & Corrections

PDFDocumentMBS.indexForPage(page as PDFPageMBS) 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 PDFPage, returns the pages index within the document.
Notes: Indicees are zero-based.

Feedback, Comments & Corrections

PDFDocumentMBS.insertPage(page as PDFPageMBS, index 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: Inserts a page in the pdf on the given index.
Example:
dim file1,file2,file3,destfile as FolderItem
dim page1,page2,page3 as PDFPageMBS
dim doc1,doc2 as PDFDocumentMBS
dim img as NSImageMBS
dim doc as PDFDocumentMBS

file1=SpecialFolder.Desktop.Child("test1.pdf")
file2=SpecialFolder.Desktop.Child("test2.pdf")
file3=SpecialFolder.Desktop.Child("logo.jpg")

doc1=new PDFDocumentMBS(file1)
doc2=new PDFDocumentMBS(file2)

MsgBox str(doc1.pageCount)

img=new NSImageMBS(file3)

Backdrop=img.CopyPicture

page1=new PDFPageMBS(img)
page2=doc1.pageAtIndex(0)
page3=doc2.pageAtIndex(0)

doc=new PDFDocumentMBS
doc.insertPage page1,0
doc.insertPage page2,1
doc.insertPage page3,2

destfile=SpecialFolder.Desktop.Child("test.pdf")
call doc.write(destfile)
Notes: Index is zero based.

Feedback, Comments & Corrections

PDFDocumentMBS.Keywords as string()
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: Array of Strings containing document keywords.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim doc as new PDFDocumentMBS(f)
MsgBox join(doc.Keywords)

Feedback, Comments & Corrections

PDFDocumentMBS.outlineItemForSelection(selection as PDFSelectionMBS) as PDFOutlineMBS
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 PDFSelection, this method returns the child outline item the selection most closely falls beneath.
Notes:
Since a selection may span multiple outline items, only the point representing the first character of the PDFSelection is considered. Typically, outline's indicate things like chapters for the PDF. Therefore, this method would help you identify the chapter the selection falls within.

For some PDFs this method returns nil.

Feedback, Comments & Corrections

PDFDocumentMBS.pageAtIndex(index as Integer) as PDFPageMBS
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 PDFPage object representing the page at index.
Example:
dim p as PDFDocumentMBS
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.pdf")
p=new PDFDocumentMBS(f)

MsgBox "Text from first page:"+EndOfLine+EndOfLine+p.pageAtIndex(0).stringValue
Notes: Will raise an exception if index is out of bounds. Indicees are zero-based.

Feedback, Comments & Corrections

PDFDocumentMBS.PrintOperation(PrintInfo as Variant, AutoRotate as boolean = true, scalingMode as Integer = 0) as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 14.3 Yes No No Yes, macOS only No
Function: Creates print operation for PDF document.
Example:
// select a PDF
dim f as FolderItem = GetOpenFolderItem("")
if f = nil then Return

// open PDF
dim doc as new PDFDocumentMBS(f)

// define some print setting via PrintInfo
dim PrintInfo as new NSPrintInfoMBS

// start print operation
dim printOperation as NSPrintOperationMBS = doc.PrintOperation(printinfo)

printOperation.showsPrintPanel = true
printOperation.showsProgressPanel = true

call printOperation.runOperation
Notes: Returns NSPrintOperationMBS object.

Feedback, Comments & Corrections

PDFDocumentMBS.removePageAtIndex(index 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: Removes a page in the pdf on the given index.
Notes: Index is zero based.

Feedback, Comments & Corrections

PDFDocumentMBS.selectionForEntireDocument 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 for the entire document.

Feedback, Comments & Corrections

PDFDocumentMBS.selectionFromPage(StartPage as PDFPageMBS, StartCharacterIndex as Integer, EndPage as PDFPageMBS, EndCharacterIndex 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: Returns a selection representing text from page startPage and point StartCharacterIndex to page endPage and to point EndCharacterIndex on that page.
Notes: Start and end page can be the same.

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.selectionFromPage(StartPage as PDFPageMBS, StartPointX as single, StartPointY as single, EndPage as PDFPageMBS, EndPointX as single, EndPointY 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 from page startPage and point startPt to page endPage and to point endPt on that page.
Notes: Points are in page-space and relative to their respective pages. Start and end page can be the same (and are then equivalent to calling selectionFromPointToPoint).

See also:

Feedback, Comments & Corrections

PDFDocumentMBS.SetDelegate(d as PDFDocumentDelegateMBS)
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: If a PDFDocument has a delegate, delegate methods may be called for this document.

Feedback, Comments & Corrections

PDFDocumentMBS.SetKeywords(keywords() as string)
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: Sets the array of strings containing document keywords.

Feedback, Comments & Corrections

PDFDocumentMBS.unlockWithPassword(password as string) as boolean
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: Unlocks an encrypted PDF with the given password.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim doc as new PDFDocumentMBS(f)

if doc.unlockWithPassword("mypassword") then
MsgBox "OK"
end if
Notes: Means of passing in a password to unlock encrypted PDF's. Calling unlockWithPassword will attempt to unlock the PDF. If successful, a DidUnlockDocument event is sent to the delegate. You cannot "re-lock" a PDF by passing in a bogus password. Returns true if the document is now unlocked, false otherwise (isLocked = false).

Feedback, Comments & Corrections

PDFDocumentMBS.write(file as folderitem, QuartzFilter as Variant = nil) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 11.2 Yes No No Yes, macOS only No
Function: Methods to record the current state of the PDFDocument as a file.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("test.pdf")
dim doc as new PDFDocumentMBS(f)

// modify here

dim o as FolderItem = SpecialFolder.Desktop.Child("testout.pdf")
call doc.write(o)
Notes:
Returns true on success and false on failure.

There is a bug known in Mac OS X 10.4 that this function may return true even if the saving failed. So you may prefer to check the file whether it exists after write.

Optional for Mac OS X 10.6, you can pass a QuartzFilterMBS object to use that filter here.

Feedback, Comments & Corrections

PDFDocumentMBS.writeWithOptions(file as folderitem, options as dictionary) as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method PDFKit MBS MacControls Plugin 19.1 Yes No No Yes, macOS only No
Function: Writes PDF to file with options.
Notes:
Returns true on success and false on failure.

Some keys to use include:
CGPDFContextMBS.kCGPDFContextUserPassword
CGPDFContextMBS.kCGPDFContextTitle
CGPDFContextMBS.kCGPDFContextSubject
CGPDFContextMBS.kCGPDFContextOwnerPassword
CGPDFContextMBS.kCGPDFContextOutputIntents
CGPDFContextMBS.kCGPDFContextOutputIntent
CGPDFContextMBS.kCGPDFContextKeywords
CGPDFContextMBS.kCGPDFContextEncryptionKeyLength
CGPDFContextMBS.kCGPDFContextCreator
CGPDFContextMBS.kCGPDFContextAuthor
CGPDFContextMBS.kCGPDFContextAllowsPrinting
CGPDFContextMBS.kCGPDFContextAllowsCopying

Feedback, Comments & Corrections

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

The biggest plugin in space...




Links
MBS Xojo Plugins