Search a Example in VB.NET

2006-06-30 08:13:46 by JoSchuh

Hello,

i am searching a simple Example how to print a PDF-Document
from a VB.NET Programm with some options, like Filename, OutputPath and OwnerPassword.

Is somebody in this forum who make this allready and
can give me some CodeSnippets?

Greeting Joachim


2006-06-30 08:28:44 by thesmilyface

;-)

Why don't you look at the com section?
PDFCreator\COM\Samples\Dot Net

Frank


2006-07-03 16:05:37 by asocos

Sorry, but I can't find the com section under pdfcreator. Are u sure that this section is online?

asocos


2006-07-04 07:03:18 by thesmilyface

It comes with the installation! Take a look at the path "PDFCreator\COM\Samples\Dot Net\VS2003\Visual Basic" on your computer.

Frank


2007-01-28 20:19:48 by zz

Hi,

I'm new to PDFCreator and VB as a whole.

Though I have a load of experience with all from assembler to C and C++ on top of scripting in several ways, I find it impossible to decipher how to use the examples in a way suitable for me.
Please, don't point me to the forms based solutions - I hate to have to push onscreen buttons.

I'm hoping to do automated PDF creation via VB stuff started with "winword.exe /mMyMacro MyTemplate.doc"

I suspect that *ten lines of text* would have me started. But those important lines are missing.
e.g: Add an example of printing ActiveDocument/ActiveSheet from Word or Excel: Write a plain VB Sub that can be run with singlestepping from VBE.

/zz - anonymous


2007-02-15 15:05:53 by peterh

'Create the objects needed:

Private WithEvents pdfMaker As PDFCreator.clsPDFCreator
Dim FileNm() As String
Dim pdfSourceDir, pdfTargetDir, pdfTargetFile As String

'Instantiate and start PDFMaker:
pdfMaker = New PDFCreator.clsPDFCreator
If pdfMaker.cStart(pdfParams) Then
pdfMaker.cClearCache()
pdfMaker.cPrinterStop = True
Else
MessageBox.Show("Blimey, we can't start...")
Me.Close()
End If

'Now, let's print something:
WordPrint("c:\test1.doc")
WordPrint("c:\test2.doc")

System.Threading.Thread.Sleep(1000)

'Combine print jobs into a document:
MakePDF(pdfTargetDir & "flurreblurre.pdf")

'When you're done:
Me.Close()

'Here's the procedure that we called above:
Sub WordPrint(ByVal WordFile)
'will print .DOC en .HTML files

Dim msWord As Word.Application

Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
Try
msWord = New Word.Application
msWord.Visible = False
Catch ex As Exception
Me.Cursor = Cursors.Default
MessageBox.Show("Error opening Word.Basic" & vbCrLf _
& ex.Message, _
"Error", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
Exit Sub
End Try

msWord.Documents.Open(WordFile)
msWord.ActivePrinter = "PDFCreator"
msWord.ActiveDocument.PrintOut(Background:=False)
msWord.ActiveDocument.Close(SaveChanges:=False)
msWord.Quit(False)
msWord = Nothing
GC.Collect()
End Sub

'Combine the print jobs to one document (if you've printed multiple documents)

Sub MakePDF(ByVal TargetFile)

'make sure last app is done printing.
System.Threading.Thread.Sleep(100)

pdfMaker.cCombineAll()
pdfMaker.cPrinterStop = False

'wait until combine is finished and PDF is rendered.
System.Threading.Thread.Sleep(100)

Do
FileNm = Directory.GetFiles(pdfSourceDir)
Loop Until FileNm.Length = 1

'wait until file is written out.
retry:
Try
File.Move(FileNm(0), pdfTargetDir & pdfTargetFile)
Catch ex As System.IO.IOException
GoTo retry
End Try

End Sub

'Clear up before we die gracefully:

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
'wait for PDFCreator to sleep.
System.Threading.Thread.Sleep(100)
pdfMaker.cClose()
System.Runtime.InteropServices.Marshal.ReleaseComObject(pdfMaker)
GC.Collect()
End Sub



... does this help?