English 中文(简体)
在 OS X 中绘制 pdf 的命令行程序
原标题:Command line app to draw pdf in OS X

我正试图找到一个很好的方法来制作一个命令行应用程序(桌面上的 OS X) 来绘制并保存一个 pdf 。 如果我有一个查看的图形用户界面, 那么我会使用 NSBezierPath 对象, 并在最后做 [我的查看数据与 PDF InsideRect:r] 。

我曾经使用CGPDFCtextCreateCreate withUURL获得的CGContextRef,但非常简单。像CGCtextAddCurveToPoint这样的有两个控制点的简单东西,并没有如我所预期的那样(在中间看起来很奇怪 ) 。 而像Scott Stevenson s < a href=> (第二部分) 似乎是不可能的。

难道我漏掉了一些简单的东西吗?有没有办法构建一个没有窗口的视图并绘制到它?一个如何做扇形核心图形的方法?

简而言之,工作的主要代码是:

int main(int argc, char * argv[]) {
    MyView *myView;
    NSRect f = NSMakeRect(0,0,300,300);
    myView = [[MyView alloc] initWithFrame:f];
    NSData *data = [myView dataWithPDFInsideRect:f];
    [data writeToFile:@"x.pdf" atomically:YES];
    return 0;
}

从终端 :

clang prog.m -o prog -framework Cocoa -fobjc-gc-only
./prog
最佳回答

如果您使用命令行工具将 AppKit 链接起来,并将数据与PDF Intect 连接到一个没有窗口的独立视图上,然后从终端.app 手动运行。这将按您所期望的那样工作。如果您通过 ssh 或其他类似已启动的工作重新登录, 这可能行不通 。

问题回答

暂无回答




相关问题
Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签