Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Excel to PDF using Win32::OLE

by Anonymous Monk
on May 02, 2006 at 16:32 UTC ( [id://546944]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am using the below method to convert excel to pdf. I am getting the pdf as a output. But when i open the output pdf i am getting the error,

"Acrobat could not open 'report.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). To create an Adobe PDF document, go to the source application. Then print the document to pdf".

Previously in my system i had Adobe 6.0 and all worked perfectly, but now i removed and installed Adobe 7.0 i am getting the above error. Where am i going wrong?

my @thing = $sheet->PrintOut({ Copies => 1, PrintToFile => 'True', ActivePrinter => "Adobe PDF",#version 7 # ActivePrinter => "Acrobat PDFWriter",#version 6 PrToFileName => "C:\\Report.pdf", #Collate => 1, });

Replies are listed 'Best First'.
Re: Excel to PDF using Win32::OLE
by JamesNC (Chaplain) on May 03, 2006 at 01:52 UTC
    I don't think you are doing anything wrong. I think we saw this problem at work. Uninstalling 6.0 is part of the problem/solution I believe. The 7.0 stuff only works with a clean build on our machines(ie. not an upgrade). We were miffed about it and ended up having to use the Acrobat vb object to create a .ps and then distill it on older installs. Maybe wiping the registry of 6.0 and re-installing 7.0? When you run this manually in Excel does it produce a readable PDF?

      Thanks for your reply. Yes, when i do manually it converts properly and not getting any error while opening. Only when i do this through perl, i am getting error. Also if i didnt give the path in the Printout method, it saves the pdf file in C:/Program Files/Outlook express. I didnt changed my current directory to that. Why it is happening like that. I think that might be the reason.

        Then the next thing is to duplicate your perl call back in a VB sub and run that sub in the VB debugger. I would also see it Excel never quits properly using your Perl script. We encountered a problem with Win32::OLE after we went to a new service pack on Win2K and we had not changed our Perl where Win32::OLE would not let Excel die. The problem went away again after we migrated to XP. We found a workaround and it looks like voodoo. I will share it with you if you find the same issue, but I would try the manual VB sub thing and also maybe running with $excel->{Visible} = 1; just so I could keep excel alive and have a lookie at the pdf as if I were doing it manually.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://546944]
Approved by TStanley
Front-paged by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-20 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found