Fehler beim Drucken

  • Fehler beim Drucken

    Hallo ich möchte das beim drücken auf ein Button ein Dokument ausgedrückt wird.
    Folgenden Code verwende ich:

    Quellcode

    1. - (IBAction)Drucken:(id)sender {
    2. // Create the print settings.
    3. NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
    4. [printInfo setTopMargin:0.0];
    5. [printInfo setBottomMargin:0.0];
    6. [printInfo setLeftMargin:0.0];
    7. [printInfo setRightMargin:0.0];
    8. [printInfo setHorizontalPagination:NSFitPagination];
    9. [printInfo setVerticalPagination:NSFitPagination];
    10. // NSURL* nsurl=[NSURL URLWithString:@"de.openoffice.org/doc/sonstiges/Iso-Image-brennen.pdf"];
    11. NSData* data;
    12. NSString* pfad = [@"/Users/neuerdrachen/my.pdf" stringByExpandingTildeInPath];
    13. [data initWithContentsOfFile:pfad];
    14. // Create the document reference.
    15. PDFDocument *pdfDocument = [[[PDFDocument alloc] initWithData:data] autorelease];
    16. // Invoke private method.
    17. // NOTE: Use NSInvocation because one argument is a BOOL type. Alternately, you could declare the method in a category and just call it.
    18. BOOL autoRotate = YES;
    19. NSMethodSignature *signature = [PDFDocument instanceMethodSignatureForSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
    20. NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
    21. [invocation setSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
    22. [invocation setArgument:&printInfo atIndex:2];
    23. [invocation setArgument:&autoRotate atIndex:3];
    24. [invocation invokeWithTarget:pdfDocument];
    25. // Grab the returned print operation.
    26. NSPrintOperation *op = nil;
    27. [invocation getReturnValue:&op];
    28. // Run the print operation without showing any dialogs.
    29. [op setShowsPrintPanel:YES];
    30. [op setShowsProgressPanel:YES];
    31. [op runOperation];
    32. }
    Alles anzeigen



    Ich bekomme aber zur Laufzeit folgende Fehlermeldung:







    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo}



    2011-06-16 13:52:58.644 MTContentManager[1758:903] -[NSWindow initWithContentsOfFile:]: unrecognized selector sent to instance 0x100528580

    2011-06-16 13:52:58.645 MTContentManager[1758:903] -[NSWindow initWithContentsOfFile:]: unrecognized selector sent to instance 0x100528580






    Habt ihr eine Idee woran das liegen kann?
  • Ich weiß zwar nicht so recht worum es geht aber...

    [@"/Users/neuerdrachen/my.pdf" stringByExpandingTildeInPath];


    Fehlt da vor dem [ nicht etwas ? Der Syntax schaut mir ziemlich spanisch aus ?(
    _____________________________
    Alle Angaben ohne Gewähr :)

    On the internet you can be anything you want. It's strange that so many people choose to be stupid.


    Superbientem animus prosternet
  • Algoros schrieb:

    Habt ihr eine Idee woran das liegen kann?


    Ja
    Xcode 4 sucks – „,Multiple exclamation marks‘, he went on, shaking his head, are a sure sign of a diseased mind.‘“ (Terry Pratchett 1992: Eric)

    "Wir ordnen und befehlen hiermit allen Ernstes, dass die Advocati wollene schwarze Mäntel, welche bis unter das Knie gehen, unserer Verordnung gemäß zu tragen haben, damit man die Spitzbuben schon von weitem erkennt." (Friedrich Wilhelm I., Soldatenkönig)
  • Algoros schrieb:

    Quellcode

    1. NSData* data;
    2. NSString* pfad = [@"/Users/neuerdrachen/my.pdf" stringByExpandingTildeInPath];
    3. [data initWithContentsOfFile:pfad];


    Versuch es mal so:

    Quellcode

    1. data = [[NSData alloc] initWithContentsOfFile:pfad];


    Jetzt solltest Du mit dem Kopf gegen eine Wand rennen oder etwas Einführendes lesen.
    Xcode 4 sucks – „,Multiple exclamation marks‘, he went on, shaking his head, are a sure sign of a diseased mind.‘“ (Terry Pratchett 1992: Eric)

    "Wir ordnen und befehlen hiermit allen Ernstes, dass die Advocati wollene schwarze Mäntel, welche bis unter das Knie gehen, unserer Verordnung gemäß zu tragen haben, damit man die Spitzbuben schon von weitem erkennt." (Friedrich Wilhelm I., Soldatenkönig)