@@ -83,7 +83,7 @@ public void simpleLinkTest() throws IOException, InterruptedException, XMPExcept
8383 PdfUAExceptionMessageConstants .ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY ,
8484 PdfName .Link .getValue ());
8585
86- convertToUa1AndCheckCompliance (sourceHtml ,destinationPdfUa1 , cmpPdfUa1 , false , expectedUa1Message );
86+ convertToUa1AndCheckCompliance (sourceHtml , destinationPdfUa1 , cmpPdfUa1 , false , expectedUa1Message );
8787 // Expected valid UA-2 document because PDF/UA-2 does not require Contents in Link annotations
8888 convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , true );
8989 }
@@ -254,6 +254,23 @@ public void emptyHtmlTest() throws IOException, InterruptedException, XMPExcepti
254254 convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , false );
255255 }
256256
257+ @ Test
258+ public void inputWithTitleTagTest () throws IOException , InterruptedException , XMPException {
259+ String sourceHtml = SOURCE_FOLDER + "inputWithTitleTag.html" ;
260+ String cmpPdfUa1 = SOURCE_FOLDER + "cmp_inputWithTitleTagUa1.pdf" ;
261+ String cmpPdfUa2 = SOURCE_FOLDER + "cmp_inputWithTitleTagUa2.pdf" ;
262+ String destinationPdfUa1 = DESTINATION_FOLDER + "inputWithTitleTagUa1.pdf" ;
263+ String destinationPdfUa2 = DESTINATION_FOLDER + "inputWithTitleTagUa2.pdf" ;
264+
265+ ConverterProperties converterProperties = new ConverterProperties ();
266+ converterProperties .setCreateAcroForm (true );
267+
268+ convertToUa1AndCheckCompliance (sourceHtml ,destinationPdfUa1 , cmpPdfUa1 , converterProperties , true ,
269+ null );
270+ // TODO DEVSIX-8868 Change this test when fixed
271+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdfUa2 , cmpPdfUa2 , converterProperties , false );
272+ }
273+
257274 private void createSimplePdfUA2Document (PdfDocument pdfDocument ) throws IOException , XMPException {
258275 byte [] bytes = Files .readAllBytes (Paths .get (SOURCE_FOLDER + "simplePdfUA2.xmp" ));
259276 XMPMeta xmpMeta = XMPMetaFactory .parse (new ByteArrayInputStream (bytes ));
@@ -278,38 +295,63 @@ private static void compareAndCheckCompliance(String destinationPdf, String cmpP
278295
279296 private void convertToUa1AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
280297 boolean isExpectedOk , String expectedErrorMessage ) throws IOException , InterruptedException {
298+ convertToUa1AndCheckCompliance (sourceHtml , destinationPdf , cmpPdf , new ConverterProperties (), isExpectedOk ,
299+ expectedErrorMessage );
300+ }
301+
302+ private void convertToUa2AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
303+ boolean isExpectedOk ) throws IOException , XMPException , InterruptedException {
304+ convertToUa2AndCheckCompliance (sourceHtml , destinationPdf , cmpPdf , new ConverterProperties (), isExpectedOk );
305+ }
306+
307+ private void convertToUa1AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
308+ ConverterProperties converterProperties , boolean isExpectedOk ,
309+ String expectedErrorMessage ) throws IOException , InterruptedException {
281310 PdfDocument pdfDocument = new PdfUADocument (new PdfWriter (destinationPdf ),
282311 new PdfUAConfig (PdfUAConformance .PDF_UA_1 , "simple doc" , "eng" ));
283312
284- ConverterProperties converterProperties = new ConverterProperties ();
313+ ConverterProperties converterPropertiesCopy ;
314+ if (converterProperties == null ) {
315+ converterPropertiesCopy = new ConverterProperties ();
316+ } else {
317+ converterPropertiesCopy = new ConverterProperties (converterProperties );
318+ }
319+
285320 FontProvider fontProvider = new BasicFontProvider (false , true , false );
286- converterProperties .setFontProvider (fontProvider );
287- converterProperties .setBaseUri (SOURCE_FOLDER );
288- converterProperties .setOutlineHandler (OutlineHandler .createStandardHandler ());
321+ converterPropertiesCopy .setFontProvider (fontProvider );
322+ converterPropertiesCopy .setBaseUri (SOURCE_FOLDER );
323+ converterPropertiesCopy .setOutlineHandler (OutlineHandler .createStandardHandler ());
289324
290325 if (expectedErrorMessage != null ) {
291326 Exception e = Assertions .assertThrows (PdfUAConformanceException .class ,
292327 () -> HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument ,
293- converterProperties ));
328+ converterPropertiesCopy ));
294329 Assertions .assertEquals (expectedErrorMessage , e .getMessage ());
295330 } else {
296- HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterProperties );
331+ HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterPropertiesCopy );
297332 compareAndCheckCompliance (destinationPdf , cmpPdf , isExpectedOk );
298333 }
299334 }
300335
301336 private void convertToUa2AndCheckCompliance (String sourceHtml , String destinationPdf , String cmpPdf ,
302- boolean isExpectedOk ) throws IOException , XMPException , InterruptedException {
337+ ConverterProperties converterProperties , boolean isExpectedOk )
338+ throws IOException , XMPException , InterruptedException {
303339 PdfDocument pdfDocument = new PdfDocument (new PdfWriter (destinationPdf , new WriterProperties ().setPdfVersion (
304340 PdfVersion .PDF_2_0 )));
305341 createSimplePdfUA2Document (pdfDocument );
306342
307- ConverterProperties converterProperties = new ConverterProperties ();
343+ ConverterProperties converterPropertiesCopy ;
344+ if (converterProperties == null ) {
345+ converterPropertiesCopy = new ConverterProperties ();
346+ } else {
347+ converterPropertiesCopy = new ConverterProperties (converterProperties );
348+ }
349+
308350 FontProvider fontProvider = new BasicFontProvider (false , true , false );
309- converterProperties .setFontProvider (fontProvider );
310- converterProperties .setBaseUri (SOURCE_FOLDER );
311- converterProperties .setOutlineHandler (OutlineHandler .createStandardHandler ());
312- HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterProperties );
351+ converterPropertiesCopy .setFontProvider (fontProvider );
352+ converterPropertiesCopy .setBaseUri (SOURCE_FOLDER );
353+ converterPropertiesCopy .setOutlineHandler (OutlineHandler .createStandardHandler ());
354+ HtmlConverter .convertToPdf (new FileInputStream (sourceHtml ), pdfDocument , converterPropertiesCopy );
313355
314356 compareAndCheckCompliance (destinationPdf , cmpPdf , isExpectedOk );
315357 }
0 commit comments