Tutorials
Turn an HTML assignment into a PDF for school: what survives the conversion
Convert a single .html file into an A4 PDF in your browser. Learn which styles and images make it into the PDF, which do not, and how to prepare the file so the marker sees your actual work.
AllYouConvert · Updated November 10, 2026 · 3 min read

On this page
Web development and digital media courses often ask you to build an HTML page and then submit it as a PDF, because learning platforms such as Canvas, Moodle and Google Classroom either block .html uploads or show them without their styles. HTML to PDF turns one .html or .htm file into an A4 PDF on your device. Knowing how it works saves you from submitting a PDF that is missing half your design.
How the converter builds the PDF
The tool opens your file in a hidden frame, takes the content of the page body, removes any <script> tags, and draws the result as a picture between 600 and 1200 pixels wide. That picture is then cut into A4 slices and placed on PDF pages with a margin. If drawing the page fails, the tool falls back to a text-only PDF that keeps your words but none of the layout.
Because each page is a picture of your HTML, the text in the PDF cannot be selected, searched or copied. If your instructor needs selectable text, for example to check your code listing, use your browser's Print → Save as PDF instead.
What makes it into the PDF
- Inline styles written as style="..." attributes on elements.
- <style> blocks placed inside the <body>.
- Text, headings, lists, tables and basic layout such as flexbox and grid when the styles are inline or in the body.
- Images embedded as data: URLs (base64).
What gets lost
- <style> blocks and <link rel="stylesheet"> tags in the <head>. Only the body is drawn, so styles in the head do not apply.
- External CSS files, such as style.css in the same folder. The converter only receives the one HTML file you choose, not the folder around it.
- Images referenced by a path, such as <img src="images/logo.png">. Those files are not part of the upload, so they appear blank.
- Web fonts loaded from Google Fonts or another server. Text falls back to Helvetica or Arial.
- Anything built by JavaScript, such as charts, content loaded after the page opens and interactive widgets. Scripts are removed before drawing.
Prepare a copy of your file first
1Work on a copy
Duplicate your HTML file, for example assignment-print.html, so your real submission files stay untouched.
2Move the CSS into the body
Paste the contents of style.css into a <style> block placed as the first thing inside <body>, and delete the <link> tag.
3Embed images
Convert each image to a data URL with any base64 tool and paste it into src. Keep images small: a few hundred kilobytes each is plenty for a PDF.
4Show your code as text
If the brief asks to see your source code, put it in a <pre> block. Remember the PDF is an image, so the marker reads it but cannot copy it.
Convert and check
1Drop the prepared .html file
The file is opened in your browser. Nothing is uploaded.
2Convert to PDF
The page is drawn, sliced into A4 pages and downloaded as a PDF.
3Inspect every page
Look for blank image boxes, missing colours and lines cut in half where one page ends and the next starts. Adding a little extra space between sections in your HTML moves the cut.
If the assignment also needs a cover sheet or a written reflection, export those to PDF separately and combine them with Merge PDF. Organize PDF lets you reorder pages or drop a blank one at the end.
01Why is my PDF missing all its colours and layout?
Your styles are almost certainly in the <head> or in a separate CSS file. Move them into a <style> block inside the <body> and convert again.
02Why can I not select the text in the PDF?
Each page is stored as an image of your HTML. For selectable text, open the page in Chrome or Edge and use Print → Save as PDF.
03Are my files uploaded?
No. The HTML is drawn and the PDF is assembled in your browser tab.
Convert your HTML file
Drop a prepared .html file and get an A4 PDF made on this device.
Open HTML to PDF


