Programatically send a copy of a local file system notebook to Onedrive Onenote - onenote

Locally, I have several OneNote notebooks in the OneNote 2007 format. For reasons out of scope it is difficult to convert them to the new format first.
I want to be able to send a copy of the notebook to OneNote Online so that I can read-only it from wherever OneNote Online is accessible.
Programmatically, I have used the OneNote desktop API to export a page as an MHT file. Then I have used further code to convert the MHT to an HTML file. Finally, I then used MS graph explorer (because I haven't written that part of the code yet), to create a new OneNoteAPI page with the HTML that I exported.
I had expected the resulting page in OneNote Online to look like the HTML I had just uploaded.
It .. did not.
a) Where before I had a nice OneNote list with checkboxes I now had them laid out vertically. So checkbox\nitem\ncheckbox\item.
b) The title box that was exported as part of the HTML .. remained in its place and the new page did not absorb it into its title box.
So, how can I programmatically send a page from a desktop OneNote to a OneNote Online folder and have it look the same?
NB: I actually want to send the entire notebook but am trying one page at a time.
NB2: I cannot port all the notebooks to OneNote online once off and then just use that. They need to live in the local network.
NB3: I suppose I could just set up an FTP site with the HTML pages that I just exported - that is plan Z.
Thank you

Related

Is there a way to automate saving a PDF version of an HTML formatted report whenever it is viewed in the browser?

I am working with SQL Server and C# to create individual employee reports. I am using HTML and CSS to format the reports and display in a browser. The customer also wants a printout of every report. I would like to have a formatted PDF version of the report automatically saved to a folder on the server whenever a report is viewed in the browser. I could create a process to print all of the PDF pages at one time.
With regards to the generation of the PDF, as it happens I had to do something similar a couple of years ago.
I was generating HTML reports from C# that I needed to convert to PDF.
There is a nuget package named OpenHtmlToPdf that uses wkhtmlopdf to convert HTML to PDF.
At the time I also wrote a bit of blurb on this subject on my blog here!
For your scenario, when the customer requests a report, on the server side you could generate the html as you are now. Then you could use OpenHtmlToPdf to additionally generate a PDF version on the server at the same time.
All you would then need to work out is how to get the PDF link address to the user (email, web link, etc)

Is it possible to upload/choose the file from sharepoint location to application using HTML5 file upload?

I would like to open/select the file from SharePoint location, the file dialogue box(HTML file upload feature) should open with a list of files from the SharePoint directory instead of pointing to the system directory. is it possible?
Currently, the dialogue box opens with the current system directory file location.
Is it feasible with all browsers?
Yes, it is feasible.
However, you might need to custom design the interface.
You would need to perform a rest API call to SharePoint document library to show the list of files. You can use Microsoft Graph API to make the calls and extract the details.

Auto-Convert OneNote to PDF

I am trying to automatically convert some Microsoft OneNote files to PDF to send as a daily email attachment. I have thought of two systematic solutions but need some help in finding the right tools:
Find an application that may be programmatically called (via a Python script e.g.) that will convert a Microsoft OneNote file to a PDF.
Find a way for OneNote to automatically save files as PDFs every time it auto-saves.
Is anyone aware of tools available for either solution?
See my answer to your other question
The approach would be to get the pages content with
./me/onenote/pages/1-1c13bcbae2fdd747a95b3e5386caddf1!1-xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx/content?includeIDs=true&includeInkML=true&preAuthenticated=true
and then render the html on a canvas with javascript/jquery.
render ink with InkMLjs
and then use a library to convert the canvas to a pdf for example with canvas2pdf
Another approach might be something like Automator for osx. You could get the pages of interest with the microsoft-graph api, open them in a web browser using applescript and when the page has finished rendering -> print -> "Save as PDF"

Generating a web site from xsn files

As we all know, the infopath forms service residing on a sharepoint server generates a web site each time we publish an inforpath form template to the sharepoint server.
Here is the question: how does sharepoint do that. Is there any way for us to do that programmatically via some kind of api provided by MS?
In fact, what I need to do is getting all the html, js, css etc. files and applying some kind of operations like deleting some divs or insert some html code into the particular web page. I have come up with two ways to do this.
Generating the web page via sharepoint api and apply those operations at the same time
Extracting the web page files from the IIS server and apply those operations
I am totally new to this kind of work. All in my mind is that each time we right click on a web page in the browser and choose to save the web page, the browser gets some of the files we need to render the web page and makes it possible for us to browse the web page offline.
httrack
WinWSD
and tools like that seems to work fine with extracting html files from online web pages but not that well with js, css files.
Now I am trying to dig into the chromium project for some kind of inspiration, although whether it helps or not is unpredictable.
Any kind of advice will be appreciated.
Best Regards,
Jordan
Infopath xsn files are just zip files with a different extension. you can rename the extension to .zip and extract out the files. you will find a number of files that make up the form. the two main ones are the .xml and .xsl files. the .xsl will have the html to generate when applied to the xml.

How HTML file upload works?

HTML uses form to send data to web server. The data can be included in the url parameters or embedded in HTML Request body. But for a file, I don't know how it works. I want to know this because I see some difference between uploading file on web and desktop applications.
The desktop application usually provides a text box to allow the user input the locale path of the file. But for web applications, the text box is usually read only.It displays the file path when the file gets selected with the browse button. Is that just a design issue between desktop and web?
Question is a bit unclear, but one important aspect about web applications (or HTML forms) is that they are sandboxed and cannot access local files directly. So the file upload picker does not allow direct input of the file name (which might be scripted), but only selection through an OS (or browser) supplied file choose UI (that the app or page cannot mess with).
Once the user has selected the file the page can access it, but it cannot make the selection itself (or surreptitiously).
A recent trend is to lock down desktop apps in the same manner. See for example Apple's sandboxing restrictions, that also do not allow apps to open random files without user intervention.
Is that just a design issue between desktop and web?
The implementation of a file upload form, whether desktop or web, is largely unimportant to the end result. Both desktop and web controls can utilize either a path string or a full-blown file navigator, though a desktop app is more likely to vary in its implementation. The only other difference is the destination: desktop apps tend to parse the file in memory and render it somehow, while web apps almost invariably upload it to a server (though this is subject to change: see the HTML5 file API), which then further operates on it.