English 中文(简体)
• 如何从UIImage中拿出Pdf?
原标题:How can i make Pdf from UIImage?

我在“伊默勒”一案中有一例“UIImage”,我想将这一形象传给“人民抵抗力量”囚犯,这样,移徙才有可能吗? 我没有这样做的想法。

最佳回答

如果您有UIImage 意见书,则采用这种方法:

-(NSData*)makePDFfromView:(UIView*)view
{
    NSMutableData *pdfData = [NSMutableData data];

    UIGraphicsBeginPDFContextToData(pdfData, view.bounds, nil);
    UIGraphicsBeginPDFPage();
    CGContextRef pdfContext = UIGraphicsGetCurrentContext();
    [view.layer renderInContext:pdfContext];
    UIGraphicsEndPDFContext();

    return pdfData;
}

类似情况:

NSData *pdfData = [self makePDFfromView:imgView];
//[pdfData writeToFile:@"myPdf.pdf" atomically:YES]; - save it to a file
问题回答

它不是非常困难的,但有一些步骤来确立一切。 从根本上说,你需要创建人民抵抗力量的图表背景,然后用标准绘图指令加以利用。 简单地将UIImage带入人民抵抗力量,你可以做如下事情:

// assume this exists and is in some writable place, like Documents
NSString* pdfFilename = /* some pathname */

// Create the PDF context
UIGraphicsBeginPDFContextToFile(pdfFilename, CGRectZero, nil); // default page size
UIGraphicsBeginPDFPageWithInfo(CGRectZero, nil);

// Draw the UIImage -- I think PDF contexts are flipped, so you may have to
// set a transform -- see the documentation link below if your image draws
// upside down
[theImage drawAtPoint:CGPointZero];

// Ending the context will automatically save the PDF file to the filename
UIGraphicsEndPDFContext();

详情见。 为提取和印刷指南。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签