//
// IFXPDFImagesSample.m
// IFXPDFFactory-iOS-SamplesBrowser
//
// Created by Sorin Nistor on 11/12/13.
// Copyright (c) 2013 IFXFactory. All rights reserved.
//
#import "IFXPDFImagesSample.h"
@implementation IFXPDFImagesSample
+ (IFXPDFDocument*) run
{
IFXPDFDocument* pdfDocument = [[IFXPDFDocument alloc] init];
IFXPDFPage* page = [IFXPDFPage emptyPage];
[pdfDocument.pages addPage:page];
IFXPDFBrush* blackBrush = [IFXPDFBrush brushWithColor:[IFXPDFRgbColor blackColor]];
IFXPDFFont* titleFont = [[IFXPDFFont alloc] init];
titleFont.fontFace = IFXPDFHelveticaBoldFontFace;
titleFont.size = 16;
IFXPDFFont* sectionFont = [[IFXPDFFont alloc] init];
sectionFont.fontFace = IFXPDFHelveticaFontFace;
sectionFont.size = 10;
[page.graphics drawText:@"Images" withFont:titleFont brush:blackBrush atX:20 y:50];
[page.graphics drawText:@"Scaling" withFont:sectionFont brush:blackBrush atX:20 y:70];
UIImage* image = [UIImage imageNamed:@"image.jpg"];
IFXPDFImage* pdfImage = [[IFXPDFImage alloc] initWithCGImage:image.CGImage];
// Draw the image 3 times on the page at different sizes.
[page.graphics drawImage:pdfImage atX:3 y:90 withWidth:100 height:67];
[page.graphics drawImage:pdfImage atX:106 y:90 withWidth:200 height:135];
[page.graphics drawImage:pdfImage atX:309 y:90 withWidth:300 height:200];
[page.graphics drawText:@"Flipping" withFont:sectionFont brush:blackBrush atX:20 y:420];
[page.graphics drawImage:pdfImage atX:20 y:440
withWidth:225 height:150 rotation:0 flip:IFXPDFNoContentFlip];
[page.graphics drawImage:pdfImage atX:300 y:440
withWidth:225 height:150 rotation:0 flip:IFXPDFVerticalContentFlip];
[page.graphics drawImage:pdfImage atX:20 y:620
withWidth:225 height:150 rotation:0 flip:IFXPDFHorizontalContentFlip];
[page.graphics drawImage:pdfImage atX:300 y:620
withWidth:225 height:150 rotation:0 flip:IFXPDFVerticalContentFlip | IFXPDFHorizontalContentFlip];
return pdfDocument;
}
@end