I am trying to link part id's to PDF pages. At the moment I am test linking them by:
const page = results[0].selection[0] % 100;
Each part ID does now link to a page. However, it only works when I click on a part -> click off the part -> then click on another part. If you try to switch between parts it doesnt show the pdf.
I think there is something wrong with the pdf#page part. As I can switch between parts if I change the code and dont link to a page.
I noticed that the same issue happens on the demo: https://forge-digital-twin.autodesk.io/
Any ideas on how to solve this?
Many thank, Poppy
Here is my code:
function initDocument(facility) {
// Only enable when exactly one part is selected
const $alert = $('#maintenance-docs div.alert');
$alert.show();
$('#maintenance-docs embed').hide()
$('#maintenance-docs > .show-based-on-selection').hide();
NOP_VIEWER.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, function(ev) {
const results = NOP_VIEWER.getAggregateSelection();
if (results.length === 1 && results[0].selection.length === 1) {
$alert.hide();
const page = results[0].selection[0] % 100;
console.log(page);
$('#maintenance-docs > .show-based-on-selection').show();
$('#maintenance-docs embed').attr('src', `/resources/Operation-manual-Sigg-Plant.pdf#page=${page}`).show();
//$('#maintenance-docs embed').show();
} else {
$alert.show();
$('#maintenance-docs > .show-based-on-selection').hide();
$('#maintenance-docs embed').attr('src', '');
//$('#maintenance-docs embed').hide();
}
});
}