From 53d610786ba8085fcce331174c74294c90c41a20 Mon Sep 17 00:00:00 2001 From: Jaume Pujantell Date: Mon, 5 Jun 2023 11:49:41 +0200 Subject: pdfium: better suport for annotations and some fixes Added suport to import FreeText annotations. Added some suport to export graphical annotations. Fixed some color issues to be more inline with the pdfium library. Change-Id: I7371595ebb95594ee765ae532ca7c7d4f0499592 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152606 Tested-by: Jenkins Reviewed-by: Andras Timar --- vcl/source/gdi/pdfwriter_impl.cxx | 64 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'vcl/source/gdi') diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 36fa35e0f6a1..718433aafc02 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -3901,10 +3902,64 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c { appendObjectID(rNote.m_nObject, aLine); - aLine.append("< 1) + { + aLine.append("/Ink /InkList ["); + for (auto const& rPolygon : rNote.m_aContents.maPolygons) + { + aLine.append("["); + for (sal_uInt32 i = 0; i < rPolygon.count(); ++i) + { + appendDouble(convertMm100ToPoint(rPolygon.getB2DPoint(i).getX()), aLine, + nLog10Divisor); + aLine.append(" "); + appendDouble(m_aPages[rNote.m_nPage].getHeight() + - convertMm100ToPoint(rPolygon.getB2DPoint(i).getY()), + aLine, nLog10Divisor); + aLine.append(" "); + } + aLine.append("]"); + aLine.append("/C ["); + appendColor(rNote.m_aContents.annotColor, aLine, false); + aLine.append("] "); + } + aLine.append("] "); + } + else if (rNote.m_aContents.isFreeText) + aLine.append("/FreeText "); + else + aLine.append("/Text "); -// i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate to 1, since it's a 'should' -// see PDF 8.4.2 and ISO 19005-1:2005 6.5.3 + aLine.append("/BS<>"); + + // i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate to 1, since it's a 'should' + // see PDF 8.4.2 and ISO 19005-1:2005 6.5.3 if (m_bIsPDF_A1 || m_bIsPDF_A2 || m_bIsPDF_A3) aLine.append("/F 4 "); @@ -9299,6 +9354,8 @@ void PDFWriterImpl::writeReferenceXObject(const ReferenceXObjectEmit& rEmit) aStream.append(" re\n"); aStream.append("f*\n"); + // Reset non-stroking color in case the XObject uses the default + aStream.append("0 0 0 rg\n"); // No reference XObject, draw the form XObject containing the original // page streams. aStream.append("/Im"); @@ -10356,6 +10413,7 @@ void PDFWriterImpl::createNote( const tools::Rectangle& rRect, const PDFNote& rN rNoteEntry.m_aPopUpAnnotation.m_nParentObject = rNoteEntry.m_nObject; rNoteEntry.m_aContents = rNote; rNoteEntry.m_aRect = rRect; + rNoteEntry.m_nPage = nPageNr; // convert to default user space now, since the mapmode may change m_aPages[nPageNr].convertRect(rNoteEntry.m_aRect); -- cgit