Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

blurred views in PDF exported through the API

dibujocad
Enthusiast

blurred views in PDF exported through the API

dibujocad
Enthusiast
Enthusiast

Hello,

I'm using the PDF Translator AddIn via the API to export drawings to PDF. But when I opened the PDF the views appear blurred.

I thought the reason could be that the drawing is exported before being updated. However I tried it, but it still didn't work. I also tried with "DrawingDocument.MakeAllViewsPrecise, but nothing has changed.

Any suggestion?

                        

                    Set oAsmDrawDoc = ThisApplication.ActiveDocument

                    'Update drawing before exporting to PDF

                    oAsmDrawDoc.Update2 (True)

                    'Make all the views precise

                    oAsmDrawDoc.MakeAllViewsPrecise

                    If oAsmDrawDoc.Update2(True) = True Then

                        'Call Sub Export PDF (save drawings as PDF)

                        ExportPDF

                        'Save the updated document

                        oAsmDrawDoc.Save2 (True)

                        'Close AsmDrawDoc and active oAsm again

                        oAsmDrawDoc.Close

                    End If

 

Thanks in advance

 

0 Likes
Reply
Accepted solutions (1)
633 Views
5 Replies
Replies (5)

bshbsh
Collaborator
Collaborator

are those shaded views? are they using bitmaps with low resolution maybe?

0 Likes

jR0sal3s
Advocate
Advocate
this is what i used....resolution at 400 or set it higher.

' Get the PDF translator Add-In.
Dim PDFAddIn As TranslatorAddIn
Set PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")

'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument

' Check if the Document Type is a drawing. If it isn't, display a message & exit the Sub.
If (oDocument.DocumentType <> kDrawingDocumentObject) Then
MsgBox "Drawing document not available for Plotting, switch to Drawing Document", , "Drawing not found"
Set oDocument = Nothing
Exit Sub
End If

Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism

' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap

' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium

' Check whether the translator has 'SaveCopyAs' options
If PDFAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then

' Options for drawings...

oOptions.Value("All_Color_AS_Black") = 0

oOptions.Value("Remove_Line_Weights") = 0
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2
'oOptions.Value("Custom_End_Sheet") = 4

End If
0 Likes

dibujocad
Enthusiast
Enthusiast
Thanks for your reply,
 
No, the drawings don't have any shadows. They contain only white and black lines.
It seems to me that the root of the problem is something related to updating the drawing document.
 
I recently did a test to check this fact. Firstly, I created a "Sub" called "UpdateTest" so as to update and save the drawing. Then, I executed it. After that, I executed another "Sub" in order to export the drawing to PDF through the API. Then, it worked. Any blurred view appeared in the exported PDF. 
However, if I execute the "Sub Update", then the views will appear blurred after exporting PDF.
 
I cannot completely understand it, it should be something related to how my code is written and it is executed, because the resolution isn't the issue. 
 
Test
Public Sub UpdateTest()

Dim oAsmDoc As DrawingDocument
Set oAsmDoc = ThisApplication.ActiveDocument

oAsmDoc.Update2 (True)
oAsmDoc.Save2 (True)

End Sub
 
 
 
Public Sub Update()

Dim oAsmDoc As DrawingDocument
Set oAsmDoc = ThisApplication.ActiveDocument

oAsmDoc.Update2 (True)
If oAsmDoc.Update2(True) = True Then
        oAsmDoc.Save2 (True)
End If
'Call Sub Export PDF through API
ExportPDF

End Sub 
0 Likes

bshbsh
Collaborator
Collaborator
Accepted solution

I used to have that problem when the option "enable background updates" for drawings is enabled. inventor just starts those background processes (something like invviewcompute.exe or so) but the macro continues to run, doesn't wait for those processes to complete. In my case, I disable this option in my macro before updating the views, then re-enable it after the pdf is exported.

0 Likes

dibujocad
Enthusiast
Enthusiast

Hi bshbsh,

Thank you so much for your tip. It finally works!! :slightly_smiling_face:

0 Likes