Author Topic: Printing PDF or DWF files  (Read 8985 times)

0 Members and 1 Guest are viewing this topic.

Kheilmann

  • Guest
Printing PDF or DWF files
« on: July 27, 2006, 03:09:57 PM »
All I want to do is print.  The question is do I need to open the file with the appropriate app first?  With excel I set the Variable...
Dim Xobj as Excel.Application
Set Xobj = Createobject("Excel.Application")
etc. etc.
Do I do the same with DWF and/or PDF files?
Also, do I need any references?  I've seen several for both, but am not sure which if any to load...???

Currently all my Cad files are saved as dwf for external use, so my question above is more in that direction; however, if I need to, I will start exporting them out as PDF's instead of dwf's.

Thanks in advance for your help....


Dnereb

  • Guest
Re: Printing PDF or DWF files
« Reply #1 on: July 27, 2006, 03:52:28 PM »
Some of the latest versions of PDF printers support VB(A) exposure.
I've helped someone out on that subject a few weeks ago at work.
Luckily for me and not for you I'm on a holiday the coming 2,5 weeks so i can't give you the sample code.
I seem to remember it was PDFcreator or maybe Cutepdf (don't think so)
If you install it and look in the list of referencesyou can find it with some educated guessing.
to find to string I would go for"pdfcreator.application" or however it's described in the reference list
On the other hand do you need to late bind?
you can run it silent in background setting a default directory and so on.

Dave R

  • Guest
Re: Printing PDF or DWF files
« Reply #2 on: July 27, 2006, 03:56:57 PM »
Not sure about PDF files as I haven't tried automating printing for them, however, you can automate the printing of DWF files if you add the appropriate references. You can download the API help for the DWF viewer from Autodesk. That will get you started with some examples.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Printing PDF or DWF files
« Reply #3 on: July 27, 2006, 04:33:50 PM »
do you want code to print dwf and or pdf from autocad?  I have both
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kheilmann

  • Guest
Re: Printing PDF or DWF files
« Reply #4 on: July 27, 2006, 06:23:57 PM »
I'm actually running my code from Access.  I know there may be some differences, hopefully it would not be too difficult.

I figured there is some reference that needs to be loaded, after that it should not be that big a deal I assume.

I can't imagine the code being anymore than a few lines.

I will download the API help Dave R recommended, and see what I can come up with...
If I have any questions I know where to find you.  :)

Thanks for your help...

Kheilmann

  • Guest
Re: Printing PDF or DWF files
« Reply #5 on: July 31, 2006, 05:23:56 PM »
OK, I have 3 references loaded for DWF (viewer, selection, and shellext).  I assume I need dwfviewer. but I am not sure.

Dwfviewer.application does not seem to be available when declaring my variable.
Also, setting my variable WhipObj to a dwfviewer document seems to also not be available.
Am I missing something?
Do I need an AutoCAD reference also?

Oh, and the Library is 1.0 for all 3 dwf references.  Not sure if that is the latest or not.  Would it make a difference?

Thanks in advance for your help...


David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Printing PDF or DWF files
« Reply #6 on: July 31, 2006, 05:59:48 PM »
i have never tried to print from Access, but this is how I do it from Autocad
Code: [Select]
Public Sub StandardsPDF()
    Dim Layout As AcadLayout, strfile As String
    strfile = ThisDrawing.Path & "\" & (Left(ThisDrawing.Name, (Len(ThisDrawing.Name)) - 4)) & ".pdf"
    Set Layout = ThisDrawing.ActiveLayout
    Layout.RefreshPlotDeviceInfo
    Layout.ConfigName = "HPDSH"
    Layout.PLOTTYPE = acExtents
    Layout.PlotRotation = ac0degrees    'Rotate to 90 for long sheets
    Layout.StyleSheet = "STANDARDS.ctb"
    'Layout.CanonicalMediaName = "Tabloid"
    Layout.CanonicalMediaName = "Letter"
    Layout.PaperUnits = acInches
    Layout.StandardScale = ac1_1
    'Layout.StandardScale = acScaleToFit
    Layout.ShowPlotStyles = False
    ThisDrawing.Plot.NumberOfCopies = 1
    Layout.CenterPlot = True
    Layout.RefreshPlotDeviceInfo
    ThisDrawing.Plot.PlotToDevice
    'ThisDrawing.Plot.PlotToFile strfile
    Set Layout = Nothing
    ThisDrawing.Close (True)
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kheilmann

  • Guest
Re: Printing PDF or DWF files
« Reply #7 on: July 31, 2006, 06:56:49 PM »
I could be wrong, but it looks as if you are actually creating the DWF's.
I want to print DWF files that have already been created and saved to a network location.

I've pretty much hit a road block. 
There was a glimmer of hope on adesk forums but the frm I needed to load to get the code was a VB6 frm and apparently I can not load that into a VBA editor.  Not sure if it would help anyway, but it seems to be the best shot I have of figuring this out as of right now....

I'll keep looking.
I appreciate any help you guys can offer...


quicksilver

  • Guest
Re: Printing PDF or DWF files
« Reply #8 on: August 01, 2006, 08:09:56 AM »
Try opening the VB form in notepad.  You should be able to read the code and cut and paste from there into vba.

Dave R

  • Guest
Re: Printing PDF or DWF files
« Reply #9 on: August 01, 2006, 08:27:52 AM »
Kevin -

See the attached screenshot. You need all these references for accessing the DWF API.

OK, I have 3 references loaded for DWF (viewer, selection, and shellext).  I assume I need dwfviewer. but I am not sure.

Dwfviewer.application does not seem to be available when declaring my variable.
Also, setting my variable WhipObj to a dwfviewer document seems to also not be available.
Am I missing something?
Do I need an AutoCAD reference also?

Oh, and the Library is 1.0 for all 3 dwf references.  Not sure if that is the latest or not.  Would it make a difference?

Thanks in advance for your help...



David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Printing PDF or DWF files
« Reply #10 on: August 01, 2006, 10:48:29 AM »
sorry, i misunderstood you.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Printing PDF or DWF files
« Reply #11 on: August 01, 2006, 10:51:27 AM »
I forget which thread it was, but somebody posted a link to a blog at adesk that was talking about dwf.  The guy that runs that blog, emailed me back and gave me a link for dwf toolkit.  Im trying to find that for you
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Dave R

  • Guest
Re: Printing PDF or DWF files
« Reply #13 on: August 01, 2006, 12:28:44 PM »
Cmdr -

The DWF toolkit is more for applications that need to read and write the DWF directly. Kevin wants to be able to print DWFs using Access VBA. This can be done using the free DWF viewer from Autodesk and the viewer's API. Autodesk's website has the API Doc along with some examples of using it, one of which includes printing.

http://usa.autodesk.com/adsk/servlet/index?id=823771&siteID=123112
http://autodesk.blogs.com/between_the_lines/2005/06/dwf_toolkit_7_w.html


Kheilmann

  • Guest
Re: Printing PDF or DWF files
« Reply #14 on: August 01, 2006, 02:52:00 PM »
Thanks for all the help guys.  Just one last question (I think)...

All the samples in the API are either too vague, or is just completely over my head...
I don't see anything specifically about printing or openning dwf files...
I see where they are iterating through pages and such, but they assume a dwf file is already loaded.
I want my dwf file to be a variable which is set depending on certain code criteria. 

Here is what I think I need from the API sample, I just need to modify it to allow me to either print or open a dwf file with dwfviewer through Access vba.

I have this.  I assume it is to activate the dwfviewer so I can open my DWF files?????
Dim Viewer As EPlotViewer.IAdEPlotViewer2

I don't thing I need this, but I think I probably need something similar???????
Private Sub SetSourcePath(FileName As String)
       'Accept the full path, relative path, FTP or HTTP path.
       CExpressViewerControl1.SourcePath = FileName
End Sub

Not sure if I need any of this, since it seems like the file is already loaded and just deals after the fact.
Private Sub CExpressViewerControl1_OnEndLoadItem(ByVal bstrItemName As String, ByVal vData As Variant, ByVal vResult As Variant)

Set Viewer = Nothing
Set Viewer = CExpressViewerControl1.DocumentHandler
If bstrItemName = "DOCUMENT" Then
'The document is fully loaded, but the sheets may not have
'been loaded yet.
'At this point, you can access all the sheets in the DWF file.
Call SetToolbarProperties
Call IterateThroughPages

ElseIf bstrItemName = "SHEET" Then
 
'A sheet is finished loading, either as a first sheet upon opening
'the document or as a change of sheets.
Call IterateThroughLayers   

ElseIf bstrItemName = "SPACE" Then

'A 3D DWF sheet has been loaded.
'Currently, the DWF Viewer does not support any APIs for 3D DWFs.
'You can give a message to the user that a 3D DWF has been loaded.
MsgBox "A 3D DWF has been loaded"

End If
End Sub