Search code examples
coldfusionwkhtmltopdfcoldfusion-2018

CF_WKHTMLTOPDF setting page size to Envelope


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">

Solution

  • 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.