flyingsaucerproject / flyingsaucerproject.github.com

1 stars 1 forks source link

Do links in XHTML documents get created in generated PDFs? #1

Open menelaosbgr opened 7 years ago

menelaosbgr commented 7 years ago

I am generating PDF documents using flying saucer from XHTML.

Is flying saucer capable of creating links in the PDF document?

Up to now I am not seeing any links at all.

  ITextRenderer itextRender = null;
  Tidy tidy = new Tidy();
  tidy.setXmlOut(true);
  tidy.setShowWarnings(false);
  // tidy.setXmlTags(false);
  tidy.setInputEncoding(UTF_8_DN);
  tidy.setOutputEncoding(UTF_8_DN);
  tidy.setXHTML(true);//
  tidy.setMakeClean(true);
  dataStream = new ByteArrayInputStream(data);
  stream = new ByteArrayOutputStream(32 * 2048);

  org.w3c.dom.Document w3cDoc = tidy.parseDOM(dataStream, stream);
  itextRender = new ITextRenderer();
  itextRender.setDocument(w3cDoc, null);

  itextRender.layout();
  itextRender.createPDF(stream);

I have not found anything online related to this. Additionally, I've checked the w3cDoc and the links do exist within the xhtml document.

Thanks

tbeukhof commented 4 years ago

This seems to be the same issue: https://github.com/vjbollavarapu/flying-saucer/issues/120 We took the recommendation listed in the issue description and edited XhtmlCssOnlyNamespaceHandler.java to change the hasAttribute() checks to be getAttribute() != null instead, and that worked.