Some test text!
Core / Guides / Objective-C
This guide will help you run Apryse samples and integrate a free trial of the Apryse SDK into Obj-C applications on macOS. Your free trial includes unlimited trial usage and support from solution engineers.
Apryse collects some data regarding your usage of the SDK for product improvement.
If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.
Run a specific sample
OBJC folder in a sample project, for example /Samples/AddImageTest/OBJC and run the sample with./RunTest.shRun all samples
/Samples and run./runall_objc.shThe tests will run one by one.
/Samples/TestFiles/OutputThis section will show you how to use our SDK to create a simple Apryse "Hello World!" application. It will create a document with one blank page and save it as a linearized PDF in its running directory.
Navigate to the /Samples directory of the Apryse SDK and create a directory called myApp if it does not exist already. This guide will assume your project is named myApp.
Enter your myApp directory and create a OBJC directory for organization. Then create a myApp.m file. Open this file in your favorite text editor and paste:
#import <OBJC/PDFNetOBJC.h>
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
int ret = 0;
[PTPDFNet Initialize: 0]; // PDFNet must be initialized before accessing any Apryse API
PTPDFDoc* doc = [[PTPDFDoc alloc] init];
PTPDFRect * rect = [[PTPDFRect alloc] init];
[rect Set: 0 y1: 0 x2: 612 y2: 792];
PTPage* page = [doc PageCreate: rect]; // Start a new page
[doc PagePushBack: page]; // Add the page to the document
[doc SaveToFile: @"output.pdf" flags: e_ptlinearized];
NSLog(@"Hello World!");
return ret;
}
}In that same OBJC directory inside your myApp project folder add a makefile called Makefile and paste this inside:
TESTNAME=myApp
CC=clang
TARGET=$(TESTNAME)
INCLUDES=-I../../../Headers
CFLAGS=-fobjc-exceptions -fobjc-arc
LIBS=-L../../../Lib -lPDFNetC -framework Foundation
LDFLAGS=-Wl,-rpath,../../../Lib
$(TARGET): $(TARGET).m.o
@echo "Linking target: $(TARGET)"
$(CC) -o $@ $< $(LIBS) $(LDFLAGS)
$(TARGET).m.o: $(TARGET).m
@echo "Compiling target: $(TARGET)"
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES)
all: $(TARGET)
clean:
rm -fr $(TARGET) *.o
rebuild: clean all
.PHONY: all clean rebuildRun the project by executing:
makefollowed by:
./myAppIf all goes well, your terminal should output:
PDFNet is running in demo mode.
Permission: write
Hello World!Check the output.pdf that the program output in the same directory. It should be a PDF with one blank page.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales