2

I am using WKHTMLTOPDF in ColdFusion 18 and am trying to have the page size be "Envelope DL". I found the global setting size.PageSize so in the code below I added pagesize = "Envelope DL" but this did not change it. Does anyone have any other ideas or could tell me what I am missing?

Any help would be greatly appreciated!

<CF_WKHTMLTOPDF
    PageURL = "http://www.com/temppdf/test.htm"
    filename = "D://temppdf/test.pdf"
    orientation = "portrait"
    DisableSmartShrinking="yes"
    margintop = "0.25"
    marginleft = "0.25"
    marginright = "0.25"
    marginbottom = "0.25"
    TimeOut = "180"
    AddFooterPageNum="yes">

<cfheader name="content-disposition" value="inline; filename=""CS_#Dateformat(NOW(),'MMDDYYYY')#.pdf""">
<cfcontent type="application/pdf" file="D://temppdf/test.pdf" deletefile="Yes">
rrk
  • 15,677
  • 4
  • 29
  • 45
David Brierton
  • 6,977
  • 12
  • 47
  • 104
  • Is wkhtmltopdf a custom tag or is it an external `.exe` – James A Mohler Nov 26 '19 at 16:33
  • 1
    @JamesAMohler wkhtmltopdf is an external `.exe` that's installed on the application server. His code example is confusing because he's calling it through both a custom tag and direct command line execution via ``. – user12031119 Nov 26 '19 at 18:36

2 Answers2

3

I wrote the ColdFusion WKHTMLTOPDF custom tag. If you look at the source code, the notes indicate where to look for the "pagesize" parameter.

Here are the allowable paper sizes. (I've used "Comm10E" for my envelopes):

http://doc.qt.io/qt-4.8/qprinter.html#PaperSize-enum

QPrinter::A0    5   841 x 1189 mm
QPrinter::A1    6   594 x 841 mm
QPrinter::A2    7   420 x 594 mm
QPrinter::A3    8   297 x 420 mm
QPrinter::A4    0   210 x 297 mm, 8.26 x 11.69 inches
QPrinter::A5    9   148 x 210 mm
QPrinter::A6    10  105 x 148 mm
QPrinter::A7    11  74 x 105 mm
QPrinter::A8    12  52 x 74 mm
QPrinter::A9    13  37 x 52 mm
QPrinter::B0    14  1000 x 1414 mm
QPrinter::B1    15  707 x 1000 mm
QPrinter::B2    17  500 x 707 mm
QPrinter::B3    18  353 x 500 mm
QPrinter::B4    19  250 x 353 mm
QPrinter::B5    1   176 x 250 mm, 6.93 x 9.84 inches
QPrinter::B6    20  125 x 176 mm
QPrinter::B7    21  88 x 125 mm
QPrinter::B8    22  62 x 88 mm
QPrinter::B9    23  33 x 62 mm
QPrinter::B10   16  31 x 44 mm
QPrinter::C5E   24  163 x 229 mm
QPrinter::Comm10E   25  105 x 241 mm, U.S. Common 10 Envelope
QPrinter::DLE   26  110 x 220 mm
QPrinter::Executive 4   7.5 x 10 inches, 190.5 x 254 mm
QPrinter::Folio 27  210 x 330 mm
QPrinter::Ledger    28  431.8 x 279.4 mm
QPrinter::Legal 3   8.5 x 14 inches, 215.9 x 355.6 mm
QPrinter::Letter    2   8.5 x 11 inches, 215.9 x 279.4 mm
QPrinter::Tabloid   29  279.4 x 431.8 mm
QPrinter::Custom    30  Unknown, or a user defined size.
James Moberg
  • 4,360
  • 1
  • 22
  • 21
  • Hey James does it have an automatic print feature? – David Brierton Dec 02 '19 at 21:41
  • Like instead of the preview that pops up is it possible to have it just start printing? – David Brierton Dec 02 '19 at 21:57
  • in chrome that is – David Brierton Dec 02 '19 at 21:57
  • Not that I know of. I once used a javascript-based technique that do this, but I don't think it works anymore. When dynamically generating PDFs, I usually force a download and/or store was a statically-generated PDF file. Chrome 77 disabled auto-print. Here's a Chrome plugin, but your mileage may vary: https://chrome.google.com/webstore/detail/chrome-direct-print/fnfkcaeloalplnglklappfjfjeafakeo?hl=en-US What is your actually need? (You could set up a sub-directory that auto-prints any recently saved PDF files.) – James Moberg Dec 02 '19 at 22:02
  • awesome thanks for helping me for what I should look for – David Brierton Dec 02 '19 at 22:05
  • This is what finally worked for me to set the size for #10 envelopes using barryvdh/laravel-snappy with loadView(). – JustLearninThisStuff Mar 03 '21 at 05:04
2

According to the wkhtmltopdf manual located here it then refers you to list of usable --page-size options which can be found here.

The page size of "DL Envelope" is 110mm x 220mm. So the page size option you need to supply to wkhtmltopdf is --page-size DLE.

user12031119
  • 1,228
  • 4
  • 14
  • @DavidBrierton your code example is confusing. Are you direct executing `wkhtmltopdf` via command line using `` or are you calling it through a custom tag using ``? – user12031119 Nov 26 '19 at 19:26
  • @DavidBrierton Being that you're defining your page attributes in the custom tag, then yes add it there. Then inside the custom tag, pass that parameter into the `` as an argument as I'm presuming all the other arguments are coded that way. – user12031119 Nov 26 '19 at 19:37