Pechkin to Tuespechkin

5.4k Views Asked by At

For a project, we are migrating to Windows Azure. I have to make sure that the HTML to PDF converter will run on a 64 bit worker role.

Since Pechkin can't run as a 64bit application I have decided to use Tuespechkin, because they should be very alike and both use wkhtmltopdf to convert the HTML to PDF.

Now, i got this all set up but the resulting PDF is kind of disappointing.

Problems:

  1. The font is rendered differently. With Pechkin the font is always 'sharp' where tuespechkin makes it very bold. Results here: http://postimg.org/image/xngqxryn1/

    • I tried using different fonts (even browser default). All render very bold
    • I tried using different Object- and Globalsettings (DPI, Outline, compression, name it; it never changes much).
  2. All contents is selectable and copyable. I would like it to be more like an image (which is default in pechkin). Any advice on this would be appreciated.

Here is the code i am using to convert the HTML to PDF:

Pechkin, old:

var documentConfig = new ObjectConfig()
            .SetAllowLocalContent(true)
            .SetLoadImages(true)
            .SetRunJavascript(true)
            .SetPrintBackground(true)
            .SetRenderDelay(15000);

var globalConfig = new GlobalConfig()
            .SetMargins(new Margins(50, 50, 100, 100))
            .SetDocumentTitle(company.Name)
            .SetPaperSize(PaperKind.A4);

var pechkin = new SynchronizedPechkin(globalConfig);
var buffer = pechkin.Convert(documentConfig, parsedHtml);

Tuespechkin:

var converter = new ThreadSafeConverter(
                            //new ImageToolset(
                            new PdfToolset(
                                new Win64EmbeddedDeployment(
                                    new TempFolderDeployment()
                                )
                            )
                        );

        var documentConfig = new ObjectSettings {
            WebSettings = new WebSettings {
                EnableJavascript = true,
                PrintBackground = true, 
                PrintMediaType = true
            },
            LoadSettings = new LoadSettings {
                BlockLocalFileAccess = false,
                RenderDelay = 15000, 
            },

            HtmlText = parsedHtml
        };

        var globalConfig = new GlobalSettings();
        globalConfig.Margins = new MarginSettings(2.645833333333, 1.322916666667, 2.645833333333, 1.322916666667);
        globalConfig.Margins.Unit = Unit.Centimeters;
        globalConfig.DocumentTitle = company.Name;
        globalConfig.PaperSize = PaperKind.A4;
        globalConfig.UseCompression = false;
        globalConfig.DPI = 1200;


        var doc = new HtmlToPdfDocument {
            Objects = {
                 documentConfig 
             },
            GlobalSettings = globalConfig
        };

var buffer = converter.Convert(doc);

Any help on either problem would be much appreciated!

1

There are 1 best solutions below

1
On

As you say, I can't solve the problem. But IIS can be set to run 32-bit applications. as this photo: https://i.stack.imgur.com/6l6Es.png

So you can run Pechkin in you Azure. You can see more in this. https://codeutil.wordpress.com/2013/09/16/convert-html-to-pdf/