Have you seen <a href="http://www.htmltopdf.org">www.htmltopdf.org</a>?<br><br>Otherwise might I suggest <a href="http://www.openreport.org/">http://www.openreport.org/</a>; you could then transform your XML into RML(xml reporting format) into a PDF. You can also design RML with OpenOffice.<br>
<br>~Gerdus<br><br><div class="gmail_quote">On Tue, May 27, 2008 at 10:41 PM, Rickey, Kyle W <<a href="mailto:Kyle.Rickey@bakerhughes.com">Kyle.Rickey@bakerhughes.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Tim, thanks for your response. I realize where I've got this messed up.<br>
<br>
I had turned off Windows File Protection for<br>
C:\Program Files\Internet Explorer<br>
So that I could replace internet explorer with my own executable that<br>
calls firefox :) The reason for this is some of our proprietary software<br>
is hardcoded to launch files in IE, but there are advantages to using<br>
firefox instead.<br>
<br>
Anyway, that's a bit off topic. I restored the real IE and rebooted and<br>
now<br>
<div class="Ih2E3d">>> ie = win32com.client.Dispatch("InternetExplorer.Application")<br>
</div>works as expected.<br>
<br>
I'm also checking out PAMIE but I'm beginning to think I may be going<br>
about this whole thing the wrong way.<br>
<br>
Basically, said software above generates reports as xml files. The xml<br>
file references an xsl file used to transform the report. This xml gets<br>
launched and transformed by IE.<br>
<br>
What we want to happen is a way to take that xml file and go to PDF. As<br>
it is now we have to print from IE to the Adobe Acrobat PDF printer.<br>
This is cumbersome for the amount of reports that need run. So here are<br>
some solutions I was considering:<br>
<br>
1) COM into IE and load the xml, print it to PDF. Works, but we still<br>
get prompted for the file name to save the pdf as (my code could supply<br>
an appropriate name)<br>
<br>
2) use some python libraries (libxml2, libxslt) to transform the xml to<br>
html. That part works but now how to I make a pdf from the html file?<br>
<br>
3) COM into Adobe Acrobat and generate the pdf (no idea where to begin)<br>
<br>
4) Rewrite entire reporting system to use pdf natively. Since the data<br>
is freely available in our SQL server, this would be possible, but very<br>
time consuming.<br>
<br>
I'm open to suggestions on a better way to go about this. Also, assuming<br>
I changed the registry to point to iexplore2 (original IE) would COM'ing<br>
into work?<br>
<font color="#888888"><br>
Kyle Rickey<br>
</font><div><div></div><div class="Wj3C7c">-----Original Message-----<br>
From: <a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a><br>
[mailto:<a href="mailto:python-win32-bounces@python.org">python-win32-bounces@python.org</a>] On Behalf Of Tim Golden<br>
Sent: Tuesday, May 27, 2008 2:46 PM<br>
Cc: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
Subject: Re: [python-win32] Dispatch InternetExplorer.Application fails<br>
<br>
Rickey, Kyle W wrote:<br>
> Whenever I try the following:<br>
><br>
>>> import win32com.client<br>
>>> ie = win32com.client.Dispatch("InternetExplorer.Application")<br>
><br>
> I get this traceback:<br>
><br>
> Traceback (most recent call last):<br>
> File "<interactive input>", line 1, in <module><br>
> File "C:\Python25\Lib\site-packages\win32com\client\__init__.py",<br>
line<br>
> 95, in Dispatch<br>
> dispatch, userName =<br>
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)<br>
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",<br>
line<br>
> 98, in _GetGoodDispatchAndUserName<br>
> return (_GetGoodDispatch(IDispatch, clsctx), userName)<br>
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",<br>
line<br>
> 78, in _GetGoodDispatch<br>
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,<br>
> pythoncom.IID_IDispatch)<br>
> com_error: (-2147024894, 'The system cannot find the file specified.',<br>
> None, None)<br>
><br>
> Any ideas what would cause this? My end goal is to COM into IE and<br>
load<br>
> an xml file, then print it to PDF.<br>
<br>
FWIW, you might find it worth looking at PAMIE which uses COM<br>
the way you're doing, but which has already ironed out a few<br>
creases. That said, it doesn't really answer your question. Can<br>
you see what result this script gives:<br>
<br>
<code><br>
import os<br>
import _winreg<br>
<br>
hKey = _winreg.OpenKey (<br>
_winreg.HKEY_CLASSES_ROOT,<br>
r"InternetExplorer.Application\CLSID"<br>
)<br>
clsid, type = _winreg.QueryValueEx (hKey, "")<br>
<br>
print clsid<br>
<br>
hKey = _winreg.OpenKey (<br>
_winreg.HKEY_CLASSES_ROOT,<br>
r"CLSID\%s\LocalServer32" % clsid<br>
)<br>
server, type = _winreg.QueryValueEx (hKey, "")<br>
<br>
print server, os.path.exists (server.strip ('"'))<br>
<br>
<code><br>
<br>
This should, crudely, go through the same steps that<br>
the Dispatch process does and should show up whether<br>
IE's not where it thinks it should be. The strip ()<br>
on the server name is because, on my machine, the<br>
location is double-quoted, presumably because it's<br>
got an embedded space which would cause some problem<br>
in the mechanism.<br>
<br>
TJG<br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
</div></div></blockquote></div><br>