Announcements
Notice: Upload of PDF documents is currently unavailable across the Community due to an ongoing issue.

Import PDF in Revit

Import PDF in Revit

ruben.rodriguezvalero
Observer Observer
893 Views
2 Replies
Message 1 of 3

Import PDF in Revit

ruben.rodriguezvalero
Observer
Observer

Hi there,

 

I want to import a PDF File into a Revit Sheet, but I found no function which allows me to do it with the Revit API. I only found regarding with the topic the import functions which are only for 3DM, DWG, GBXML, DNG etc files and an ImportPDF as enumtype from the PostableCommands enum, but I don't think that's usable.

 

Is there a way PDFs can be imported via Revit API like Revit does with Import PDF or Link PDF buttons in the Insert category?

 

Thanks!

0 Likes
894 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

The easiest and most effective way to address a Revit API programming task like this is to complete it manually in the user interface first and use RevitLookup and other Revit database analysis tools to analyse the effect of these actions on the database from an API point of view by comparing the state before and after:

  

https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...

 

That will show you what changed, what elements were added and what relationships they have. With that in hand, you will be able to reproduce the same programmatically.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

SillyLucky2_0
Participant
Participant

I realize this has been open for a couple years, but for anyone else who may be searching for this. You must first create an ImageType and then use ImageInstance.Create() as shown below. Hope this helps.

 

			Document doc = ActiveUIDocument.Document;
			View view = doc.ActiveView;
			string filePath = "Full File Path of .pdf";
			
			using (Transaction trans = new Transaction(doc))
			{
				trans.Start("Import PDF");
				ImageTypeOptions imageTypeOptions = new ImageTypeOptions(filePath, false, ImageTypeSource.Import);
				imageTypeOptions.Resolution = 600;
				ImageType imageType = ImageType.Create(doc, imageTypeOptions);
				
				XYZ location = new XYZ(0, 0, 0);
				ImagePlacementOptions placementOptions = new ImagePlacementOptions(location,BoxPlacement.Center);

				ImageInstance imageInstance = ImageInstance.Create(doc, view, imageType.Id, placementOptions);
				trans.Commit();
			}