intbot / ng2-pdfjs-viewer

An angular component for PDFJS and ViewerJS (Supports all versions of angular)
Apache License 2.0
225 stars 113 forks source link

Sidebar default behaviour #166

Closed anees-tricon closed 2 years ago

anees-tricon commented 2 years ago

The left sidebar seems to be closed by default for few pdfs and opened for few others? Is the tool taking some kind of decision on how it should be?

I had tried to close the sidebar always using the onDocumentLoad event, but the problem is, the side bar appears for a split second before being closed programmatically. Causing a flicker.

loadComplete() {
    this.pdfViewer.PDFViewerApplication.pdfSidebar.close(); //close the left nav by default.
}
raykin commented 2 years ago

@anees-tricon I explicitly set pagemode to none can fix it in iframe. It seems iframe can't disable sidebar by default. Here is a code example.

ng2-pdfjs-viewer([pdfSrc]="encodeLink", [openFile]="false", [viewBookmark]="false", [download]="false", pagemode="none")
anees-tricon commented 2 years ago

@raykin , this looks more like removing the sidebar all-together from what i understand. I would want to keep the sidebar, but closed by default.

raykin commented 2 years ago

@anees-tricon it doesn't remove sidebar. I tested it in app and it just close sidebar, I can still open sidebar with two view mode. It also add a green dot to the sidebar. Btw, I notice it was opened in iframe in default.

anees-tricon commented 2 years ago

@raykin , i did not get what you meant in iframe

raykin commented 2 years ago

@anees-tricon nevermind. I mean the PDF viewer opened in iframe. I used it in hybrid app so it could be different from web browser.

anees-tricon commented 2 years ago

@raykin , thanks for your suggestion. This definitely should help remove the flicker(i haven't tried it yet).

on my original question, for few pdfs its closed by default and open for other few. I was wondering if the tool is somehow deciding it based on the content or something like that. If that is the case, i believe it is for a reason and hence i would not want to change the behaviour. And if there is a reason i can convince my product owner also of the same :)

Any idea?

raykin commented 2 years ago

@anees-tricon well, I have no suggestions on your troubles. I notice PDF viewer state sometimes can be remembered in my app. You can search more issues in PDF.js repo. Someone may have answers.

anees-tricon commented 2 years ago

The state remembering is another thing i had doubts on. As you say it is sometimes. I really want to know more about it. That's for another thread though.

anees-tricon commented 2 years ago

Closing this as pagemode="none" did the trick for me.