I have a conception problem and before coding I would like your help.
My goal is to create an app that call an api, gather the data, analyze it, create a report from it and lastly send it by email.
I managed to get the data (as json) with c#, to deserialize it and to make my analysis.
I would like to know what would be the best way to create a nice pdf with the data. My goal would therefore to create for example an html template, that every time I call out my api it modify the content of the template and generate from the html a pdf.
If I think about html it is because I know that I can do my html exactly as I am please, but the problem is the conversion to pdf that sometimes destroy a bit the style.
I know that with visual code I can create html pages, and I would like to know if I can modify the content from a c# page if it is the same project.
If not, can you recommend anything in order for me to do a pdf exactly as I am please with the dynamic content
Thank you
Related
I have a sample PDF. I want to manipulate it with data (add fullname + date) and add a signature field. When the user opens the PDF on his browser and signs it, I want to save the pdf to my database and get notified on my backend side (when success).
I am familiar with php; thus I came across with 'fpdf' and 'tcpdf'. However, I couldn't figure out if what I want achieve is possible with those, but I don't think so. I can open pdf and add line from fpdf but I can't achieve anything with signatures.
What is the best/easiest way to achieve what I want to achieve? From php am I capable of such thing?
Should I try to generate the pdf from html? Is it possible to achieve what they are doing with C# in php? Or should I use completely different language for such thing?
I've written a webpage (HTML & PHP) where a user can fill in various data into a form (using text-inputs and checkboxes). This data should be added to an already existing .docx template (MS Office Word).
Now I chose PHP because I thought PHPWord would offer the solution to all my needs... but it failed me, and I am not clever enough to adapt to the code make it work somehow. So I looked for another Library that could actually insert tables and images in .docx Templates and found DocX (http://docx.codeplex.com/). But this Library is design for .NET. Now I'm hoping DocX will offer the solution I need or my boss will hang me for wasting time.
So on to the question:
I somehow need to port the data gathered in the webpage from PHP to C#. But I'm not entirely sure how one should go about doing this...
I thought maybe I could transform the data into JSON or XML and somehow read that into my C# program. But I don't understand how to "pass on the data"... do I write to a file and read that file every 5 seconds? Do I create some kind of socket/listener on a certain port? Can I somehow trigger an event in C#? My programming knowlegde is lacking...
Could someone please push me in the right direction?
I'm trying to export HTML content (tables) to CSV files using C#, and based from my research here, one of the best ways to implement this is through the use of the HTML Agility Pack.
I haven't started coding and testing this yet because I need to be sure if it's doable first. The HTML table from the website is actually getting push messages from the server so its contents are updated real-time, so a change can happen all the time. What I would like to do is to be able to export the table to CSV every after there's a change in the table (e.g. row added, row deleted, cell contents modified, etc).
I am not sure if this can be done using HTML agility pack, or can be done using C# at all.
Please advise and thank you in advance.
Since this is dynamically updating data it sounds like a headless browser would be a better fit for what you're looking to do. Something like espion.io or phantom.js. A headless browser would allow you to respond to these data pushes and capture the html for further processing.
I've been pointed in the direction of ITextSharp, when I went to download the package from NuGet I noticed something called RazorToPDF only to discover unsolvable formatting issues due to the project no longer being supported.
After more research I was surprised to find there wasn't a similarly worded question as this on SO.
So guys, what's the best way to convert a HTML page/table in an MVC project to a PDF file?
What's the best way to convert a HTML page/table in an MVC project to a PDF file?
Generally, print it to a PDF from the web browser on the client.
The thing is, by relying on the end-user perspective of the view in this case, you're also relying on the end-user rendering of that view. It's a step that should be removed from this particular equation entirely.
Keep in mind that there are fundamental differences between how an HTML page renders and how a PDF renders. The two aren't 100% interchangeable. A PDF has a static page size and elements are placed absolutely, whereas HTML has dynamic sizes and elements are placed in a flow layout. There are additional considerations such as client-side DOM manipulation that may take place in that view. "Rendering" it quickly becomes a browser-based activity, which is something you shouldn't really need to do server-side.
Instead of thinking of the PDF as an extra step following the rendering of the view, think of it as a view in and or itself, parallel to the other view. One requested action results in the HTML view, another requested action results in the PDF "view". As such, you design the PDF template how you want it to look and populate it with data (using something like iTextSharp) before returning the file contents to the client.
I am thoroughly confused with something I want to do and am looking for some advice.
One of my client has to produce monthly invoice detailing all of the company expenditure, and two other such invoices. The client is sure that he only needs these invoices - and they are extremely simple enough to produce as far as logic is concerned.
Now, to make the actual invoice, I don't really want to use reporting solutions like Telerik, SSRS etc.. as I think they are an overkill for my purpose. At the same time, I am not sure how I can get the printer to print the invoices in a neat pages without cutting off anything.
I am very tempted to just give the output in a webpage and ask my client to print them off from there.
Am I not looking at this the right way? Is this possible?
I could use ITextSharp or something to produce pdf's.. In fact, I think I will go ahead with this if it isn't possible to just output to html page and get the printer to recognize the page breaks somehow.
Because this is a very small job, I don't want to spend too much time on it as the cost of this freelance project is minimal too.
The reason printing to a new page is important is that my client has a few shops he deals with and he would want to print each of his customers their own invoices. I can get him to produce each customer's invoice separately and print them but it is not ideal way to deal with it.
thanks
There is a css property which should tell a browser to break a page: page-break-before.
But if you have a a wide list of browsers to support, it would be better to get some HTML to PDF conversion library or really use iTextSharp (as far as I know there is even a module/class which allows to conver HTML to PDF with iTextSharp) as printing web pages has many issues.
In the past, when I wanted to create a reusable document, I used Word or Excel XML formats.
See: http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
They are easy to create and tweak, then all you have to do is recreate the dynamic parts in your code. All you have to do is save the document in Office XML format, then open it up in word pad to see where to make your changes.
SSRS has a drag and drop interface for designing reports and has a PDF output option. If the data is in a SQL server database then even with the learning curve it should be easier to do SSRS reports.