Results 1 to 8 of 8

Thread: Converting / Printing files to PDF

  1. #1
    Lively Member
    Join Date
    May 12
    Posts
    91

    Question Converting / Printing files to PDF

    Hi,

    I'm looking for advice and examples on how to convert files to PDF.

    The files could be anything:
    Office docs .docx, .xlsx
    Images .jpg, .gif
    AutoCAD files .dwg .dxf
    Microstation files .dgn

    Ideally I'd like to do this within the VB application, I'm hoping there is maybe an add-in I can apply, so that each user of the application does not require a program or file installed on their machine. (if possible)

    Another option might be:
    As each machine has CutePDF installed which allows users to select CutePDF as their printer and effectively convert any file to a PDF. Using VB to basically run a print function using this printer, if that makes sense. But I want to avoid this as I assume this would require user interaction in naming the file and choosing it's location...

    Any help or suggestions would be appreciated.

    Thanks.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,486

    Re: Converting / Printing files to PDF

    Can you use CutePDF with command line arguments/parameters?

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 06
    Location
    Providence, RI - USA
    Posts
    9,167

    Re: Converting / Printing files to PDF

    The free version of CutePDF writer requires user interaction. The commercial custom PDF Writer allows you to print to it programmatically and you can distribute it with your app royalty free. I'm unaware of any free solution that allows you to convert programmatically any document to pdf. If you happen to come across one, please let me know.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4
    Lively Member
    Join Date
    May 12
    Posts
    91

    Re: Converting / Printing files to PDF

    dunfiddlin - I've never looked so I am not sure, how would I find out..?

    stanav - Do you use the "commercial custom PDF Writer" and can you link me to where I can purchase this please..?

    Thanks for your replies.
    Last edited by squatman; Aug 8th, 2012 at 04:17 PM.

  5. #5
    Lively Member
    Join Date
    May 12
    Posts
    91

    Re: Converting / Printing files to PDF

    Having looked I assume you was referring to the Custom version of CutePDF with programmatical access...

    I found this:
    http://www.cutepdf.com/solutions/pdfwriter3.asp

    So in answer to your question dunfiddlin, I guess I need to buy this version to be able to use commands...

    Are there any classes or anything to achieve this another way, what if it was just for .docx files..?

    Thanks guys.

  6. #6
    Addicted Member
    Join Date
    Aug 11
    Posts
    253

    Re: Converting / Printing files to PDF

    I haven't used it myself but apparently PDFCreator includes a COM component that you can print to programmatically.

  7. #7
    Lively Member
    Join Date
    May 12
    Posts
    91

    Re: Converting / Printing files to PDF

    samuelk - Thanks a lot for your reply, I'll be sure to check this out!

  8. #8
    Lively Member
    Join Date
    May 12
    Posts
    91

    Question Re: Converting / Printing files to PDF

    After installing PDFCreator I have ended up with the following code:

    vb Code:
    1. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    2.         Dim oWord As Word.Application
    3.         Dim oDoc As Word.Document
    4.  
    5.         oWord = New Word.Application
    6.         oDoc = oWord.Documents.Open("C:\test\test.docx")
    7.  
    8.         oWord.ActivePrinter = "PDFCreator"
    9.         oWord.PrintOut(Copies:=1, PrintToFile:=True, Collate:=True, FileName:="C:\test\test.docx", OutputFileName:="C:\test\Test.pdf")
    10.         oWord.Close()
    11.     End Sub

    It creates a PDF file, with believable filesize, but when I try to open it says the file may be corrupt and also "oWord.Close()" fails...

    If anyone can see any obviously fixes please can you let me know.

    Also is this the only way to use PDF converters like this, where you can to control thing within the program i.e. "oWord.PrintOut()" as I want to convert non microsoft office files that might not be able to controlled within VB this way...

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •