If the input pdf file i 7 pages, I will get 7 tiff files, but they are all of the first page only. How do I get at the other pages correctly. I am doing the setCurrentPage, and setting it correctly, but I never get more than the first page. Does it have to do with how I am drawing it out?
Any help would be great.
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> NSImage *myImageToSave;
NSImage *image1;
NSData *data;
int numPages = 0;
int curpage = 0;
NSNumber *iAsNumber;
NSPDFImageRep *myPDF;
NSData *myPDFasData;
NSSize kUSLetterSize = NSMakeSize(612, 792);
NSString *tempString;
NSString *temp2String;
NSString *temp3String;
myPDFasData = [[NSData alloc] initWithContentsOfFile:@"/myFile.pdf"];
myPDF = [[NSPDFImageRep alloc] initWithData:myPDFasData];
curpage = [myPDF currentPage];
numPages = [myPDF pageCount];
do
{
[myPDF setCurrentPage:curpage+1];
myPDFasData = [myPDF PDFRepresentation];
image1 = [[NSImage alloc] initWithData:myPDFasData];
myImageToSave = [[NSImage alloc] initWithSize:kUSLetterSize];
[myImageToSave lockFocus];
[image1 compositeToPoint:NSZeroPoint operation:NSCompositeCopy];
[myImageToSave unlockFocus];
data = [myImageToSave TIFFRepresentationUsingCompression:NSTIFFCompressi onCCITTFAX3 factor:nil];
tempString = @"/Output.pdf.";
if(curpage<10)
{
temp2String = [tempString stringByAppendingString:@"00"];
iAsNumber = [[NSNumber alloc] initWithInt:curpage+1];
temp3String = [temp2String stringByAppendingString:[iAsNumber stringValue]];
}
else
{
temp2String = [tempString stringByAppendingString:@"0"];
iAsNumber = [[NSNumber alloc] initWithInt:curpage+1];
temp3String = [temp2String stringByAppendingString:[iAsNumber stringValue]];
}
[data writeToFile:temp3String atomically:YES];
curpage++;
}while( curpage < numPages);</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">