Inventor Customization

Reply
Contributor
LiliaE
Posts: 18
Registered: ‎03-14-2011
Message 1 of 4 (412 Views)

C# Print to PDF without PDF AddIn.SaveCopyAs

412 Views, 3 Replies
11-26-2012 06:00 AM

I would like to use Drag2PDF to create my PDF, and I want to automate the printing process. I want to print all sheets as a one PDF file. I have created a simple C# code, which prints to PDF, but I have one problem... When I submit the print a dialogue will appear (from the Drag2PDF) which asks for the file to be saved (location and name) How can I automate this?

I may not use pdfAddIn.SaveCopyAs, it makes my PDF not good.

 

public void PrintDrawingToPDF()

        {

Inventor.DrawingPrintManager oPrintMgr = (Inventor.DrawingPrintManager)InventorOpen._invApp.ActiveDocument.PrintManager;

oPrintMgr.Printer = "Drag2PDF";

oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3;

oPrintMgr.PrintRange = PrintRangeEnum.kPrintAllSheets;

oPrintMgr.SubmitPrint();

}

ADN Support Specialist
adam.nagy
Posts: 521
Registered: ‎03-26-2007
Message 2 of 4 (382 Views)

Re: C# Print to PDF without PDF AddIn.SaveCopyAs

12-11-2012 08:54 AM in reply to: LiliaE

Hi,

 

Did you try DrawingPrintManager.PrintToFile() ?



Adam Nagy
Developer Technical Services
Autodesk Developer Network
Contributor
LiliaE
Posts: 18
Registered: ‎03-14-2011
Message 3 of 4 (374 Views)

Re: C# Print to PDF without PDF AddIn.SaveCopyAs

12-11-2012 11:58 PM in reply to: adam.nagy

Hi

Yes I have tried DrawingPrintManager.PrintToFile(), but it gives not god result. It makes PDF file, which I cannot open afterward.

Lilia

ADN Support Specialist
adam.nagy
Posts: 521
Registered: ‎03-26-2007
Message 4 of 4 (371 Views)

Re: C# Print to PDF without PDF AddIn.SaveCopyAs

12-12-2012 12:53 AM in reply to: LiliaE

Hi,

 

Just to avoid misuderstandings...

So you tried this and you could not open the pdf that this created?

public void PrintDrawingToPDF()
        {
Inventor.DrawingPrintManager oPrintMgr = (Inventor.DrawingPrintManager)InventorOpen._invApp.ActiveDocument.PrintManager;
oPrintMgr.Printer = "Drag2PDF";
oPrintMgr.PaperSize = PaperSizeEnum.kPaperSizeA3;
oPrintMgr.PrintRange = PrintRangeEnum.kPrintAllSheets;
oPrintMgr.PrintToFile("c:\\mypdf.pdf");
}

I'm asking because e.g. this worked fine for me in Inventor 2013 using VBA

Sub PrintTest()
    Dim dpm As DrawingPrintManager
    Set dpm = ThisApplication.ActiveDocument.PrintManager
    
    dpm.Printer = "Microsoft XPS Document Writer"
    dpm.PaperSize = kPaperSizeCSheet
    dpm.PrintRange = kPrintAllSheets
    dpm.PrintToFile "c:\my.xps"
End Sub

So if the exact same does not work with the Drag2PDF driver, then maybe there is some problem with that driver and you should contact its creator.

 

Cheers,



Adam Nagy
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube