<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export pdf from VB.net in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472098#M55441</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you will have to go through the plot-functionality using the "&lt;EM&gt;&lt;FONT color="#666699"&gt;DWG to PDF.pc3&lt;/FONT&gt;&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;That makes also more sense for setting the page-size you like to have as result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
    <pubDate>Fri, 25 May 2012 06:32:56 GMT</pubDate>
    <dc:creator>Alfred.NESWADBA</dc:creator>
    <dc:date>2012-05-25T06:32:56Z</dc:date>
    <item>
      <title>Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3471934#M55440</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I'm trying to make an application that would take a drawing(dwg) and convert it to pdf.&amp;nbsp; Since I can do it directly in&amp;nbsp;autocad 2013, i presume that there should be a function in the API, that i could use to do the same.&amp;nbsp; So far, i tried with AcadDocument.export(filename, FileExtension, AcadSelectionSet) with no luck. I cannot put PDF as a valid file extension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public sub SaveToPDF(ByVal psfilename As String)&lt;/P&gt;&lt;P&gt;Dim oAutocad As AutoCAD.AcadApplication = New AutoCAD.AcadApplication()&lt;/P&gt;&lt;P&gt;Dim oAcadDoc As AutoCAD.AcadDocument = oAutocad.Documents.Open(psfilename, True)&lt;/P&gt;&lt;P&gt;Dim sFolder As String = psfilename.Substring(0, psfilename.LastIndexOf("\") + 1)&lt;/P&gt;&lt;P&gt;Dim sFilename As String = psfilename.Substring(psfilename.LastIndexOf("\") + 1, (psfilename.Length - psfilename.LastIndexOf("\")) - (psfilename.Length - psfilename.LastIndexOf(".") + 1))&lt;/P&gt;&lt;P&gt;Dim oSS As AcadSelectionSet = Nothing&lt;/P&gt;&lt;P&gt;Try &amp;nbsp;oSS = oAutocad.ActiveDocument.SelectionSets.Add("MySet")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oSS.Select(AcSelect.acSelectionSetAll)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oAutocad.ActiveDocument.Export(sFolder &amp;amp; sFilename &amp;amp; ".pdf", ".pdf", oSS)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oSS.Delete() Catch ex As Exception &amp;nbsp;success = False &amp;nbsp;oSS.Delete() &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oSS = Nothing&lt;/P&gt;&lt;P&gt;End Try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Each Doc In oAutocad.Documents&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;Doc.Close(False)&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;oAutocad.Quit()&lt;/P&gt;&lt;P&gt;oAutocad = Nothing&lt;/P&gt;&lt;P&gt;end sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have an idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 01:32:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3471934#M55440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-25T01:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472098#M55441</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you will have to go through the plot-functionality using the "&lt;EM&gt;&lt;FONT color="#666699"&gt;DWG to PDF.pc3&lt;/FONT&gt;&lt;/EM&gt;"&lt;/P&gt;&lt;P&gt;That makes also more sense for setting the page-size you like to have as result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 06:32:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472098#M55441</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-05-25T06:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472334#M55442</link>
      <description>&lt;P&gt;See if this helps&lt;/P&gt;&lt;PRE&gt;    Imports System.IO
     ......................
    &amp;lt;CommandMethod("pdfing")&amp;gt; _
    Public Sub TestPDF()
        SaveToPDF("C:\Test\blah.dwg")
    End Sub
    Public Sub SaveToPDF(ByVal psfilename As String)

        Dim oAutocad As AcadApplication = New AcadApplication

        oAutocad.Visible = True

        oAutocad.WindowState = AcWindowState.acMax

        Dim success As Boolean = False

        Dim oAcadDoc As AcadDocument = oAutocad.Documents.Open(psfilename, False, "")

        'Dim sFolder As String = Path.GetDirectoryName(psfilename) 'psfilename.Substring(0, psfilename.LastIndexOf("\") + 1)

        'Dim sFilename As String = Path.GetFileNameWithoutExtension(psfilename) 'psfilename.Substring(psfilename.LastIndexOf("\") + 1, (psfilename.Length - psfilename.LastIndexOf("\")) - (psfilename.Length - psfilename.LastIndexOf(".") + 1))

        Dim oSS As AcadSelectionSet = Nothing

        Try
           
            Dim ftype(0) As Short
            ftype(0) = 410
            Dim fdata(0) As Object
            fdata(0) = "Model"
            oAutocad.ZoomExtents()

            oSS = oAcadDoc.SelectionSets.Add("MySet")

            oSS.Select(AcSelect.acSelectionSetAll, Nothing, Nothing, ftype, fdata)

            CreatePDF(oAcadDoc)
     
            If oAcadDoc.Saved Then
                oAcadDoc.Close(False)
            End If
            oAcadDoc = Nothing
         
            oAutocad.Quit()

            oAutocad = Nothing
            success = True
        Catch ex As Exception
            MsgBox(ex.Message + vbLf + ex.StackTrace)
            success = False
        Finally

            MsgBox(vbLf + "Program ended up with result of: " + success.ToString)

        End Try

    End Sub
    ''-------------------------------------------------------------''
    Sub CreatePDF(acDoc As AcadDocument) 'by RBell

        Dim PtConfigs As AcadPlotConfigurations
        Dim PlotConfig As AcadPlotConfiguration
        Dim PtObj As AcadPlot
        Dim BackPlot As Object

        'Create a new plot configutrarion with all needed parameters
        PtObj = acDoc.Plot
        PtConfigs = acDoc.PlotConfigurations
        'Add a new plot configuration
        PtConfigs.Add("PDF", False)
        'The plot config you created become active
        PlotConfig = PtConfigs.Item("PDF")
        'Use this method to set the scale
        PlotConfig.StandardScale = AcPlotScale.acScaleToFit
        'Updates the plot
        PlotConfig.RefreshPlotDeviceInfo()
        'Here you specify the pc3 file you want to use
        PlotConfig.ConfigName = "DWG To PDF.pc3"
        'You can select the plot style table here
        PlotConfig.StyleSheet = "acad.ctb"
        'Specifies whether or not to plot using the plot styles
        PlotConfig.PlotWithPlotStyles = True

        'If you are going to create pdf files in a batch mode,
        'I would recommend to turn off the BACKGROUNDPLOT system variable,
        'so autocad will not continue to do anything until finishes
        'the pdf creation
        BackPlot = acDoc.GetVariable("BACKGROUNDPLOT")
        acDoc.SetVariable("BACKGROUNDPLOT", 0)
        'Updates the plot
        PlotConfig.RefreshPlotDeviceInfo()
        ''Acad.ActiveDocument.ActiveLayout.CopyFrom(plotconfig)
        'Now you can use the PlotTofile method
        If PtObj.PlotToFile(Replace(acDoc.FullName, "dwg", "pdf"), PlotConfig.ConfigName) Then
            acDoc.Utility.Prompt(vbLf + "PDF Was Created")
        Else
            acDoc.Utility.Prompt(vbLf + "PDF Creation Unsuccessful")
        End If
        'If you wish you can delete th plot configuration you created
        'programmatically, and set the 'BACKGROUNDPLOT' system variable
        'to its original status.
        PtConfigs.Item("PDF").Delete()
        PlotConfig = Nothing
        acDoc.SetVariable("BACKGROUNDPLOT", BackPlot)

    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 11:55:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472334#M55442</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-25T11:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472990#M55443</link>
      <description>&lt;P&gt;Thanks guys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I've been able to convert my drawing in a pdf.&amp;nbsp; The next step is turning my application into a windows service.&amp;nbsp; i'm not able to start autocad.&amp;nbsp; I see the process comming up in task manager but the next line ain't executed.&amp;nbsp; Is there a way to open autocad in a windows service application?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 17:29:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/3472990#M55443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-25T17:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4641031#M55444</link>
      <description>ho andre&lt;BR /&gt;there is a trick you can do if you still interesets&lt;BR /&gt;dudi</description>
      <pubDate>Thu, 21 Nov 2013 13:17:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4641031#M55444</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-21T13:17:40Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4646397#M55445</link>
      <description>&lt;P&gt;Dudi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd be interested inthis trick...&lt;/P&gt;</description>
      <pubDate>Sat, 23 Nov 2013 08:53:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4646397#M55445</guid>
      <dc:creator>btmsoftware</dc:creator>
      <dc:date>2013-11-23T08:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4648131#M55446</link>
      <description>&lt;P&gt;Hi Hallex.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks great. Is there any ways to export to pdf without open the drawing (using ReadDWGfile(...&lt;BR /&gt;) method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2013 01:12:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/4648131#M55446</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-25T01:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8357966#M55447</link>
      <description>&lt;P&gt;Hi andre,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have the same problem of converting the dwg file to pdf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please kindly show your code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 06:52:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8357966#M55447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-25T06:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358089#M55448</link>
      <description>&lt;P&gt;Oh my mistake...&lt;/P&gt;&lt;P&gt;I found my pdf files&lt;/P&gt;&lt;P&gt;They were in "C:\Users\Administrator\AppData\Local\Temp"&lt;/P&gt;&lt;P&gt;Thank Hallex and RBell!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 07:52:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358089#M55448</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-25T07:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358397#M55449</link>
      <description>&lt;P&gt;Dudi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any chance you could share this trick with us?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 09:43:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358397#M55449</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-25T09:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358466#M55450</link>
      <description>&lt;P&gt;I just copy the Hallex's code. It works but I thought it could not work before because I cannot find my pdf files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But&amp;nbsp;&lt;SPAN&gt;Hallex's code actually works!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The pdf files are hidden in somewhere in the computer. You may&amp;nbsp;check it out with "CreatePDF" and see his code the line of&amp;nbsp; "If PtObj.PlotToFile(Replace(acDoc.FullName, "dwg", "pdf"), PlotConfig.ConfigName) Then".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The variable of "FullName" is the path of the pdf files saved.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 10:10:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8358466#M55450</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-10-25T10:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8359182#M55451</link>
      <description>&lt;P&gt;I think the tip was about using AutoCAD as a Windows service, not the PDF generation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anybody has a trip to use AutoCAD as a windows service, please, share&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2018 13:54:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/8359182#M55451</guid>
      <dc:creator>btmsoftware</dc:creator>
      <dc:date>2018-10-25T13:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/9397186#M55452</link>
      <description>&lt;P&gt;Hi !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this may be the right way for my problem. i want to use the exportpdf-function of autocad via vb.net.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but what means the .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;  Imports System.IO
     ......................
    &amp;lt;CommandMethod("pdfing")&amp;gt; _
    Public Sub TestPDF()
        SaveToPDF("C:\Test\blah.dwg")
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;so current i did know how to find the defintion of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;AcadPlotConfigurations&lt;BR /&gt;AcadPlotConfiguration&lt;/LI&gt;&lt;LI&gt;AcPlotScale&lt;/LI&gt;&lt;LI&gt;...&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;regards Jan&lt;/P&gt;</description>
      <pubDate>Tue, 24 Mar 2020 16:54:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/9397186#M55452</guid>
      <dc:creator>jan_tappenbeck</dc:creator>
      <dc:date>2020-03-24T16:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Export pdf from VB.net</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/10015183#M55453</link>
      <description>&lt;P&gt;Hello ,&lt;SPAN&gt;Add application from the project tab then select AutoCad.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2021 07:44:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-pdf-from-vb-net/m-p/10015183#M55453</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-20T07:44:39Z</dc:date>
    </item>
  </channel>
</rss>

