I want to be able to upload a file to the cms, to a field on a page. Then from the actually site page, have a link to download said file
I think that a nice way to do this is with kentico page attachments. On the page in the content tree you can go to attachments. There you can add for example a pdf file. This can then be retrieved on the backend and then you can create a link on the view with it. Also see this link about displaying the page attachments. You can also take a look at attaching file groups to pages.
Example:
Controller:
viewModel.FileUrl = treeNode.AllAttachments?.FirstOrDefault()?.GetPath() ?? string.Empty;
View:
Download file
Related
How can I connect cshtml content to ejs-pdfviewer, I want to use it as andvantage to be able to print I want I have set into the PdfViewer with syncfusion, is it possible?'
Is there any attribute I have to add to enable this functionality, or is there a special way to achieve this in syncfusion?
Below is the cshtml code :
<ejs-pdfviewer id="container" style="height: 600px"
serviceUrl="/api/PdfViewer"
documentPath="#Path"
enablePrint="true">
</ejs-pdfviewer>
Currently, PDF Viewer do not have support to display the cshtml page directly. However, we can convert the cshml to PDF and then we can load that PDF document in PDF Viewer. We have created the sample for the same and shared in the following location,
https://www.syncfusion.com/downloads/support/directtrac/general/ze/ViewToPDF_Core1313262793
In the above sample click on ‘ConvertToPDF’ to load the cshtml page in PDF Viewer.
PDF Viewer:
UG link: https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/getting-started/
Reference links for Html to PDF Conversion:
UG: https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit
KB: https://www.syncfusion.com/kb/9779/how-to-convert-html-to-pdf-in-azure-using-net-core
MVC view to PDF (.NET Framework): https://www.syncfusion.com/kb/6024/how-to-convert-mvc-view-to-pdf-using-c-and-vb-net
Note: For converting HTTPS sites, the HTML converter requires OPENSSL libraries to be installed in the machine where the conversion takes place. Please find the below link for reference
https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#openssl
Regards,
Ramya T
I have a PDF file viewer web page and instead of manually creating a web page for each PDF document, I want the page to get the file names attached to its Url as a query string and adds the file name to a JavaScript value in the page.
For example:
http://example.com/FileViewer.aspx?file=GetStarted.pdf
"GetStarted.pdf" should be captured and used as a value in the script, so each request to http://example.com/FileViewer.aspx with the file name attached to it should respond back with a page on the fly that shows the PDF document.
Never done this before with C# and I don't have any sample code, but any leads and/or suggestions are highly appreciated.
I am trying to build a pdf tool with xfinium library and I would like to know if it is possible to retrieve the pdf links of a pdf to make them live when displayed in my app. For now I can only see them as text and it is not possible to click on them so they are not useful. I have looked in the samples of xfinium but I couldn't find any hint to what I should change to make them work.
Any help would be great.
Thanks a lot.
Links in the PDF file are stored as link annotations. You can retrieve these links in this way: load your file in a PdfFixedDocument. The document's Pages collection is populated automatically with all the pages in the document.
Each page has an Annotations collection which is populated automatically with all the annotations on the page. Loop through this collection and test which annotation is a link annotation. The position of the link on the page is given by the VisualRectangle property.
If you need the link's URL you have to inspect the Action property of the link annotation. If it is an URI action then URI property of the action will give you the link's URL.
Disclaimer: I work for the company that develops XFINIUM.PDF library.
I want to browse to folder on button click and select a file in that folder. When user selects a particular file. I want to retrieve the folder path and size of that file ?
How can i do that in asp.net with c#
BTW i'm using vs2008.
Please help me
Thanks in anticipation
Why not use the FileUpload control instead of a Button? http://asp.net-tutorials.com/controls/file-upload-control/
Using FileUpload control, it will accept file uploads from users and is extremely easy. With the FileUpload control, it can be done with a small amount of lines of code, as you will see in the following example. However, please notice that there are security concerns to to consider when accepting files from users!
Use the FileUpload control to let user browse to the file, select it and upload it. Unfortunately, there is no way to retrieve the file size until the file is uploaded (without using Silverlight or other third-party browser components). Once the file is uploaded, you can retrieve file size via the ContentLength property.
how to get file on asp.net form so that user can download it?
suppose i have created one excel file and i want to upload it on form so that user can download it, fill the details when they are offline.
You can use
Response.AddHeader("content-disposition", "attachment; filename=test.txt");
Response.WriteFile(#"test.txt");
Response.End();
Otherwise if it's a specific file you can use a normal Download Meand point it to the files location.
Use the fileupload component. I would store the file locally on the server and then display a list of the uploaded files.the list would be a list of hyperlinkswhich you can link directly to the uploaded files so when the user clicks on one, the file download begins automatically using the standard browser behavior.
Place the file in one of your directories under the application root folder and then you can simply place an anchor tag to let user download the file, like
abc