Platforms to show: All Mac Windows Linux Cross-Platform

/MacCG/CoreGraphics PDF/PDF properties


Required plugins for this example: MBS MacCG Plugin, MBS MacCF Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics PDF/PDF properties

This example is the version from Sun, 17th Mar 2012.

Project "PDF properties.xojo_binary_project"
FileTypes
Filetype application/pdf
End FileTypes
Class ListWindow Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub ExpandRow(row As Integer) dim co as CGPDFObjectMBS dim i as integer dim n as Variant dim a as CGPDFArrayMBS dim pa as CGPDFPageMBS dim d as CGPDFDictionaryMBS n=me.CellTag(row,0) if n isa CGPDFObjectMBS then co=CGPDFObjectMBS(n) AddRows co elseif n isa cgpdfarraymbs then a=cgpdfarraymbs(n) AddArrayRows a elseif n isa CGPDFDictionaryMBS then d=CGPDFDictionaryMBS(n) AddDictionaryRows d elseif n isa CGPDFPageMBS then pa=CGPDFPageMBS(n) AddDictionaryRows pa.Dictionary end if End EventHandler
End Control
EventHandler Sub DropObject(obj As DragItem, action As Integer) do if obj.FolderItemAvailable then run obj.FolderItem end if loop until not obj.NextItem End EventHandler
EventHandler Sub Open() me.AcceptFileDrop FileTypes.ApplicationPdf End EventHandler
Sub AddArrayRows(a as cgpdfarrayMBS) dim i,c,j as integer dim co as CGPDFObjectMBS dim b as Boolean dim n as string dim s as CGPDFStringMBS dim r as double dim st as CGPDFStreamMBS dim d as CGPDFDictionaryMBS dim aa as CGPDFArrayMBS c=a.Count List.AddRow "array with "+str(c)+" items." c=c-1 for i=0 to c if a.ArrayValue(i,aa) then List.addfolder "Array" List.CellTag(List.LastIndex,0)=a elseif a.DictionaryValue(i,d) then List.addfolder "Dictionary" List.CellTag(List.LastIndex,0)=a elseif a.ObjectValue(i,co) then AddRows co elseif a.StringValue(i,s) then List.AddRow s.Text elseif a.StreamValue(i,st) then addStream st elseif a.BooleanValue(i,b) then List.AddRow str(b) elseif a.IntegerValue(i,j) then List.AddRow str(j) elseif a.SingleValue(i,r) then List.AddRow str(r) elseif a.NullValue(i) then List.AddRow "null" else List.AddRow "?" end if next End Sub
Sub AddDictionaryRows(cd as cgpdfdictionaryMBS) dim cl as CGPDFDictionaryListMBS dim i,c as integer dim co as CGPDFObjectMBS cl=cd.List if cl<>nil then c=cl.Count-1 for i=0 to c co=cl.Value(i) List.Addfolder cl.Key(i) List.Celltag(List.LastIndex,0)=co next end if End Sub
Sub AddRows(co as cgpdfobjectMBS) const kCGPDFObjectTypeNull = 1 const kCGPDFObjectTypeBoolean = 2 const kCGPDFObjectTypeInteger = 3 const kCGPDFObjectTypeReal = 4 const kCGPDFObjectTypeName = 5 const kCGPDFObjectTypeString = 6 const kCGPDFObjectTypeArray = 7 const kCGPDFObjectTypeDictionary = 8 const kCGPDFObjectTypeStream = 9 dim b as Boolean dim i as integer dim n as string dim s as CGPDFStringMBS dim r as double dim st as CGPDFStreamMBS dim d as CGPDFDictionaryMBS dim a as CGPDFArrayMBS Select case co.Type case kCGPDFObjectTypeNull List.AddRow "null?" case kCGPDFObjectTypeBoolean if co.BooleanValue(b) then if b then List.AddRow "true" else List.AddRow "false" end if else List.AddRow "boolean?" end if case kCGPDFObjectTypeInteger if co.IntegerValue(i) then List.AddRow str(i) else List.AddRow "integer?" end if case kCGPDFObjectTypeReal if co.SingleValue(r) then List.AddRow str(r) else List.AddRow "real?" end if case kCGPDFObjectTypeName if co.NameValue(n) then List.AddRow n else List.AddRow "name?" end if case kCGPDFObjectTypeString if co.StringValue(s) then List.AddRow s.Text else List.AddRow "string?" end if case kCGPDFObjectTypeArray if co.ArrayValue(a) then List.addfolder "Array" List.CellTag(List.LastIndex,0)=a else List.AddRow "array?" end if case kCGPDFObjectTypeDictionary if co.DictionaryValue(d) then List.addfolder "Dictionary" List.CellTag(List.LastIndex,0)=d else List.AddRow "dic?" end if case kCGPDFObjectTypeStream if co.StreamValue(st) then AddStream st else List.AddRow "stream?" end if end Select End Sub
Sub addStream(st as CGPDFStreamMBS) dim type as integer dim n as string n=st.Data(type) List.AddRow "Data: "+leftb(n,100) if type=0 then List.AddRow "raw" elseif type=1 then List.AddRow "jpeg" end if List.AddFolder "Dictionary" List.Celltag(List.LastIndex,0)=st.Dictionary End Sub
Sub run(f as folderitem) if f<>nil and f.Exists then p=f.OpenAsCGPDFDocumentMBS if p<>nil then List.AddFolder "Catalog" List.Celltag(List.LastIndex,0)=p.Catalog end if dim c as integer=p.PageCount for i as integer=1 to c List.AddFolder "Page "+str(i) List.Celltag(List.LastIndex,0)=p.Page(i) next end if End Sub
Property p As cgpdfdocumentMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...