Css problem when converting pdftohtml then html to pdf with wkhtmltopdf.
I’m trying to convert a pdf to html, then translate the html and finally convert it back to PDF with wkhtmltopdf. The problem appeared immediately when I converted it to HTML with the command pdftohtml -c -s documents/fss4.pdf fss4-original.html
. The writing became smaller, the content was placed on the left and other problems appeared.
Here’s an image link to give you an idea of what happened.
After a long period of debugging, I finally solved these problems by adding these CSS codes, removing the bgcolor=”#A0A0A0
attribute in the body
and removing the CSS codes in the style attribute in “id=”page1-div“” and id=”page2-div“
which allowed me to display the HTML a little more appropriately in my browser.
#page-container {
background-color: #9e9e9e;
background-image: url(https://www.translatedocs.bloggors.com/assets/files/background.svg);
-webkit-transition: left 500ms;
transition: left 500ms;
margin-top: -25px;
}
.pf {
box-shadow: 1px 1px 3px 1px #333;
border-collapse: separate;
position: relative;
background-color: white;
overflow: hidden;
margin: 13px auto;
border: 0;
width:1024.000000px;
height:1455.411765px;
margin-bottom: -10px;
}
Next, I translated my HTML correctly. After that, I tried to convert my HTML to pdf with this command
wkhtmltopdf fss4-html-translated.html fss4-html-translated.pdf
it was converted but not completely to PDF.
Here’s the link to the image result to give you an idea.
I think it’s a CSS problem. I’d like to know if, by submitting the original HTML file and the translated HTML file, you could take a look at it so that I can improve it and produce an excellent result in the same way as the original PDF? Could you help? Here’s the github link where you’ll find the original PDF, the translated PDF, the original HTML and the translated HTML. I don’t want you to use this kind of command pdf2htmlEX --fit-width 1024 --space-as-offset 1 abc.pdf abc.html
to keep exactly the same layout. However, I want you to give me a solution with this instead pdftohtml -c -s documents/fss4.pdf fss4-original.html
Any help you can give me will be greatly appreciated.