Rect

Sample Obj-C code for using Apryse SDK to change a page's MediaBox using Rect class. Learn more about our iOS SDK and PDF Editing & Manipulation Library.

1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6#import <OBJC/PDFNetOBJC.h>
7#import <Foundation/Foundation.h>
8
9int main(int argc, char *argv[])
10{
11 @autoreleasepool {
12 int ret = 0;
13 [PTPDFNet Initialize: 0];
14
15 @try // Test - Adjust the position of content within the page.
16 {
17 NSLog(@"_______________________________________________");
18 NSLog(@"Opening the input pdf...");
19
20 PTPDFDoc *input_doc = [[PTPDFDoc alloc] initWithFilepath: @"../../TestFiles/tiger.pdf"];
21 [input_doc InitSecurityHandler];
22
23 PTPageIterator *pg_itr1 = [input_doc GetPageIterator: 1];
24
25 PTPDFRect * media_box = [[pg_itr1 Current] GetMediaBox];
26
27 [media_box SetX1: [media_box GetX1] - 200]; // translate the page 200 units (1 uint = 1/72 inch)
28 [media_box SetX2: [media_box GetX2] - 200];
29
30 [media_box Update: [[PTObj alloc] init]];
31
32 [input_doc SaveToFile: @"../../TestFiles/Output/tiger_shift.pdf" flags: 0];
33
34 NSLog(@"Done. Result saved in tiger_shift...");
35 }
36 @catch(NSException *e)
37 {
38 NSLog(@"Caught PDFNet exception: %@", e.reason);
39 ret = 1;
40 }
41 [PTPDFNet Terminate: 0];
42 return ret;
43 }
44}

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales