Skip to content

Commit cddeb74

Browse files
vitali-priText-CI
authored andcommitted
Support structure destinations for outlines
DEVSIX-7956 Autoported commit. Original commit hash: [922093fd9]
1 parent e383b98 commit cddeb74

File tree

17 files changed

+47
-6
lines changed

17 files changed

+47
-6
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/HtmlConverterPdfUA2Test.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License
2222
*/
2323
using System;
2424
using System.IO;
25+
using iText.Html2pdf.Attach.Impl;
2526
using iText.Html2pdf.Resolver.Font;
2627
using iText.Kernel.Pdf;
2728
using iText.Kernel.Utils;
@@ -88,6 +89,23 @@ public virtual void BackwardLinkTest() {
8889
CompareAndCheckCompliance(destinationPdf, cmpPdf, false);
8990
}
9091

92+
[NUnit.Framework.Test]
93+
public virtual void SimpleOutlineTest() {
94+
String sourceHtml = SOURCE_FOLDER + "simpleOutline.html";
95+
String destinationPdf = DESTINATION_FOLDER + "simpleOutline.pdf";
96+
String cmpPdf = SOURCE_FOLDER + "cmp_simpleOutline.pdf";
97+
PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationPdf, new WriterProperties().SetPdfVersion
98+
(PdfVersion.PDF_2_0)));
99+
CreateSimplePdfUA2Document(pdfDocument);
100+
ConverterProperties converterProperties = new ConverterProperties();
101+
FontProvider fontProvider = new DefaultFontProvider(false, true, false);
102+
converterProperties.SetFontProvider(fontProvider);
103+
converterProperties.SetOutlineHandler(OutlineHandler.CreateStandardHandler());
104+
HtmlConverter.ConvertToPdf(new FileStream(sourceHtml, FileMode.Open, FileAccess.Read), pdfDocument, converterProperties
105+
);
106+
CompareAndCheckCompliance(destinationPdf, cmpPdf, true);
107+
}
108+
91109
private void CreateSimplePdfUA2Document(PdfDocument pdfDocument) {
92110
byte[] bytes = File.ReadAllBytes(System.IO.Path.Combine(SOURCE_FOLDER + "simplePdfUA2.xmp"));
93111
XMPMeta xmpMeta = XMPMetaFactory.Parse(new MemoryStream(bytes));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
</head>
4+
<body>
5+
<H1>Top level</H1>
6+
<div>text</div>
7+
<H2>Sublevel 1</H2>
8+
<div>text</div>
9+
<H4>Sublevel 1.1</H4>
10+
<div>text</div>
11+
<H4>Sublevel 1.2</H4>
12+
<div>text</div>
13+
<H2>Sublevel 2</H2>
14+
<div>text</div>
15+
<H4>Sublevel 2.1</H4>
16+
<div>text</div>
17+
<H4>Sublevel 2.2</H4>
18+
<div>text</div>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)