//--------------------------------------------------------------------------------------- // Copyright (c) 2001-2012 by PDFTron Systems Inc. All Rights Reserved. // Consult legal.txt regarding legal and license information. //--------------------------------------------------------------------------------------- #import #import //std::string output_path = "../../TestFiles/Output/"; //std::string input_path = "../../TestFiles/"; void AnnotationHighLevelAPI(PDFDoc *doc) { // The following code snippet traverses all annotations in the document NSLog(@"Traversing all annotations in the document..."); int page_num = 1; PageIterator* itr; for (itr = [doc GetPageIterator: 1]; [itr HasNext]; [itr Next]) { NSLog(@"Page %d: ", page_num++); Page* page = [itr Current]; int num_annots = [page GetNumAnnots]; int i = 0; for (i=0; i dash( 2, 2.0 ); [txtannot SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 1 b_hr: 10 b_vr: 20] autorelease] oldStyleOnly: YES]; [txtannot SetQuaddingFormat: 0]; [first_page AnnotPushBack: txtannot]; [txtannot RefreshAppearance]; } { FreeText *txtannot = [FreeText Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 100 x2: 350 y2: 500] autorelease]]; [txtannot SetContentRect: [[[PDFRect alloc] initWithX1: 200 y1: 200 x2: 350 y2: 500] autorelease]]; [txtannot SetContents: @"\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." "\n\nAha!\n\nAnd there was much rejoicing!"]; [txtannot SetCalloutLinePointsWithKneePoint: [[[PDFPoint alloc] initWithPx: 200 py: 300] autorelease] p2: [[[PDFPoint alloc] initWithPx: 150 py: 290] autorelease] p3: [[[PDFPoint alloc] initWithPx: 110 py: 110] autorelease]]; //std::vector dash( 2, 2.0 ); [txtannot SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 1 b_hr: 10 b_vr: 20 ] autorelease] oldStyleOnly: YES]; [txtannot SetEndingStyle: e_ClosedArrow]; [txtannot SetColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [txtannot SetQuaddingFormat: 1]; [first_page AnnotPushBack: txtannot]; [txtannot RefreshAppearance]; } { FreeText *txtannot = [FreeText Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 400 y1: 10 x2: 550 y2: 400] autorelease]]; [txtannot SetContents: @"\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." "\n\nAha!\n\nAnd there was much rejoicing!"]; [txtannot SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 1 b_hr: 10 b_vr: 20 ] autorelease] oldStyleOnly: YES]; [txtannot SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [txtannot SetOpacity: 0.2 ]; [txtannot SetQuaddingFormat: 2]; [first_page AnnotPushBack: txtannot]; [txtannot RefreshAppearance]; } Page *page = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [doc PagePushBack: page]; [ew WriterBeginWithPage: page placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to this page [eb Reset: [[[GState alloc] init] autorelease]]; // Reset the GState to default [ew End]; // save changes to the current page { //Create a Line annotation... LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 250 y1: 250 x2: 400 y2: 400] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 350 py: 270] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 260 py: 370] autorelease]]; [line SetStartStyle: e_Square]; [line SetEndStyle: e_Circle]; [line SetColor: [[[ColorPt alloc] initWithX: 0.3 y: 0.5 z: 0 w: 0] autorelease] comp_num: 3]; [line SetContents: @"Dashed Captioned"]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top ]; NSMutableArray *dash = [NSMutableArray arrayWithCapacity: 2]; [dash addObject: [NSNumber numberWithDouble: 2]]; [dash addObject: [NSNumber numberWithDouble: 2]]; [line SetBorderStyle: [[[BorderStyle alloc] initWithS: e_dashed b_width: 2 b_hr: 0 b_vr: 0 b_dash: dash] autorelease] oldStyleOnly: NO]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 347 y1: 377 x2: 600 y2: 600] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 385 py: 410] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 540 py: 555] autorelease]]; [line SetStartStyle: e_Circle]; [line SetEndStyle: e_OpenArrow]; [line SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [line SetContents: @"Inline Caption"]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Inline ]; [line SetLeaderLineExtensionLength: -4]; [line SetLeaderLineLength: -12 ]; [line SetLeaderLineOffset: 2]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 10 y1: 400 x2: 200 y2: 600] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 25 py: 426] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 180 py: 555] autorelease]]; [line SetStartStyle: e_Circle]; [line SetEndStyle: e_Square]; [line SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [line SetInteriorColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] CompNum: 3]; [line SetContents: @"Offset Caption"]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top ]; [line SetTextHOffset: -60]; [line SetTextVOffset: 10]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 200 y1: 10 x2: 400 y2: 70] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 220 py: 25] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 370 py: 60] autorelease]]; [line SetStartStyle: e_Butt]; [line SetEndStyle: e_OpenArrow]; [line SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [line SetContents: @"Regular Caption"]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top ]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 200 y1: 70 x2: 400 y2: 130] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 220 py: 111] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 370 py: 78] autorelease]]; [line SetStartStyle: e_Circle]; [line SetEndStyle: e_Diamond]; [line SetContents: @"Circle to Diamond"]; [line SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [line SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] CompNum: 3]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 10 y1: 100 x2: 160 y2: 200] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 15 py: 110] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 150 py: 190] autorelease]]; [line SetStartStyle: e_Slash]; [line SetEndStyle: e_ClosedArrow]; [line SetContents: @"Slash to CArrow"]; [line SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [line SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 1 w: 0] autorelease] CompNum: 3]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 270 y1: 270 x2: 570 y2: 433] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 300 py: 400] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 550 py: 300] autorelease]]; [line SetStartStyle: e_RClosedArrow]; [line SetEndStyle: e_ROpenArrow]; [line SetContents: @"ROpen & RClosed arrows"]; [line SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [line SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] CompNum: 3]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 195 y1: 395 x2: 205 y2: 505] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 200 py: 400] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 200 py: 500] autorelease]]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 55 y1: 299 x2: 150 y2: 301] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 55 py: 300] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 155 py: 300] autorelease]]; [line SetStartStyle: e_Circle]; [line SetEndStyle: e_Circle]; [line SetContents: @"Caption that's longer than its line."]; [line SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [line SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] CompNum: 3]; [line SetShowCaption: YES]; [line SetCaptionPosition: e_Top]; [line RefreshAppearance]; [page AnnotPushBack: line]; } { LineAnnot *line=[LineAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 300 y1: 200 x2: 290 y2: 234] autorelease]]; [line SetStartPoint: [[[PDFPoint alloc] initWithPx: 310 py: 210] autorelease]]; [line SetEndPoint: [[[PDFPoint alloc] initWithPx: 380 py: 220] autorelease]]; [line SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [line RefreshAppearance]; [page AnnotPushBack: line]; } Page *page3 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page3 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page3]; { Circle *circle=[Circle Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 300 y1: 300 x2: 390 y2: 350] autorelease]]; [circle SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [circle RefreshAppearance]; [page3 AnnotPushBack: circle]; } { Circle *circle=[Circle Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 100 x2: 200 y2: 200] autorelease]]; [circle SetColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [circle SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] CompNum: 3]; NSMutableArray *dash = [NSMutableArray arrayWithCapacity: 2]; [dash addObject: [NSNumber numberWithDouble: 2]]; [dash addObject: [NSNumber numberWithDouble: 4]]; [circle SetBorderStyle: [[[BorderStyle alloc] initWithS: e_dashed b_width: 3 b_hr: 0 b_vr: 0 b_dash: dash] autorelease] oldStyleOnly: NO]; [circle SetPadding: 2]; [circle RefreshAppearance]; [page3 AnnotPushBack: circle]; } { Square *sq = [Square Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 10 y1: 200 x2: 80 y2: 300] autorelease]]; [sq SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [sq RefreshAppearance]; [page3 AnnotPushBack: sq]; } { Square *sq = [Square Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 500 y1: 200 x2: 580 y2: 300] autorelease]]; [sq SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [sq SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 1 w: 0] autorelease] CompNum: 3]; NSMutableArray *dash = [NSMutableArray arrayWithCapacity: 2]; [dash addObject: [NSNumber numberWithDouble: 4]]; [dash addObject: [NSNumber numberWithDouble: 2]]; [sq SetBorderStyle: [[[BorderStyle alloc] initWithS: e_dashed b_width: 6 b_hr: 0 b_vr: 0 b_dash: dash] autorelease] oldStyleOnly: NO]; [sq SetPadding: 4]; [sq RefreshAppearance]; [page3 AnnotPushBack: sq]; } { PDFPolygon *poly = [PDFPolygon Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 5 y1: 500 x2: 125 y2: 590] autorelease]]; [poly SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [poly SetInteriorColor: [[[ColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] autorelease] CompNum: 3]; [poly SetVertex: 0 pt: [[[PDFPoint alloc] initWithPx: 12 py: 510] autorelease]]; [poly SetVertex: 1 pt: [[[PDFPoint alloc] initWithPx: 100 py: 510] autorelease]]; [poly SetVertex: 2 pt: [[[PDFPoint alloc] initWithPx: 100 py: 555] autorelease]]; [poly SetVertex: 3 pt: [[[PDFPoint alloc] initWithPx: 35 py: 544] autorelease]]; [poly SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 4 b_hr: 0 b_vr: 0] autorelease] oldStyleOnly: NO]; [poly SetPadding: 4]; [poly RefreshAppearance]; [page3 AnnotPushBack: poly]; } { PDFPolygon *poly = [PDFPolygon Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 400 y1: 10 x2: 500 y2: 90] autorelease]]; [poly SetColor: [[[ColorPt alloc] initWithX: 1 y: 0 z: 0 w: 0] autorelease] comp_num: 3]; [poly SetInteriorColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] CompNum: 3]; [poly SetVertex: 0 pt: [[[PDFPoint alloc] initWithPx: 405 py: 20] autorelease]]; [poly SetVertex: 1 pt: [[[PDFPoint alloc] initWithPx: 440 py: 40] autorelease]]; [poly SetVertex: 2 pt: [[[PDFPoint alloc] initWithPx: 410 py: 60] autorelease]]; [poly SetVertex: 3 pt: [[[PDFPoint alloc] initWithPx: 470 py: 80] autorelease]]; [poly SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 2 b_hr: 0 b_vr: 0] autorelease] oldStyleOnly: NO]; [poly SetPadding: 4]; [poly SetStartStyle: e_RClosedArrow]; [poly SetEndStyle: e_ClosedArrow]; [poly RefreshAppearance]; [page3 AnnotPushBack: poly]; } { Link *lk = [Link Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 5 y1: 5 x2: 55 y2: 24] autorelease]]; //lk.SetColor( ColorPt(0,1,0), 3 ); [lk RefreshAppearance]; [page3 AnnotPushBack: lk]; } Page *page4 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page4 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page4]; { [ew WriterBeginWithPage: page4 placement: e_overlay page_coord_sys: YES compress: YES]; Font *font = [Font Create: [doc GetSDFDoc] type: e_helvetica embed: NO]; element = [eb CreateTextBeginWithFont: font font_sz: 16]; [element SetPathFill: YES]; [ew WriteElement: element]; element = [eb CreateTextRunWithFont: @"Some random text on the page" font: font font_sz: 16]; [element SetTextMatrix: 1 b: 0 c: 0 d: 1 h: 100 v: 500]; [ew WriteElement: element]; [ew WriteElement: [eb CreateTextEnd]]; [ew End]; } { HighlightAnnot *hl = [HighlightAnnot Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 490 x2: 150 y2: 515] autorelease]]; [hl SetColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [hl RefreshAppearance]; [page4 AnnotPushBack: hl]; } { Squiggly *sq = [Squiggly Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 450 x2: 250 y2: 600] autorelease]]; //sq.SetColor( ColorPt(1,0,0), 3 ); PDFPoint *p1 = [[[PDFPoint alloc] initWithPx: 122 py: 455] autorelease]; PDFPoint *p2 = [[[PDFPoint alloc] initWithPx: 240 py: 545] autorelease]; PDFPoint *p3 = [[[PDFPoint alloc] initWithPx: 230 py: 595] autorelease]; PDFPoint *p4 = [[[PDFPoint alloc] initWithPx: 101 py: 500] autorelease]; [sq SetQuadPoint: 0 qp: [[[QuadPoint alloc] initWithP11: p1 p22: p2 p33: p3 p44: p4] autorelease]]; [sq RefreshAppearance]; [page4 AnnotPushBack: sq]; } { Caret *cr = [Caret Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 40 x2: 129 y2: 69] autorelease]]; [cr SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [cr SetSymbol: @"P"]; [cr RefreshAppearance]; [page4 AnnotPushBack: cr]; } Page *page5 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page5 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page5]; FileSpec *fs = [FileSpec Create: [doc GetSDFDoc] path: @"../../TestFiles/Output/butterfly.png" embed: NO]; Page *page6 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page6 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page6]; int ipage; for( ipage =0; ipage < 2; ++ipage ) { int iann; for( iann =0; iann < 100; iann++ ) { if( ! (iann > e_Tag) ) { FileAttachment *fa = [FileAttachment CreateFileAttchWithFileSpec: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 50+50*iann y1: 100 x2: 70+50*iann y2: 120] autorelease] fs: fs icon_name: iann]; if(ipage) [fa SetColor: [[[ColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [fa RefreshAppearance]; if( ipage == 0 ) [page5 AnnotPushBack: fa]; else [page6 AnnotPushBack: fa]; } if( iann > e_Note ) break; Text *txt = [Text Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 10+iann*50 y1: 200 x2: 30+iann*50 y2: 220] autorelease]]; [txt SetTextIconType: iann]; [txt SetContents: [txt GetIconName]]; if( ipage ) [txt SetColor: [[[ColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [txt RefreshAppearance]; if( ipage == 0 ) [page5 AnnotPushBack: txt]; else [page6 AnnotPushBack: txt]; } } { Text *txt = [Text Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 10 y1: 20 x2: 30 y2: 40] autorelease]]; [txt SetTextIconName: @"UserIcon"]; [txt SetContents: @"User defined icon, unrecognized by appearance generator"]; [txt SetColor: [[[ColorPt alloc] initWithX: 0 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [txt RefreshAppearance]; [page6 AnnotPushBack: txt]; } { Ink *ink = [Ink Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 400 x2: 200 y2: 550] autorelease]]; [ink SetColor: [[[ColorPt alloc] initWithX: 0 y: 0 z: 1 w: 0] autorelease] comp_num: 3]; [ink SetPoint: 1 pointindex: 3 pt: [[[PDFPoint alloc] initWithPx: 220 py: 505] autorelease]]; [ink SetPoint: 1 pointindex: 0 pt: [[[PDFPoint alloc] initWithPx: 100 py: 490] autorelease]]; [ink SetPoint: 0 pointindex: 1 pt: [[[PDFPoint alloc] initWithPx: 120 py: 410] autorelease]]; [ink SetPoint: 0 pointindex: 0 pt: [[[PDFPoint alloc] initWithPx: 100 py: 400] autorelease]]; [ink SetPoint: 1 pointindex: 2 pt: [[[PDFPoint alloc] initWithPx: 180 py: 490] autorelease]]; [ink SetPoint: 1 pointindex: 1 pt: [[[PDFPoint alloc] initWithPx: 140 py: 440] autorelease]]; [ink SetBorderStyle: [[[BorderStyle alloc] initWithS: e_solid b_width: 3 b_hr: 0 b_vr: 0] autorelease] oldStyleOnly: NO]; [ink RefreshAppearance]; [page6 AnnotPushBack: ink]; } Page *page7 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page7 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page7]; { Sound *snd = [Sound Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 100 y1: 500 x2: 120 y2: 520] autorelease]]; [snd SetColor: [[[ColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [snd SetSoundIconType: e_Speaker]; [snd RefreshAppearance]; [page7 AnnotPushBack: snd]; } { Sound *snd = [Sound Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 200 y1: 500 x2: 220 y2: 520] autorelease]]; [snd SetColor: [[[ColorPt alloc] initWithX: 1 y: 1 z: 0 w: 0] autorelease] comp_num: 3]; [snd SetSoundIconType: e_Mic]; [snd RefreshAppearance]; [page7 AnnotPushBack: snd]; } Page *page8 = [doc PageCreate: [[[PDFRect alloc] initWithX1: 0 y1: 0 x2: 600 y2: 600] autorelease]]; [ew WriterBeginWithPage: page8 placement: e_overlay page_coord_sys: YES compress: YES]; // begin writing to the page [ew End]; // save changes to the current page [doc PagePushBack: page8]; int ipage1; for( ipage1 =0; ipage1 < 2; ++ipage1 ) { double px = 5, py = 520; RubberStampIcon istamp; for( istamp = e_Approved; istamp <= e_Draft; istamp = istamp + 1 ) { RubberStamp *st = [RubberStamp Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 1 y1: 2 x2: 200 y2: 200] autorelease] icon:e_Draft]; [st SetRubberStampIconType: istamp]; [st SetContents: [st GetIconName]]; [st SetRect: [[[PDFRect alloc] initWithX1: px y1: py x2: px+100 y2: py+25] autorelease]]; py = py - 100; if( py < 0 ) { py = 520; px = px + 200; } if( ipage == 0 ) //[page7 AnnotPushBack: st]; ; else { [page8 AnnotPushBack: st]; [st RefreshAppearance]; } } } RubberStamp *st = [RubberStamp Create: [doc GetSDFDoc] pos: [[[PDFRect alloc] initWithX1: 400 y1: 5 x2: 550 y2: 45] autorelease] icon: e_Draft]; [st SetRubberStampIconName: @"UserStamp"]; [st SetContents: @"User defined stamp"]; [page8 AnnotPushBack: st]; [st RefreshAppearance]; } int main(int argc, char *argv[]) { int ret = 0; [PDFNet Initialize: 0]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @try { PDFDoc *doc = [[[PDFDoc alloc] initWithFilepath: @"../../TestFiles/numbered.pdf"] autorelease]; [doc InitSecurityHandler]; // An example of using SDF/Cos API to add any type of annotations. AnnotationLowLevelAPI(doc); [doc SaveToFile: @"../../TestFiles/Output/annotation_test1.pdf" flags: e_linearized]; // An example of using the high-level PDFNet API to read existing annotations, // to edit existing annotations, and to create new annotation from scratch. AnnotationHighLevelAPI(doc); [doc SaveToFile: @"../../TestFiles/Output/annotation_test2.pdf" flags: e_linearized]; // an example of creating various annotations in a brand new document PDFDoc *doc1 = [[[PDFDoc alloc] init] autorelease]; CreateTestAnnots( doc1 ); [doc1 SaveToFile: @"../../TestFiles/Output/new_annot_test_api.pdf" flags: e_linearized]; NSLog(@"%@", @"Saved ../../TestFiles/Output/new_annot_test_api.pdf"); } @catch(NSException *e) { NSLog(@"%@", [e reason]); ret = 1; } [pool release]; return ret; }