PDF Viewer - pdfjs processing with base64 string

0 Answers 6 Views
General Discussions PDFViewer
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Daniel asked on 09 May 2022, 01:07 PM

Hey guys,

currently I'm trying to init my pdf viewer with a base64 string receiving from the server. Somehow it don't want to work, so I searched for a working example of you and found it here:

https://docs.telerik.com/kendo-ui/api/javascript/ui/pdfviewer/configuration/pdfjsprocessing.file.data

Your example isn't working on your preview tab and dojo. When inspecting the browser console it is the CORS policy blocking the request of your example. Maybe you can fix it and I can investigate my problem with your example. 

Cheers,
Daniel

Daniel
Top achievements
Rank 3
Iron
Iron
Iron
commented on 09 May 2022, 01:50 PM | edited

Update: I found my issue, so my own problem is solved (highlighted below). The base64 string has some special characters and these will be encoded and my base64 string is not valid anymore. Fixed with the @Html.Raw() functionality.

$('#pdfViewer').kendoPDFViewer({
	height: 1200,
	pdfjsProcessing: {
		file: {
			data: '@Html.Raw(ViewData["PdfBase64String"])'
		}
	},
	toolbar: {
		items: [
			{ type: 'pager', input: false },
			{ type: 'zoom', zoomInOut: true },
			'toggleSelection',
			// 'search',
			'download',
			// 'print'
		]
	},
	width: '100%'
}).data('kendoPDFViewer');

Well, then this thread is just a note somebody of you to maybe fix your example of the documentation in the link I've posted :-)

No answers yet. Maybe you can help?

Tags
General Discussions PDFViewer
Asked by
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or