Print not working

Hi,


Print is not working for Document Viewer for .NET. I have a licensed version of GroupDocs Viewer for .NET.

I am getting the following error on console when I click on print button. Please let me know if you need any further details on error.

Uncaught TypeError: Cannot read property ‘length’ of null(anonymous function) @ GetScript?name=installableViewer.min.js:1(anonymous function) @ GetScript?name=installableViewer.min.js:1$.extend._successHandler @ GetScript?name=GroupdocsViewer.all.min.js:1(anonymous function) @ GetScript?name=GroupdocsViewer.all.min.js:1j.s.a @ GetScript?name=GroupdocsViewer.all.min.js:1Accept @ GetScript?name=GroupdocsViewer.all.min.js:1w @ GetScript?name=GroupdocsViewer.all.min.js:1OnCompleted @ GetScript?name=GroupdocsViewer.all.min.js:1a.success @ GetScript?name=GroupdocsViewer.all.min.js:1a @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1h.fireWith @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1k @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1send.u @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1XMLHttpRequest.send (async)send @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1i.extend.ajax @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1c.ajaxAsObservable @ GetScript?name=GroupdocsViewer.all.min.js:1$.extend._runService @ GetScript?name=GroupdocsViewer.all.min.js:1$.extend._runServiceAsync @ GetScript?name=GroupdocsViewer.all.min.js:1$.extend.getPrintableHtml @ GetScript?name=GroupdocsViewer.all.min.js:1a.extend.getPrintableHtml @ GetScript?name=installableViewer.min.js:1a.extend._printDocument @ GetScript?name=installableViewer.min.js:1d.bind.click @ GetScript?name=installableViewer.min.js:1i.event.dispatch @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1y.handle @ jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1:1

Thanks,
Dhivya
Hello Dhivya,

Thanks for using GroupDocs.Viewer.

We have checked the print option on our side with latest version of the GroupDocs.Viewer for .NET (2.12.0) and it works fine for us.

Could you please share with us some additional info about which the version of GroupDocs.Viewer you use and which type of project MVC or Web Forms. Also will be useful if you share with us an example of your project to we will be able to check your configuration for our library.

Please come back with your details and we will be glad to help you.

Best regards
Evgen Efimov

http://groupdocs.com
Your Document Collaboration APIs
Follow us on LinkedIn, Twitter, Facebook and Google+

The issues you have found earlier (filed as WEB-1724) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by GroupDocsNotifier.

Hi Evgen,
The viewer is running on a MVC (web api) application. I am using the version 2.10.0.20039.
I tried version 2.12 as mentioned by you and now i see a pop up saying printing coming up and then closing immediately. Also, I see the same error on this line g=l.length in the script file installableViewer.min.js.
Can you please tell me what l in l.length contains so that I can confirm its not something on the code which is stopping this to work.
I see the following files not loading when my application starts. Not sure if this could be the reason stopping the print.
GET http://domain-name/document-viewer/fonts/PT_Sans-Web-Regular.woff
GET http://domain-name/document-viewer/fonts/PT_Sans-Web-Regular.ttf

Thanks,
Dhivya

Hi Evgen,


Happy to inform that print is working if I set usePdfPrinting as true. My understanding was showPrint alone needs to be true for print to work.

Can you please confirm if usePdfPrinting needs to be true?

Also, as mentioned in my previous post the following error in the console needs to be handled as clients think those to be some errors. Can you please help and let me know if I need to add some files to my application?

document-viewer/fonts/PT_Sans-Web-Regular.woff
document-viewer/fonts/PT_Sans-Web-Regular.ttf

Thanks,
Dhivya

Hello Dhivya,


We glad to hear that you have fixed the issue. The usePdfPrinting doesn’t necessary and you don’t need to add any fonts. If the usePdfPrinting(true) resolve the issue and it’s suitable for you, you can leave it.

Also please make sure that you have such code in your web.config:
<system.webServer>
</system.webServer>


As Evgen said earlier we need examples of the Viewer widget code that you use.

Thank you.

Thanks very much, that resolved my console error.


I am initializing the doc viewer as below. Can you please verify if I really need to set usePdfPrinting to true or is it something with the setting which is not allowing the print?

Also, please note usePdfPrinting prints all documents but png documents are failing. It says “failed to load the pdf”.

$(’#tabname’).groupdocsViewer({
filePath: data.fileName,
docViewerId: ‘doc_viewer’ + tabName,
PreloadPagesCount: 1,
quality: 100, showThumbnails: true, openThumbnails: false,
initialZoom: 100, zoomToFitWidth: true, zoomToFitHeight: false,
width: 0, height: 0, backgroundColor: ‘’, showFolderBrowser: false, showPrint: true,
showDownload: false, showZoom: true, showPaging: true, showViewerStyleControl: false, showSearch: true,
viewerStyle: 1, supportTextSelection: true, usePdfPrinting: false,
localizedStrings: localizedStrings, thumbsImageBase64Encoded: thumbsImageBase64Encoded,
toolbarButtonsBoxShadowStyle: ‘0 1px 0 rgba(200, 0, 0, 0.2) inset, 0 1px 0 rgba(200, 0, 0, 0.15)’,
toolbarButtonsBoxShadowHoverStyle: ‘0 1px 0 rgba(160, 0, 0, 0.4) inset,0 1px 0 rgba(160, 0, 0, 0.3)’,
thumbnailsContainerBackgroundColor: ‘’, thumbnailsContainerBorderRightColor: ‘’, toolbarBorderBottomColor: ‘’,
toolbarInputFieldBorderColor: ‘’, toolbarButtonBorderColor: ‘’, toolbarButtonBorderHoverColor: ‘’,
thumbnailsContainerWidth: 0, useBrowserCache: false,
showDownloadErrorsInPopup: true, showImageWidth: false, showHeader: true, minimumImageWidth: 0,
enableStandardErrorHandling: true, useHtmlBasedEngine: false, fileDisplayName: ‘’
});


Thanks,
dhivya

Hello Dhivya,


Thank you for the code example. We have checked it and we can assume that you use an old version of the Viewer. Since that you should update it first, please use the latest version of the Viewer . Then remove this property: docViewerId: ‘doc_viewer’ + tabName, since it’s deprecated.

After these updates try to use usePdfPrinting: false

Thank you.

Hi,


Tried the new version 2.12 and it is still not working. I see a message “Getting the printable version of the document” which quickly hides and I see the below error message in console.

Uncaught TypeError: Cannot read property ‘length’ of null (in file installableViewer.min.js in line var k,g=l.length;)

In addition to this I see a new error everytime I generate a viewer now in console as below.

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42%E2%80%8C%E2%80%8BmNgYAAAAAMAASsJTYQAAAAASUVORK5CYII= net::ERR_INVALID_URL (in file knockout.js)

Please note we are using the following js files in our application.

“~/Scripts/jquery-1.10.2.min.js”
“~/Scripts/jquery-ui-1.11.4.min.js”
“~/Scripts/jquery.dataTables.js”
“~/Scripts/dataTables.responsive.js”
“~/Scripts/bootstrap-select.js”
“~/Scripts/moment.js”
“~/Scripts/daterangepicker.js”
“~/Scripts/angular.min.js”
“~/Scripts/MultiSelect/jquery.multiselect.min.js”
~/Scripts/MultiSelect/jquery.multiselect.filter.min.js"
“~/Scripts/Pagination/jquery.paginate.js”
“~/Scripts/Pagination/jquery.simplePagination.js”
"~/Scripts/Typeahead/bootstrap3-typeahead.js"


Thanks,
Dhivya

Hello Dhivya,


We have reproduced the bug and we created a bug ticket for our product team (you can see it attached to the first post in this thread). Our product team will resolve it and we will notify you when it will be ready.

Sorry for the inconvenience.

Thanks.


Can you tell me an approx time within which the fix will be available as we have to commit to our customers?

Thanks,
Dhivya

Hello Dhivya,


Sorry but currently I can’t share with you the date. I will try to found out more info from our product team and when I will have any updates I will come back to you.

Thank you.

Hello,

We have fixed the JavaScript error. Please download fixed version here and set .UsePdfPrinting(true)

Thank you.

Hi,


I tried the new version it is working fine I don’t see any console errors any more. But print for image files is still now working.

I have another issue where the browser is caching the image URL.

STEPS:
1. Preview a document.
2. Update Document in the backend
3. Preview the document again, it is showing old document. but the cache folder is updated with new image.
4. Refresh the browser by clicking Ctrl+F5 and now the preview shows the new document.

FIX:
1. appended “&random={random no.}” to the page URL.
2. This seemed to work in previous version of 2.10, but now as I have PreloadPagesCount set as 1 and using new version, I see the same old console error for any additional pages as appending “&random=” to the src of “data:image” is invalid url.

NEED SOLUTION FOR:
1. Do we have flag like ‘useBrowserCache’ as we have for JAVA for .NET as well.
2. Does the viewer has any event when the src is changed from “data:image” to “http:\”. If yes I can append the extra parameter at the end in that event.
2. If not how do you suggest we resolve this issue of browser caching the image.

Thanks,
Dhivya

Hello Dhivya,


In case that you need to print the image file you can’t use the .UsePdfPrinting(true) option, if you need to print the image set this property to false and then when you will print other documents set it back to true.

As for the issue with documents changing - please investigate attached example code. It shows how to change the document by setting document name in the GET parameter of the URL (use ?fileName property)

Also if you will use such approach you can check the document type and then set the correct printing option (.UsePdfPrinting(true) or .UsePdfPrinting(false))

Thank you.

Hi,


If I set usePdfPrinting as false then I end up having the console error as below even for images and printing stops working completely.

Uncaught TypeError: Cannot read property ‘length’ of null.

For the fileName, the problem is filename is still same but the content of the file has been modifed. So adding the filename is not resolving the issue of browser cache.

Not sure if this helps but at the end of my page i see the following HTML.


I am not sure why there is an empty img tag and could that be contributing to the length being 0. It changed to below when I click on print.


Thanks,
Dhivya

Hello Dhivya,


We are sorry for the issue. We can’t reproduce it on our side - all works fine for us. Since that could you please share with us example of the project with documents examples that you use.

As for the issue with the document update - after you have changed the document you do next:

1. Remove the cache for this document - you will find cache for specific document under such path: temp/Cache/your document name
2. Refresh the Viewer - to do it you have to variants: refresh entire web page or just rebuild the Viewer div.
To rebuild the Viewre div you should put it with the Viewer widget code in to the same div. For example:

<%= Viewer.ClientCode()
.TargetElementSelector("#test")
.FilePath(“candy.pdf”)
.ZoomToFitWidth()
.UseHtmlBasedEngine(true)
%>
Then you will be able to remove the div with id “viewer” and generate it again with the JavaScript.

Thank you.

Hi,


Not sure what was wrong but if I use all the settings as mentioned in the attached file then print is working for me.

Thanks,
Dhivy

Hello Dhivy,


Glad to hear that. If you will have more questions please feel free to contact us.

Thank you.