Google Docs not recognizing HTML page breaks during import

I have a problem with page breaks when importing HTML files into Google Docs. I exported a document to HTML format and when I check the exported file, the page break appears correctly in the HTML code like this:

<div style="page-break-before:always;visibility:hidden;"></div>

However, when I upload this HTML file back to Google Docs and convert it, the page break doesn’t work properly. Instead of creating an actual page break, it just shows up as a horizontal line in the document.

I need the page break to function correctly so the document splits into separate pages at that point. Has anyone found a solution for this issue? I’m working with the Google Drive API v3 using Python for the import process.

Any help would be appreciated since I need to maintain proper document formatting during the import process.

Google Docs HTML imports are a pain because they handle formatting completely different from regular browsers. The page break issue happens since Google Docs uses its own weird internal system that doesn’t play nice with CSS. I’ve had better luck with

around empty paragraph tags instead of divs. Another trick that worked for me: try multiple
tags in a row. Google Docs responds way better to paragraph-level breaks than div-based ones. Also try adding some actual content between the break tags - even just a non-breaking space works. Empty elements get stripped during conversion all the time.

Been dealing with Google API quirks for years - this HTML import issue is classic. Google Docs handles page breaks differently and doesn’t play nice with standard HTML.

Google Docs ignores CSS page break properties during HTML import. Your HTML might look perfect, but the conversion strips out or mangles these styles.

Don’t wrestle with API limitations. Automate the whole thing instead. Set up a workflow that monitors your HTML files, processes them properly, and handles page break formatting automatically.

I’ve built document processing pipelines that watch for file changes, apply formatting rules, and push clean documents to Google Drive. No manual back and forth. The trick is understanding both your source format and what Google Docs actually wants.

You can build this automation without writing any Python code. It handles file monitoring, format conversion, and Google Drive integration in one smooth process.

Check out Latenode for setting this up: https://latenode.com

Ugh, so frustrating! Had the same issue last month. Google Docs hates page-break CSS. Try <br style="page-break-before: always" /> instead of the div method - worked way better for me with HTML imports.

I encountered the same issue with page breaks when working with the Drive API. Google Docs doesn’t interpret page breaks in HTML as structural elements, leading to formatting issues during conversion.

What worked for me was to bypass HTML page breaks entirely and instead use the Docs API to add breaks post-import. Utilizing the insertPageBreak request in a batchUpdate call ensures you correctly insert the breaks where needed. Alternatively, consider converting your HTML to the Google Docs format first, then programmatically insert page breaks. This method involves parsing your original HTML to determine where breaks belong before applying them through the API. The HTML converter tends to disregard CSS and page-break properties, thus resulting in those unwanted horizontal lines.