export PDF without layers

export PDF without layers

Anonymous
Not applicable
3,169 Views
18 Replies
Message 1 of 19

export PDF without layers

Anonymous
Not applicable

I have an iLogic function that will export the drawing as a pdf and I can control certain options on the export as well. I was wondering is there a way to control whether or not the exported pdf contains the layer information or not?

0 Likes
3,170 Views
18 Replies
Replies (18)
Message 2 of 19

MechMachineMan
Advisor
Advisor
Printing to PDF will not show layers. The only other way I have come across is to have PDF software to flatten the document.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 19

Anonymous
Not applicable

I got to looking at the code I am using and I am technically doing a save as and am keeping it vertor format as when it is rasterized as a print it has errors or other sorts with alignments and colors and such.... So it does come out with layers.

0 Likes
Message 4 of 19

xiaodong_liang
Autodesk Support
Autodesk Support
Hi,

I do not find an option that can enable / disable layers. While I am not clear on what you described in message 3. It sounds you hit a problem where you think it is caused from layer? Could you elaborate the problem? probably we can try to sort how to solve the problem, instead of trying to find option to disable layers.
0 Likes
Message 5 of 19

kevin_hay
Contributor
Contributor

Hi there.

 

If the user who raised the initial post is similar to myself, removing layer information is nothing to do with encountering problems, it is much simpler.

 

Security!

 

Many firms, including who I work for wish a PDF file to represent the drawing content as it would appear on paper only. Hence we do not wish layer information to be made public as part of the electronic file. This leaves us with two options, the first is to scan a paper drawing which has quality issues, the second is to use an aftermarket PDF solution such as adobe which has limitations as the task cannot be automated via iLogic.

 

Easy solution is to provide functionality within the PDF export options and API to choose whether you want to embed layer information or not.

 

Thanks,

Kev.

Message 6 of 19

xiaodong_liang
Autodesk Support
Autodesk Support
Hi Kevin,

Thank you for the comments. I can log a wish.
Message 7 of 19

xiaodong_liang
Autodesk Support
Autodesk Support
just fyi the wish ID # TFS-140221
Message 8 of 19

kevin_hay
Contributor
Contributor
Thanks!
0 Likes
Message 9 of 19

freesbee
Collaborator
Collaborator

...there is also a corresponding idea to vote (and maybe it makes sense to vote also the other related ideas on PDF translator improvements):

PDF Translator flatten layers functionality 

@xiaodong_liangmaybe you could pair the wish ID # TFS-140221 to the idea with almost 50 votes?

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes
Message 10 of 19

JelteDeJong
Mentor
Mentor

Just a thought. you could try to use a pdf-printer instead of the build in pdf export function. maybe layers do not get sent to the printer. (I did not test this but maybe it works)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 11 of 19

freesbee
Collaborator
Collaborator

@JelteDeJong wrote:

Just a thought. you could try to use a pdf-printer instead of the build in pdf export function. maybe layers do not get sent to the printer. (I did not test this but maybe it works)


Yes, it works (I did test it of course a few years ago), but how do you realize it on 1000+ drawings?

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes
Message 12 of 19

JelteDeJong
Mentor
Mentor

For batch exporting i have not a complete answer. But i would try to create PostScript-files

Dim doc As DrawingDocument = ThisApplication.ActiveDocument
doc.PrintManager.PrintToFile("c:\temp\testfile.ps")

and then convert the PostScript-files to pdf.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 13 of 19

Anonymous
Not applicable

@JelteDeJong wrote:

Just a thought. you could try to use a pdf-printer instead of the build in pdf export function. maybe layers do not get sent to the printer. (I did not test this but maybe it works)


I realize this is an old(er) thread, but an additional limitation of Print to PDF (at least the built in one that comes with Windows) is paper size. I exclusively deal with ANSI D-size sheets, and currently the Print to PDF only handles up to ANSI B-Size sheets (11x17, or "Tabloid").

0 Likes
Message 14 of 19

tomasz.sztejka
Advocate
Advocate
Unfortunately since 2021 the document display name is not sent do printer anymore, so automation is terribly tricky as all prints ends in files with meaningless names.
Message 15 of 19

nithin9JMXC
Participant
Participant

Following.

0 Likes
Message 16 of 19

freesbee
Collaborator
Collaborator

...the idea I mentioned in message #9 is currently by 128 votes.
Just keep pushing it and maybe something will move in the PDF Translator area...

PDF Translator flatten layers functionality 

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes
Message 17 of 19

nithin9JMXC
Participant
Participant

Hi, thank you @freesbee. But, sorry, I was looking for a built-in option in Inventor if available. Earlier I was doing it in the way you suggested, but the problem with that is, it's time consuming (need to rename, find the right folder directory to save in etc.) Not easy when its lot of files.

0 Likes
Message 18 of 19

freesbee
Collaborator
Collaborator

...and the idea is exactly about "changing the only built in option" of inventor in order to achieve what you want, becasue the current built in option (called PDF Translator) cannot do that.

I suspect your only viable possibility is to vote and promote those ideas, so that soon or later Autodesk will react. That is why I wrote the idea some years ago...

Massimo Frison
CAD R&D // PDM Admin · Hekuma GmbH
0 Likes
Message 19 of 19

g.georgiades
Advocate
Advocate

@freesbee @nithin9JMXC There are open source third party libraries that can be used to remove layers from pdfs programatically.

 

Eg for my company, I have rules that export the pdf with temp_#.pdf using the pdf translator, then use this snippet to flatten it using iText (Inventor 2025+) and then delete the temporary file.

It can easily be baked into multi file pdf exporter rules, programs, etc.

 

Though the only way to truly make the pdf uneditable is to rasterize it, but then you loose the vector quality and the file size can get larger. Even PDF signing, there are a few ways to get around it if one's goal is to get to hidden graphics underneath a mask.

 

'Requires iText7+, Inventor 2025+
'iText is AGPL3!
Imports iText.Kernel.Pdf


#If False Then 'Hides VB.Net Compiler Error in Visual Studio, but still works with iLogic
AddReference "****\itext\itext.io.dll"
AddReference "****\itext\itext.kernel.dll"
AddReference "System.Drawing.dll"
AddReference "PresentationFramework.dll"
#End If


''''code to export drawing to pdf

'partial flatten pdf. this removes easy access layer control, but it still allows object control because it does not rasterize!
        Dim failture As Boolean = false
		Dim pdoc As PdfDocument = Nothing
		Try
			pdoc = New PdfDocument(New PdfReader(oDataMedium.FileName), New PdfWriter(newpdfname))
			Dim cat = pdoc.GetCatalog()
			Dim dict = cat.GetPdfObject().GetAsDictionary(PdfName.OCProperties)
			If dict.ContainsKey(PdfName.OCGs) Then
				dict.Remove(PdfName.OCGs)
			End If
		Catch
			failure = True
			MsgBox("Failed to faltten/rename PDF, do you have the original open?")
		Finally
			If pdoc IsNot Nothing Then
				pdoc.Close()
			End If
		End Try

		If Not failure Then
			Try
				System.IO.File.Delete(oDataMedium.FileName)
			Catch
			End Try
		End If

 

0 Likes