[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating PDF reports
From: |
Steven LeMaire |
Subject: |
Re: Creating PDF reports |
Date: |
Wed, 27 Feb 2013 21:48:48 -0500 |
I've gotten a bit further along with this (I had a small problem in my main.m)
with the Xvfb method.
Apologies for the long output, but basically it runs to completion now, except
the pdf file it creates is empty.
I have an NSLog that prints out the contents of the NSTextView.
2013-02-27 16:51:59.714 report[8305] Failed to determine offsets for style 1
2013-02-27 16:51:59.715 report[8305] Failed to determine offsets for style 2
2013-02-27 16:51:59.715 report[8305] Failed to determine offsets for style 3
2013-02-27 16:51:59.716 report[8305] Failed to determine offsets for style 4
2013-02-27 16:51:59.717 report[8305] Failed to determine offsets for style 5
2013-02-27 16:51:59.717 report[8305] Failed to determine offsets for style 6
2013-02-27 16:51:59.718 report[8305] Failed to determine offsets for style 7
2013-02-27 16:51:59.719 report[8305] Failed to determine offsets for style 8
2013-02-27 16:51:59.719 report[8305] Failed to determine offsets for style 9
2013-02-27 16:51:59.720 report[8305] Failed to determine offsets for style 10
2013-02-27 16:51:59.721 report[8305] Failed to determine offsets for style 11
2013-02-27 16:51:59.721 report[8305] Failed to determine offsets for style 12
2013-02-27 16:51:59.722 report[8305] Failed to determine offsets for style 13
2013-02-27 16:51:59.723 report[8305] Failed to determine offsets for style 14
2013-02-27 16:51:59.723 report[8305] Failed to determine offsets for style 15
2013-02-27 16:51:59.798 report[8305] The textView object contains: *** This is
the test string ***
2013-02-27 16:51:59.799 report[8305] styleoffsets ... guessing offsets
2013-02-27 16:51:59.799 report[8305] styleoffsets ... guessing offsets
The "guessing offsets" repeats about 30 times.
This is my Report object:
@implementation Rep
-(id)init {
if (self = [super init]) {
textView = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 612.0,
792.0)];
return self;
} else
return nil;
}
-(void)addText {
[textView insertText:@"*** This is the test string ***"];
}
-(void)doPrint {
NSMutableData *pdfData = [[NSMutableData alloc] init];
NSPrintOperation *printOp = [NSPrintOperation PDFOperationWithView:textView
insideRect:[textView bounds] toData:pdfData];
NSLog(@"The textView object contains: %@", [textView text]);
[printOp runOperation];
[pdfData writeToFile:@"/home/steven/pdftest.pdf" atomically:YES];
}
@end
I also had a warning there was no default printer setup, so I created a "PDF
writer" type printer in CUPS and the message went away.
Perhaps I need a "real" printer setup (even though there is none) and set as
default in CUPS ?
Many Thanks
Steven
On 2013-02-27, at 7:36 PM, Steven LeMaire wrote:
> I gave it a go with Xvfb, by first setting up the display like so:
>
> export DISPLAY=:1
> Xvfb :1 -screen 0 1024x768x16 &
>
> Then running the program (in gdb), but it breaks unfortunately:
>
> Breakpoint 1, main (argc=1, argv=0xbfffeed4) at main.m:14
> 14 id pool = [[NSAutoreleasePool alloc] init];
> (gdb) n
> 17 app = [NSApplication sharedApplication];
> (gdb) n
> 2013-02-27 14:48:31.995 report[6785] Failed to determine offsets for style 1
> 2013-02-27 14:48:31.996 report[6785] Failed to determine offsets for style 2
> 2013-02-27 14:48:31.996 report[6785] Failed to determine offsets for style 3
> 2013-02-27 14:48:31.997 report[6785] Failed to determine offsets for style 4
> 2013-02-27 14:48:31.998 report[6785] Failed to determine offsets for style 5
> 2013-02-27 14:48:31.998 report[6785] Failed to determine offsets for style 6
> 2013-02-27 14:48:31.999 report[6785] Failed to determine offsets for style 7
> 2013-02-27 14:48:31.1000 report[6785] Failed to determine offsets for style 8
> 2013-02-27 14:48:32.000 report[6785] Failed to determine offsets for style 9
> 2013-02-27 14:48:32.001 report[6785] Failed to determine offsets for style 10
> 2013-02-27 14:48:32.002 report[6785] Failed to determine offsets for style 11
> 2013-02-27 14:48:32.002 report[6785] Failed to determine offsets for style 12
> 2013-02-27 14:48:32.003 report[6785] Failed to determine offsets for style 13
> 2013-02-27 14:48:32.004 report[6785] Failed to determine offsets for style 14
> 2013-02-27 14:48:32.004 report[6785] Failed to determine offsets for style 15
> Warning:
> Cannot insert breakpoint 0.
> Error accessing memory address 0x94fb986: Input/output error.
>
> Did i do something wrong ? I also tried using NSAttributedString hoping to
> try and make RTF instead, but it seems to have the same X requirements
>
> On 2013-02-27, at 6:35 AM, Robert Slover wrote:
>
>> If you have Xvfb available, that can serve as a dummy X server for such
>> purposes. (vfb==virtual frame buffer). Unfortunately, it still requires a
>> bunch of X infrastructure such as font libraries, X shared libs, etc.
>>
>> On Feb 27, 2013, at 6:02, Steven LeMaire <address@hidden> wrote:
>>
>>> I tried adding the [NSApplication sharedApplication] but when I run the
>>> program with that in the code, it attempts to connect to a X server (which
>>> there is none in this case) and ends.
>>>
>>> For the NEEDS_GUI=YES, do I just plug that anywhere in the makefile ?
>>>
>>> thsnks !
>>>
>>>
>>> On 2013-02-27, at 3:10 AM, Fred Kiefer wrote:
>>>
>>>>
>>>>
>>>> Am 27.02.2013 um 05:07 schrieb Germán "A. Arias" <address@hidden>:
>>>>
>>>>> El mar, 26-02-2013 a las 22:04 -0500, Steven LeMaire escribió:
>>>>>> Hello Everyone,
>>>>>>
>>>>>> I'm looking at writing a simple program that will run scheduled on a
>>>>>> server, which will query a database and using the results, generate a
>>>>>> PDF report to be emailed to some users. I'm not too sure how I should go
>>>>>> about doing this, my first attempt at this was to write a tool that
>>>>>> creates an NSTextView, and simply inserts the text into it. It would
>>>>>> then use the NSPrintOperation PDFOperationWithTextView method to create
>>>>>> an NSMutableData object, which could them be written to a file.
>>>>>>
>>>>>> The problem I'm having now is, it requires AppKit, so I'm building with
>>>>>> application.make included in my makefile, but it then is complaining
>>>>>> there's no shared application object.
>>>>>> Basically, I don't want a graphical interface, so I'm not sure where to
>>>>>> go from here.
>>>>>>
>>>>>> Any guidance would be appreciated.
>>>>>>
>>>>>> Thanks
>>>>>> Steven
>>>>>>
>>>>>
>>>>> Make a tool instead an app. You only need add in GNUmakefile:
>>>>>
>>>>> NEEDS_GUI = YES
>>>>
>>>> That wont help much. What you need to do is initialize the application.
>>>> Just add [NSApplication sharedApplication] somewhere in your code before
>>>> you use any of the other gui classes.
>>>>
>>>
>>>
>>> _______________________________________________
>>> Gnustep-dev mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/gnustep-dev
>
- Creating PDF reports, Steven LeMaire, 2013/02/26
- Re: Creating PDF reports, A. Arias, 2013/02/26
- Re: Creating PDF reports, Fred Kiefer, 2013/02/27
- Re: Creating PDF reports, Steven LeMaire, 2013/02/27
- Re: Creating PDF reports, Steven LeMaire, 2013/02/27
- Re: Creating PDF reports,
Steven LeMaire <=
- Re: Creating PDF reports, Riccardo Mottola, 2013/02/28
- Re: Creating PDF reports, Steven LeMaire, 2013/02/28
- Re: Creating PDF reports, Riccardo Mottola, 2013/02/28
- GS WM assumptiuons (was Re: Creating PDF reports), Derek Fawcus, 2013/02/28
- Re: Creating PDF reports, Fred Kiefer, 2013/02/28
- Re: Creating PDF reports, Eric Wasylishen, 2013/02/28
- Message not available
- Re: Creating PDF reports, Steven LeMaire, 2013/02/28
Re: Creating PDF reports, Pirmin Braun, 2013/02/27