@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