2

The page should when the text ends. So, that there is only one "page". Don't worry. It's not for being printed.

\documentclass[12pt]{article}

% Packages
\usepackage{lipsum,anyfontsize}
\usepackage[left=100px,right=100px,top=50px,bottom=50px,
paperwidth=1052px, paperheight=2250 px]{geometry} % max 15800 long

\begin{document}
 \fontsize{35}{42}\selectfont
 \lipsum[1-5]
\end{document}

This is for a board. You can upload pictures (yes, I can convert to pictures) and there is a perfect format (e.g. 1052px).

  • It is very important that the units are in pixel.

  • Advices for a better/easier font(-size) are appreciated but not needed (Font is unbelievable big as a cause of using px as unit).

I found this one Is there a way to make "page" size match document length? but I does not help. Pls don't hate me.

3

1 Answer 1

5

The following example puts the page contents in a box, measures the box and ship outs a page with the corrected dimensions for the height of the page. The example assumes pdfTeX or LuaTeX. Here \pdf(h,v)origin and \pdfpage(height,width) are available to set the dimensions of the output page.

% arara: pdflatex
\documentclass[12pt]{article}

\usepackage{lipsum,anyfontsize}

\makeatletter
\newcommand*{\PrintPageHeight}{%
  \edef\PageHeightPt{\strip@pt\pdfpageheight pt}%
  \edef\PageHeightPx{%
    \strip@pt\dimexpr
      % scaling operation with doubled precision
      \pdfpageheight
      *\dimexpr1pt\relax
      /\dimexpr1px\relax
    \relax
    px
  }%
  \typeout{}%
  \typeout{=> Page height = \PageHeightPt\space = \PageHeightPx}%
  \typeout{}%
}
\makeatother

\newcommand*{\CheckPageHeight}{%
  \ifdim\pdfpageheight>15800px %
    \errmessage{Page height is too large!}%
  \fi
}

\setlength{\paperwidth}{1052px}
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-200px}% 2 * 100px

\setlength{\pdfhorigin}{100px}
\setlength{\pdfvorigin}{50px}
\setlength{\pdfpagewidth}{\paperwidth}

\newsavebox{\PageBox}
\newenvironment{board}{%
  \setbox\PageBox=\vbox\bgroup
  \begingroup % for color support
}{%
  \endgroup
  \egroup
  \setlength{\paperheight}{\ht\PageBox}%
  \addtolength{\paperheight}{\dp\PageBox}%
  \addtolength{\paperheight}{100px}% 2 * 50px
  \setlength{\pdfpageheight}{\paperheight}%
  \shipout\box\PageBox
  \PrintPageHeight
  \CheckPageHeight
}
\setlength{\maxdepth}{0pt}
\setlength{\topskip}{0pt}
\pagestyle{empty}

\begin{document}
  \begin{board}
    \fontsize{35}{42}\selectfont
    \lipsum[1-5]
  \end{board}
\end{document}

Reported page height:

=> Page height = 2518.68092pt = 2509.26201px
2
  • Is there a way of knowing the actual page height? Or restrict the pageheight to 15800px? Mar 25, 2016 at 19:17
  • 1
    @JoelDuscha I have updated the answer, it prints the page height in pt and px. Also the height is checked and an error is thrown, if the page height is too large. Mar 25, 2016 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .