Closed bartek4c closed 4 years ago
I haven't tried that scenario, but you can pass additional options using the CustomWkHtmlPageArgs
property of your PdfConversionSettings
. There are the following places to stick additional configuration
CustomWkHtmlArgs
CustomWkHtmlCoverArgs
CustomWkHtmlPageArgs
CustomWkHtmlTocArgs
CustomWkHtmlFooterArgs
CustomWkHtmlHeaderArgs
Something like the following should be what you're after. I'll try and make a test to see if that works, just need to find a site I know that requires some sort of auth or api token.
In the PDF you'll see the header in the output.
var settings = new PdfConversionSettings
{
Title = "I can have headers?",
OutputPath = @"C:\temp\custom-header.pdf",
ContentUrl = "https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending",
CustomWkHtmlPageArgs = "--custom-header authorization \"bearer ABC123xyz789\""
};
PdfConvert.Convert(settings);
I think this fixed your old issue? Closing. If it hasn't let me, I promise it won't be two years for a response. :)
Hi,
Thanks for a great tool! It works great for me, apart of one fairly big issue. When I generate the PDF I point the tool to the URL of another application, but I also need to pass the authorization token together with the request. Currently I don't know how to do it. I have looked into WkHtmlToPdf documentation and found the --custom-header option in the tool, but I'm not sure how to implement it into your code. Any chance you could help me with that? Thanks