Forum: Ruby How to use WIN32OLE to Save As PDF

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2010-01-22 20:08
Hi,

I've been trying to figure out how to use Win32OLE to save as a PDF.  It
doesn't seem like there's any good documentation on how to do this, so I
was hoping someone here has experience with this.

Anyhoo, if anyone's tried this before, and actually gotten somewhere
with it, please let me know.

Thanks
33ec7e55a251c1be8d6febfd929aebbe?d=identicon&s=25 Greg Kujawa (gregarican)
on 2010-01-22 20:23
(Received via mailing list)
On Jan 22, 2:08 pm, Joe Peck <j...@scimedsolutions.com> wrote:
> --
> Posted viahttp://www.ruby-forum.com/.

Ever look at this?

http://ruby-pdf.rubyforge.org/pdf-writer/

Seems like it'd be straightforward, at least moreso than digging into
all of the OLE stuff...
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2010-01-22 20:27
Greg Kujawa wrote:
> Ever look at this?
>
> http://ruby-pdf.rubyforge.org/pdf-writer/
>
> Seems like it'd be straightforward, at least moreso than digging into
> all of the OLE stuff...

Yeah, I've seen that.  I just figure there has to be a way to save
directly as a PDF using WIN32OLE.  If only there was like a list of
FileFormats that it uses....
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2010-01-22 20:45
(Received via mailing list)
On Fri, Jan 22, 2010 at 2:20 PM, gregarican <greg.kujawa@gmail.com>
wrote:
> On Jan 22, 2:08 pm, Joe Peck <j...@scimedsolutions.com> wrote:

> Ever look at this?
>
> http://ruby-pdf.rubyforge.org/pdf-writer/

Please don't use PDF::Writer anymore.  If you need pure Ruby PDF
generation, Prawn is the way to go.
If there are features that are holding you back, let us know.

(Disclosure: I am the maintainer of Prawn and the 'if all hell breaks
loose' maintainer of PDF::Writer (originally written by Austin
Ziegler) )

-greg
2a745e2d109928984604d0b573e55855?d=identicon&s=25 Phillip Gawlowski (Guest)
on 2010-01-22 20:47
(Received via mailing list)
On 22.01.2010 20:27, Joe Peck wrote:

> Yeah, I've seen that.  I just figure there has to be a way to save
> directly as a PDF using WIN32OLE.

Only if an OLE capable tool is installed that a) accepts your input and
b) writes PDF (for example, OO.o Writer, or MS Word 2007).
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2010-01-22 21:05
Alrighty, so I figured it out.

It turns out 17 is the FormatType for PDF, so you just have to do
something like this:

document.SaveAs(filename, 17)

I didn't see any documentation about this, but we just started going up
from 0 as a FormateType, and once we hit 17, it made a valid PDF!!
31e038e4e9330f6c75ccfd1fca8010ee?d=identicon&s=25 Gregory Brown (Guest)
on 2010-01-22 21:18
(Received via mailing list)
On Fri, Jan 22, 2010 at 3:05 PM, Joe Peck <joep@scimedsolutions.com>
wrote:
> Alrighty, so I figured it out.
>
> It turns out 17 is the FormatType for PDF, so you just have to do
> something like this:
>
> document.SaveAs(filename, 17)

FormatType for what?  You never mentioned what program you're using
via win32ole (i'm assuming MS Office?).  In the future, be sure to do
that so that people know what you're talking about.

-greg
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (austin)
on 2010-01-23 15:23
Gregory Brown wrote:
> On Fri, Jan 22, 2010 at 2:20 PM, gregarican <greg.kujawa@gmail.com>
> wrote:
>> On Jan 22, 2:08�pm, Joe Peck <j...@scimedsolutions.com> wrote:
>> Ever look at this?
>>
>> http://ruby-pdf.rubyforge.org/pdf-writer/
> Please don't use PDF::Writer anymore.  If you need pure Ruby PDF
> generation, Prawn is the way to go.
> If there are features that are holding you back, let us know.
>
> (Disclosure: I am the maintainer of Prawn and the 'if all hell breaks
> loose' maintainer of PDF::Writer (originally written by Austin
> Ziegler) )

What Greg said.

-austin
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2010-01-25 14:20
>
> FormatType for what?  You never mentioned what program you're using
> via win32ole (i'm assuming MS Office?).  In the future, be sure to do
> that so that people know what you're talking about.
>
> -greg

Sorry.  Yeah, I'm using MS Office through win32ole.
2119f016588ba13373484491bd2dd6d1?d=identicon&s=25 Joe Peck (fatcatt316)
on 2010-01-25 20:59
In case anyone else is searching for how to use win32ole to save as a
PDF, Mr. Mullet posted some nice instructions here:
http://rubyonwindows.blogspot.com/2010/01/saving-m...
Eff93e9bbe063b7136c9b6f218071a09?d=identicon&s=25 Marco Mastrodonato (marcomd)
on 2010-01-26 23:11
Joe Peck wrote:
> In case anyone else is searching for how to use win32ole to save as a
> PDF, Mr. Mullet posted some nice instructions here:
> http://rubyonwindows.blogspot.com/2010/01/saving-m...

To can save office 2007 documents to pdf format you have to download the
free ms plugin, google => 'pdf plugin office 2007'
2a745e2d109928984604d0b573e55855?d=identicon&s=25 Phillip Gawlowski (Guest)
on 2010-01-27 12:11
(Received via mailing list)
On 26.01.2010 23:12, Marco Mastrodonato wrote:

> To can save office 2007 documents to pdf format you have to download the
> free ms plugin, google =>  'pdf plugin office 2007'

Better way: install Office 2007 Service Pack 2, which includes the
functionality.

http://support.microsoft.com/?scid=kb%3Ben-us%3B95...
This topic is locked and can not be replied to.