Hello PDFTron!
I’m having this error when I try to getFileData
the options are
{ xfdfString, flatten: true, }
Unable to download PDF data: raw document access has been disabled
I’m using
"@pdftron/webviewer": "^7.3.0",
WebViewer server is activated
Hello, I’m Ron, an automated tech support bot
While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:
Guides:
APIs:
Forums:
Can you provide the following so we can test and try to reproduce this on our side?
The PDF document you are using
How you get the variable xfdfStrings
The code that how you call getFileData()
Thanks!
Oscar
Hello Oscar!
we are handling many files
we use this for testing
https://filesamples.com/categories/document
https://file-examples.com/index.php/sample-documents-download/
and others for the stage environment that are files stored in our S3 protected with AccesssToken
I had this function to get annotations & file for upload to our endpoints
async function generateAnnotationsPDF() {
const xfdfString = await annotationManager.exportAnnotations();
const document = documentViewer.getDocument();
const rawFileData = await document.getFileData({
xfdfString,
flatten: true,
});
const pdf = new File([new Uint8Array(rawFileData)], `${file.filename}.pdf`, {
type: 'application/pdf',
});
return {
xfdfString,
pdf,
};
}
Actually I activated Full API.
When load File this error appears
I picked some random PDF files from the links you provided. But unfortunately, I didn’t see any error when running the code you provided.
Here is what I did:
Open WebViewer Demo site: https://www.pdftron.com/webviewer/demo/ (This demo site is running V7.3.1)
Open Browser console and change to WebViewer Iframe
Enter the following code in the console
const annotationManager = docViewer.getAnnotationManager();
const xfdfString = await annotationManager.exportAnnotations();
const doc = docViewer.getDocument();
const rawFileData = await doc.getFileData({
xfdfString,
flatten: true,
});
// replace the link in the next line:
const pdf = new File([new Uint8Array(rawFileData)], `link_to_the_PDF_file`, {
type: 'application/pdf',
});
console.log('xfdfString', xfdfString);
console.log('pdf', pdf);
The code can be executed with no error.
Can you repeat the steps I did above and let me know if you can see any errors?
If this error only happens in your local environment, can you let me know how to reproduce it?
Osacr
Oscar_Zhang:
const annotationManager = docViewer.getAnnotationManager();
const xfdfString = await annotationManager.exportAnnotations();
const doc = docViewer.getDocument();
const rawFileData = await doc.getFileData({
xfdfString,
flatten: true,
});
// replace the link in the next line:
const pdf = new File([new Uint8Array(rawFileData)], `link_to_the_PDF_file`, {
type: 'application/pdf',
});
console.log('xfdfString', xfdfString);
console.log('pdf', pdf);
I reproduced it on our dev environment and this error happens
Also, this error only happens in our dev & stage environment when active WbViewer server and load Viewer
and when I try to getFileData, the viewer stays stuck there.
I can’t reproduce it on local environment
Now, I tested with server activated & fullAPI deactivated, now this error occurs
Do you have any clue about this?
I have already exhausted the things that occur to me.
if it is possible to use the annotations with the web server or not?