Я пытался преобразовать файл HTML в PDF с помощью iText с Java. Однако в моем PDF-файле есть область другого цвета из-за свойства фона тега . PDF-файл должен иметь полностью белый фон, как и класс . Есть ли способ добиться этого вместо изменения фона на белый?
[img]https: //i.sstatic.net/0k1GBloC.png[/img]
Это мой HTML и CSS
Document
@page {
margin-left: 0;
margin-right: 0;
margin-top: 0;
@bottom-left {
margin-left: 10px;
content: "Page " counter(page) " / " counter(pages);
}
}
body {
scroll-behavior: smooth;
color: #000;
font-weight: normal;
background: #f0f0f0;
background-color: rgb(244, 180, 103);
width: 100%;
line-height: 20pt;
text-align: justify;
margin: 0 auto;
height: 100%;
}
@media print {
body {
background-color: #fff;
}
}
.container {
scroll-behavior: smooth;
width: 210mm;
padding: 25mm 25mm 25mm 35mm;
background: #FFF;
margin: 0 auto;
box-sizing: border-box;
position: relative;
font-size: 14pt;
height: 100%;
}
CONTAINER
This is my data
This is my data
This is my data
This is my data
This is my data
This is my data
This is my data
This is my data
Это мой Java-код
private static final String HTML_FILE_PATH = "C:/yourlocation/input.html";
private static final String PDF_FILE_PATH = "C:/yourlocation/output.pdf";
public static void main(String[] args) throws IOException {
System.out.println("Hello World!");
FontProvider fontProvider = new DefaultFontProvider(true, true, true);
ConverterProperties properties = new ConverterProperties();
properties.setCharset("UTF-8");
properties.setFontProvider(fontProvider);
File htmlFile = new File(HTML_FILE_PATH);
File pdfFile = new File(PDF_FILE_PATH);
try (FileInputStream fStream = new FileInputStream(htmlFile)) {
System.out.println("BEGIN to convert HTML to PDF");
HtmlConverter.convertToPdf(fStream, new FileOutputStream(pdfFile), properties);
System.out.println("FINISHED convert HTML to PDF");
} catch (IOException e) {
e.printStackTrace();
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... ound-color
IText HTML в PDF с нежелательным цветом фона ⇐ CSS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение