DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting PDF of Report without bookmarks tab being open

Hi all.

I am using DIAdem 2022 Q2 on Windows 10.

I am using VBS to automate some data analysis and exporting a pdf of a report showing key analysis results. 

Everything is working, with one minor (but really aggravating) issue: when I open the exported PDF the bookmarks tab is open and it is almost the same size as the report as shown below (just having a bit of fun with the "redacted" bits 😉). 

bpollock80_1-1664568338692.png

I have done some looking into this with PDFs in general and found that the setting is in the individual document's initial view property. If I open the PDF and go to File>Properties>Initial View, then change the navigation tab to Page Only, it changes it so that when I open the PDF again the bookmarks tab is gone. The setting in Acrobat is shown below: 

bpollock80_2-1664568714083.png

 

I REALLY don't want to have to do this every time I open an exported PDF.

 

Here is what I have tried to do from my script:

 

The code I am using to export the PDF. It works fine other than the whole bookmarks thing:

Call Report.Sheets.ExportToPDF(SavedRepName & "_" & Data.Root.Name, False)

I have used some of the help file's code to get a list of the document level properties in the exported PDF:

Option Explicit 'Forces the explicit declaration of all the variables in a script.

Dim oMyDocument, DocProp, DocProps, sOut

Set oMyDocument = OpenDocument("pathandfilename.pdf", False, eDocumentTypeAuto)

Set DocProps = oMyDocument.properties

For each DocProp in Docprops

sOut = sOut & "Name: " & DocProp.Name & ", Value: " & DocProp.Value & VBCrLf

Next

print(sOUt)

Which gives me the following properties: Name, Description, Title, Author, and Datetime.

I have even rerun the code above after changing the initial view settings and then saving the PDF. No new properties were added to the logfile sOut output.

 

I then tried this code as a shot in the dark:

Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim oMyDocument, DocProp, DocProps, sOut

Set oMyDocument = OpenDocument("pathandfilename.pdf", False, eDocumentTypeAuto)

Set DocProps = oMyDocument.properties

Call oMyDocument.Properties.Add("Initial View","Page Only",DataTypeDocumentString)

Call oMyDocument.Save()

For each DocProp in Docprops

sOut = sOut & "Name: " & DocProp.Name & ", Value: " & DocProp.Value & VBCrLf

Next

print(sOUt)

That ended up at least adding a property in the logfile sOUT output for "Initial_View" and the value was "Page Only" but it didn't end up changing anything. Not that I really expected it to, but wanted to throw something at the wall to see what would stick. 

 

I am guessing that I need the correct property name as it probably isn't actually Initial View. And the correct value probably isn't actually Page Only. 

 

Anybody have an idea for me to try?

 

Is there a way for me to access the document's bookmarks and just delete the bookmarks? Not that doing so will for sure change the default view, but I figure it is worth a shot. By the way, the name of the bookmark matches the name of the worksheet in the Report Layout. 

 

Maybe there is something else I need to change somewhere else? This is just one of those frustrating things that I really want to solve before I consider this project done.

 

Thanks for taking the time to read my novel 😀

Brett

0 Kudos
Message 1 of 3
(1,262 Views)

Hi bpollock80

 

I would guess that the bookmarks are just markers that are then displayed differently depending on the PDF viewer. So these are then also settings of the viewer. I have made tests with a free PDF viewer that confirm this. It saves the last settings whether bookmarks are displayed and in which size automatically.
OpenDocument allows saving name-value pairs, which have a documenting character. They should not influence the parameterization of the PDF viewer.

Greetings

Walter

0 Kudos
Message 2 of 3
(1,220 Views)

Walter,

 

Thanks for taking the time to check out my question and for writing your reply.

 

Unfortunately, using a different pdf viewer isn't a good option for my case. There are a number of people in my department that will need to view the pdf output files from my script. We are limited in the software that IT will allow us to install, plus, we all have a full version of Acrobat installed on our machines. This issue very well might be unique to Acrobat.

 

The initial view setting is definitely a property of the individual document that gets set during the time of file creation. When I save a Microsoft Word file as a pdf the initial view setting is by default "page only" as I want for my exported DIAdem reports.

 

But again, thanks Walter for giving it a shot!

 

Anyone else have any ideas?

0 Kudos
Message 3 of 3
(1,203 Views)