Create PDF/A with WKHTMLTOPDF w/o using Ghostscript? - c#

We use WKHTMLTOPDF to create PDF documents out of HTML in our C# Project.
But we have to be PDF/A compliant with our PDF-Files.
At the moment we use another external component to convert from PDF to PDF/A
Is there no direct way to generate PDF/A compliant documents with WKHTMLTOPDF?
Maybe a WKHTMLTOPDF "Fork" or something?

Not currently (has been an open issue since 2014)
PDF/* are SUPERsets (designed by committee) of good old functional PDF 1.0 ideals.
That is certain things MUST and must NOT be included.
WKHTMLTOPDF is built on QT WEBKIT viewer where those requirements are not needed in order to display PDF i.e. it can display some but not all conforming and non conforming PDFs, its a PDF viewer not creator.
You can as you know use GS to adjust and create the parts needed for some PDF conformances
Your best viable alternative is to use open source iText 7 specifically:-
https://github.com/itext/i7n-pdfhtml
an iText 7 add-on for C# (.NET) that allows you to easily convert HTML and CSS into standards compliant PDFs

Related

Generate a PDF document using .NET Standard 2.0

I am trying to find a way how to generate a custom PDF document from .NET Standard 2.0. Free or Open-Source library would be of the preference in this case.
I Have already tried PDFSharp, but it does not support .NET Standard 2.0 (or am I wrong here?) and several ports of this library, which all claim to be .NET Standard, do not have the System.Drawing.Common which is necessary to actually write anything to the document.
Does anyone have any suggestion on how could I generate a PDF with my above-mentioned criteria? It does not really matter if I would have to first write HTML and then convert it to PDF or per se convert excel type to PDF. Anything that could give me a PDF would be great.

C#: How to convert HTML5/CSS3 into PDF document?

It's obvious from the title what I want to do. I know it is possible to convert html to PDF document using a very popular library iTextSharp. But what I acknowledged from this post is iTextSharp cannot render HTML5 and CSS3 styles correctly. Is there any free library to achieve this?
Backgroud:
I am using DevExtreme for report generation. It has supported chart export in PDF but my client wants some extra content in PDF apart from charts. It is not supported by DevExtreme, so I took decision to write my own custom PDF exporter.
There are some libraries available but I cannot rely them since I can't predict in advance what issues will it cause in production in future. Correct me if I am wrong, there is no API given by Microsoft for manipulating PDF files. We can create and manipulate excel and doc files using Microsoft.Office.Interop.Excel.dll and Microsoft.Office.Interop.Word.dll but I didn't find anything for PDF manipulation.
Please suggest me what options I have.
Hope this makes sense..!
A few years back I was using iTextSharp to get our html manuals in xhtml/css/wiki to pdf. It was...painful and a lot of work. So, the first news is: You will need quite a few weeks (2,3,4 weeks, depending on the grade of perfection you want) of time if what you have is not only a few html pages.
If you only have a very limited amount of pages, the quickest and dirtiest way is to make screenshots from your rendered pages and add those images to the pdf. Not very high-tech but quickly done.
If your style sheets can be sacrificed and you do not care about the formatting of the content to be identical, you can convert your html5 pages to xhtml so you can load them as XmlDocuments. Then you simply create a program which does some mapping from xml elements, such as <h1>MyTitle</h1> to some section of code which creates a pdf entity using iTextSharp. Basically that was the way I did it in my case. I also did some mapping from css style classes to some specific pdf formatting, but not to the extreme.
Also worth trying is converters from html (or xml) to tex/latex. If you are lucky you find one which does a good enough job. Then you can use pdftex and get your pdf.
Also, it is possible that you can print your documents to an xps printer and then convert the xps to pdf. Or you simply convince your customer that xps is what they want.

How can I convert my report into pdf without using a gridview (Visual Studio)

I was able to convert gridviews into pdfs but now I want to generate a pdf for my pay slip.
It has a different format because I fixed the layout using an HTML table, and ASP Labels.
How can I convert that into PDF?
If you don't have a built tool for converting to PDF (like teleriks builtin methods for exporting RadGrids to PDF) I'd go for generating the PDF by hand.
Instead of trying to parse the UI into a PDF you can construct the PDF directly from the data source. I've used iTextSharp for composing PDF:s manually. It's a bit clunky but it get the job done. Beware of the license for iTextSharp version > 5 if you have a commercial site.

Generate PDF/ Microsoft Word Reports using ASP.NET

I want to ask for the best way to generate a PDF and Microsoft Word Documents using ASP.NET.
I have used XSLT transformation, but the results was not good, and the major of XSLT processors are commercial and not free.
I need to create a simple document have a header, footer and some tables and images.
can anyone provide me with the best technology to do this job.
Thanks
I had this question a little while ago.
I wrote some really neat stuff for PDF generation.
iTextSharp or XSL-FO to create a PDF dynamically with fillable forms?
PM me and I can send you some files.
IText is a good free library for creating PDF documents.http://itextpdf.com. Works great with both WinForms and ASP.Net.

Use a System.Drawing.Printing.PrintDocument to generate a PDF in memory

Does anyone know if the following is possible and if so what the best way of doing it is for free?
I am generating a PrintDocument in a project I am currently working on and displaying a print dialog box so a user can choose which printer they want to use etc. The is currently a windows form application and if a user wants to print to a PDF they can select to print to CutePDF or something similar.
However I am now putting a ASP.Net web frontend on the application and want to use the same code to generate the PrintDocument but want to print it to a PDF on the fly and serve it up via the Response stream in the format of a PDF download.
So my question is....How can I use the current PrintDocument and generate a PDF in memory from it??
Thanks
The System.Drawing code for a PrintDocument can be reused to generate a PDF document with ABCpdf .NET. See the System.Drawing example...
You would have to use a 3rd party component in order to generate the PDF. The following article has some links to some such components: Generating PDF Files from .Net
You're in a world of hurt if you think you're going to run the "same code" that deals with printers in both a forms app and an ASP.NET app.
You might be in luck, however, as it appears that PDFsharp + MigraDoc might be able to do this for you.
I think you will find there is not any tools that will take a PrintDocument as input and render a PDF as output. The only way to do what you want is to "print" the PrintDocument to a "PDF printer driver" that will generate PDF. Basically a virtual printer that will generate PDF instead of printing the actual output. There are a plethora of products on the market for that. A couple that are cheap and widely used are as follows:
Ghostscript with RedMon (open source/GPL or commercial licenses available)
Foxit Software's PDF Creator ($29)
You really should be looking at iTextSharp (it is mentioned on the iText.NET page recommended earlier)
http://itextsharp.sourceforge.net/
PrintDocument is meant for Windows Forms applications but is up and coming in SilverLight, see this video... http://silverlight.net/learn/videos/all/printing-api-basics/
If you wish to continue with the PrintDocument and a web application, I think SilverLight 4 (which is beta right now) is the only way to go, or your going to have to have a lite weight windows form application installed locally for the end user that maybe uses web services.
iTextSharp is a great tool for generating PDFs with .NET on the Internet. I highly recommend it; I've used iText with Java...and have been using iTextSharp for the past few years.
There are several ports of iText for .NET (A very popular open-source PDF library for Java).
http://www.ujihara.jp/iTextdotNET/en/

Categories

Resources