4

Here is my case:

I'm using ABCPDF to generate a HTML document from a .DOCX file that I need to show on the web. When you export to HTML from ABCPDF you generate a HTML and a folder with support files (.css, .js, .png)

Now these HTML files may contain quite sensitive data so I immediately after generating the files, I move them to a password-protected .zip file (from which I fetch them later)

The problem is, that this leaves the files unencrypted on the HDD for a few seconds and even longer if I'm (for some reason) unable to delete them at once.

I'd like suggestions for another way of doing this. I've looked in to a ram drive, but I'm not happy with installing such drivers on my servers. (AND the RAM drive would still be accessible from the OS)

The cause of the problem here might be that ABCPDF can only export HTML as files (since its multiple files) and not as a stream.

Any ideas?

I'm using .NET 4.6.x and c#

Henrik Clausen
  • 679
  • 6
  • 16
  • cant you use the http://www.websupergoo.com/helppdfnet/source/5-abcpdf/doc/1-methods/save.htm and save to stream than to a file – Saravanan Oct 21 '17 at 11:16
  • Can you save multiple files in one stream? I believe you can only save to stream as a .PDF, and what I need is HTML (including support files) – Henrik Clausen Oct 21 '17 at 11:22
  • Any code to show? As it stands your question is arguably **too broad** –  Oct 21 '17 at 11:22
  • 1
    I can post code, but I'd like to get som alternate ideas that I haven't thought of, not just review of my code – Henrik Clausen Oct 21 '17 at 11:24
  • @HenrikClausen: Hope your static resources like CSS / JS are from a CDN so no need to stream them in files for your html files. – Saravanan Oct 21 '17 at 11:24
  • @Saravanan : The CSS and JS are not static.. They are generated per export so they are unique to the html representation of the word-document. But that wasnt what I was asking about anyway :) I need to get the HTML file from ABCPDF to a zip in a more secure way than saving to disk. – Henrik Clausen Oct 21 '17 at 11:28
  • You could stream the response from AbcPDF to a stream and from the stream to a encryption technique that encrypts the stream. Once the stream is encrypted, you can just pass on the stream contents in the response, so file converted, as stream in memory, encrypted, compressed and responded w/o disk I/O. Try out the details in the link shared and share with us the update – Saravanan Oct 21 '17 at 11:31
  • @Saravanan : As I mentioned, the ABCPDF component saves :HTML as multiple files, thus it cant generate them as a stream.. Just files.. – Henrik Clausen Oct 21 '17 at 11:37
  • Are the contents of .JS, .CSS and .PNG also sensitive? – Alex AIT Oct 21 '17 at 11:57
  • @Alex : No they are completely anonymous. – Henrik Clausen Oct 21 '17 at 11:59

1 Answers1

2

Since all your files except the .HTML are anonymous, you can use the suggested way of writing the HTML to a stream. Only all other files will be stored to the file system.

http://www.websupergoo.com/helppdfnet/source/5-abcpdf/doc/1-methods/save.htm

When saving to a Stream the format can be indicated using a Doc.SaveOptions.FileExtension property such as ".htm" or ".xps". For HTML you must provide a sensible value for the Doc.SaveOptions.Folder property.

http://www.websupergoo.com/helppdfnet/source/5-abcpdf/xsaveoptions/2-properties/folder.htm

This property specifies the folder where to store additional data such as images and fonts. it is only used when exporting documents to HTML. It is ignored otherwise.

For a start, try using a simple MemoryStream to hold the sensitive data. If you get large files or high traffic, open an encrypted stream to a file on your system.

Alex AIT
  • 17,361
  • 3
  • 36
  • 73