<?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 current opened drawing to pdf file. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11371586#M11947</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;As Norman.yuan pointed out,&amp;nbsp; the Close and save command caused error&lt;/P&gt;&lt;LI-CODE lang="general"&gt;currentDocument.CloseAndSave(fname)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Perhaps a "Save as" command may work?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;currentDatabase.SaveAs(strTempFileName, currentDatabase.OriginalFileVersion)&lt;/LI-CODE&gt;&lt;P&gt;or you may interested in working with side database in case your current drawing is closed.&lt;BR /&gt;&lt;A href="https://adndevblog.typepad.com/autocad/2012/04/batch-process-in-memory-1.html" target="_blank"&gt;https://adndevblog.typepad.com/autocad/2012/04/batch-process-in-memory-1.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 21 Aug 2022 11:27:53 GMT</pubDate>
    <dc:creator>ntclmain</dc:creator>
    <dc:date>2022-08-21T11:27:53Z</dc:date>
    <item>
      <title>Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370613#M11944</link>
      <description>&lt;P&gt;Hello, everyone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I am making a function to save current drawing file to pdf file.&lt;/P&gt;&lt;P&gt;my simple code is as followings.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[CommandMethod("svp")]
        public static void ExportPdf()
        {
            var documentManager = Application.DocumentManager;
            var currentDocument = documentManager.MdiActiveDocument;
            var db = currentDocument.Database;
            var ed = currentDocument.Editor;
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.DefaultExt = ".dwg"; // Required file extension 
            fileDialog.Filter = "Acad Files (*.dwg)|*.dwg|All Files (*.*)|*.*"; // Optional file extensions

            fileDialog.ShowDialog();
            string fname = fileDialog.FileName;
            currentDocument.CloseAndSave(fname);
            //using (Aspose.CAD.Image image = Aspose.CAD.Image.)
            //{
            //    // Create an instance of CadRasterizationOptions and set its various properties
            //    Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
            //    rasterizationOptions.PageWidth = 1600;
            //    rasterizationOptions.PageHeight = 1600;

            //    // Create an instance of PdfOptions
            //    Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();

            //    // Set the VectorRasterizationOptions property
            //    pdfOptions.VectorRasterizationOptions = rasterizationOptions;

            //    // Export CAD to PDF
            //    image.Save(fname, pdfOptions);
            //}

        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone's help.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 13:21:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370613#M11944</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T13:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370711#M11945</link>
      <description>&lt;P&gt;While your command is running, you cannot close the current document, because the command runs in document context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Seeing the code you commented out below, I am not sure why you need to close the current document. If you have to, your command has to be session command (adding CommandFlags.Session to the CommandMethod attributes).&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 14:54:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370711#M11945</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-08-20T14:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370760#M11946</link>
      <description>Thanks for your reply.&lt;BR /&gt;How can I export without closing?</description>
      <pubDate>Sat, 20 Aug 2022 15:26:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11370760#M11946</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-20T15:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11371586#M11947</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;As Norman.yuan pointed out,&amp;nbsp; the Close and save command caused error&lt;/P&gt;&lt;LI-CODE lang="general"&gt;currentDocument.CloseAndSave(fname)&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Perhaps a "Save as" command may work?&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;currentDatabase.SaveAs(strTempFileName, currentDatabase.OriginalFileVersion)&lt;/LI-CODE&gt;&lt;P&gt;or you may interested in working with side database in case your current drawing is closed.&lt;BR /&gt;&lt;A href="https://adndevblog.typepad.com/autocad/2012/04/batch-process-in-memory-1.html" target="_blank"&gt;https://adndevblog.typepad.com/autocad/2012/04/batch-process-in-memory-1.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 11:27:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11371586#M11947</guid>
      <dc:creator>ntclmain</dc:creator>
      <dc:date>2022-08-21T11:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11371641#M11948</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to clarify your question: do you want to know why you get the error, or how to "export" current drawing as PDF?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the former, I already answered. So, you need to explain why you have to close current drawing? If you do not have to close it, have you tried to go ahead with the other code without closing current drawing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the latter, since you are using third part component to do the export, sorry, I have no knowledge of it. However, it is a very common topic to use AutoCAD .NET API to generate PDF from drawing, and you can find a lot of sample code in this forum/online.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 12:56:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11371641#M11948</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-08-21T12:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11374464#M11949</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="goldhorsemillion_0-1661274252601.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1106760iF089400C783F4632/image-size/medium?v=v2&amp;amp;px=400" role="button" title="goldhorsemillion_0-1661274252601.png" alt="goldhorsemillion_0-1661274252601.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;I save a dwg file wity database.saveas but when I open that pdf file, I can find this error message.&lt;/P&gt;&lt;P&gt;How can I resolve this?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 00:06:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11374464#M11949</guid>
      <dc:creator>MarkJamesRogolino</dc:creator>
      <dc:date>2022-08-23T00:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Export current opened drawing to pdf file.</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11374585#M11950</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12396114"&gt;@MarkJamesRogolino&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;It seems that we have misunderstood.&lt;/P&gt;&lt;P&gt;In my previous post, the "saveas" command just save the drawing with .dwg file format, not&amp;nbsp; .pdf format.&lt;/P&gt;&lt;P&gt;You used "saveas" command to save a drawing with a .pdf extension, just like edit the filename extension ---- You failed because that fake .pdf file is still in .dwg format.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*&lt;BR /&gt;There is no built-in "save" method from .dwg to .pdf.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, you must do a plot (print) to a PDF plotter, such as&amp;nbsp;"DWG To PDF.pc3", just like your printing action to PDF,&amp;nbsp; but the difference is: now you print by code.&lt;BR /&gt;I found a old topic which may help&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/net/export-pdf-from-vb-net/td-p/3471934" target="_blank"&gt;https://forums.autodesk.com/t5/net/export-pdf-from-vb-net/td-p/3471934&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 02:30:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-current-opened-drawing-to-pdf-file/m-p/11374585#M11950</guid>
      <dc:creator>ntclmain</dc:creator>
      <dc:date>2022-08-23T02:30:43Z</dc:date>
    </item>
  </channel>
</rss>

