Hi Wade,
first of all, you forget - in your code - the lines to instanciate a Shell:
Dim s As Shell
s = New Shell
I added these lines and I was able to execute the shared code.
After some seconds, I realized where to find the cwoutput.pdf file.
The created pdf seems to be correct since I was able to load it using a
double-click.
Like you wrote, the generated pdf is not open by the provided code.
Using the following AppleScript, I know that the file does not have file type
nor a file creator. And that is certainly where the problem lies.
I added some code / some debug and found that f2 is not Nil, but does not
exists.
I reported the path to an EditField and found:
Macintosh HD:FireFox Downloads:REALbasic
2009r3:/Users/emile_schwarz/Documents/cwoutput.pdf
The string comes from the debugger.
Nox, here is a solution (not the nicer nor the best, but it works):
Replace the line:
f2 = GetFolderItem(filestring)
by the line:
f2 = SpecialFolder.Documents.Child("cwoutput.pdf")
Of course, a rewrite of the code is needed (too many expositions to errors
right now), but the code now works.
BTW: the used html file is the REALbasic "ReleaseNotes.html" file, not
something fancy ;-).
HTH,
Emile
WARNING:
I tried a large html file (with images) and the pdf was empty until I replace a
non ascii character in the file name.
I tried another smaller file and it worked - without images -.
The last test I've done is with a home made (with a keyboard) html file: OK
except for the icons or images which are not in the PDF file.
>Date: Sat, 30 May 2009 18:13:28 -0500
>From: Wade Maxfield
>Subject: printing htmlviewer in MacOSX
>To: realbasic-nug@lists.realsoftware.com
>Message-ID:
> <45a1b53e0905301613t4c6ae09dtcdc0c23e775a922c@mail.gmail.com>
>Content-Type: text/plain; charset=ISO-8859-1
>
> I am also trying to print the htmlviewer content in realbasic. 2009R2
>
> I have this code, thanks to Shawn Giese, software.sirkevi.com, and it
>mostly works:
>
>dim filestring as string
>dim f, f1,f2 as folderitem
>dim execString as String
>
> f = GetFolderItem("PointerToHTMLFile.html")
> f1 = SpecialFolder.Documents
> filestring = f1.ShellPath+"/cwoutput.pdf"
>
> if f <> nil and f1 <> nil then
> execString = "/System/Library/Printers/Libraries/convert -f "+ f.ShellPath +"
> -o " + filestring
> s.execute execString
> // added hoping would fix launch
> execString = "chmod a+rwx "+filestring
> s.Execute execString
>//
> f2 = GetFolderItem(filestring)
> if f2 = Nil then Return
> f2.launch
> end if
>
> The problem is that f2.launch fails to launch the pdf file. It is there.
>If I Right-click and choose open in Finder, it launches in preview as
>expected. The "chmod" was added to see if the executable bits were needed,
>then I gave it universal privs to see if any difference was made.
>
> Anyone know why f2.launch() fails? I'm f.launch() -ing a pre-made pdf file
>in another part of the program, and that works.
> BTW, the convert --help shows that the default is "application/pdf" for
>the created file, using "-j application/pdf" does not help this problem (It
>was in there first).
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|