Loading...

Create a pdf from an existing Worddocument

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Create a pdf from an existing Worddocument

Postby rolson » Fri Feb 25, 2011 9:49 am

Hi, I'm a newbie in GdPicture and I would be very glad to get help from you.
I'm working with MicroSoft Dynamics NAV, Ver.5 .
I have to create a PDF from an existing Worddocument. And I need a simple sample how to do this.
It can be a chart where all the relevant GdPicture methodes are included to do this. Or it can be written in any progr.-language.
I have the following features:
existing Worddocument is: c:\wordpath\text.doc
the PDF-File has to be written to: c:\pdfpath\text.pdf
I have GdPicturePro V5.
Word is closed during this process.

Thanks in advance.
Rolson
rolson
 
Posts: 1
Joined: Thu Feb 24, 2011 4:15 pm
Location: Hamburg, Germany

Re: Create a pdf from an existing Worddocument

Postby Loïc » Mon Feb 28, 2011 10:07 am

Hi Rolson,

i think you can use MS word automation in this current process:

- Open the word doc
- Convert the desired page to bitmap
- Copy the bitmap to clipboard
- Create PDF from GdPicture getting bitmap from clipboard

Here a piece of code to do the bitmap conversion in ms word:


Code: Select all
Dim oWord As Object
Set oWord = CreateObject("Word.Application")
   
oWord.Documents.Open "myfile.doc", False, True, False
oWord.Documents(1).Activate
Clipboard.Clear
oWord.Documents(1).Select
oWord.Selection.CopyAsPicture
oWord.Application.Documents(1).Close False
oWord.Quit
Set oWord = Nothing


Hope this helps.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4430
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Create a pdf from an existing Worddocument

Postby pssgdp » Sun Oct 09, 2011 8:37 pm

New to GdPicture, and I reply to this post because this is also my problem.

The posted sample code is working for me, but in my case I want to write the captured WordDocument to PDF.

The WordDocument is several pages long. I can confirm that all pages are in the clipboard because opening Word and pasting the clipboard to an empty document all pages are copied.

My question is, how can I iterate through all pages in the clipboard and create with them a PDF. Can you show me some VB 6.0 code.
pssgdp
 
Posts: 1
Joined: Sun Oct 09, 2011 8:25 pm

Re: Create a pdf from an existing Worddocument

Postby GrubyGreg » Sun Jan 15, 2012 11:31 pm

You can use this code without GdViewer:


Code: Select all
   Dim oWord As Object, WordNotOpen As Boolean, sWordPath as string, sPDF_Path as string
   
    Set oWord = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
        WordNotOpen = True
        Err.Clear
        Set oWord = CreateObject("Word.Application")
        If oWord Is Nothing Then
            MsgBox "MS Word could not start. Application will quit."
            Exit Function
        End If
    End If
   
    oWord.Documents.Open sWordPath, False, False, False, , , , , , , , , False
    oWord.Documents(1).Activate

    oWord.Documents(1).ExportAsFixedFormat OutputFileName:=sPDF_Path, _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
        OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
   
    oWord.Documents(1).Close
    If WordNotOpen Then oWord.Quit
    Set oWord = Nothing


All you'll need is the PDF export add-in you can get from Microsoft.
GrubyGreg
 
Posts: 8
Joined: Sun Feb 15, 2009 6:48 pm


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron