Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Added attribute to set raw data as the source of the pdf #36

Merged
merged 4 commits into from
Apr 6, 2017

Conversation

moesjarraf
Copy link
Member

@moesjarraf moesjarraf commented Mar 31, 2017

We used to pass in the pdf src as a {{ interpolation }} string. However this makes it really difficult to open a pdf from binary data.

This PR instead forces us to to pass in $scope variables, so we can pass the binary data to the directive. Note that interpolation strings will no longer be supported by the directive, so this is a breaking change.

Aside from passing in a URL string as the source, PDF.JS by default supports passing a Uint8Array as the source. Now we can actually use that feature in the directive.

It is fairly easy to create a UInt8Array from a pdf resource as can be seen in the updated demo file. Because you can just set the responseType of a XMLHttpRequest to arraybuffer and then pass that in the Uint8Array constructor.

I also fixed initializing the webviewer with no source. So you can actually load the pdf-viewer without displaying a pdf (for async loaded pdf files). It used to break the view if you passed in null as the src.

fixes #35 fixes #24

@moesjarraf moesjarraf requested a review from jasny March 31, 2017 14:52
Copy link
Member

@jasny jasny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moesjarraf Ok, but breaks BC.

Is there a way to do this without breaking BC? Like adding a new attribute data, while keeping src as is.

@moesjarraf
Copy link
Member Author

@jasny I added a seperate attribute to not break BC. Also cleaned up instructions on how to use the directive in the readme. Removed unnecessary parts of the examples that just make the usage seem more complex.

@moesjarraf moesjarraf changed the title Set pdf source as scope var, so we can pass in binary data Added attribute to set raw data as the source of the pdf Apr 3, 2017
@jasny jasny merged commit ee7de57 into master Apr 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access PDF's on a secure location How to use with Base64string PDF data ?
2 participants