diff options
author | Jaume Pujantell <jaume.pujantell@collabora.com> | 2023-06-05 11:49:41 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-06-08 21:53:59 +0200 |
commit | 53d610786ba8085fcce331174c74294c90c41a20 (patch) | |
tree | 3f4af2f6ebc0a22b5070a0a951d79f6221309fa9 /vcl/source/gdi | |
parent | 260bc16e1923016d0628a8779e219b290d4c9011 (diff) |
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 <andras.timar@collabora.com>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 64 |
1 files changed, 61 insertions, 3 deletions
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 <tools/stream.hxx> #include <tools/helpers.hxx> #include <tools/urlobj.hxx> +#include <tools/UnitConversion.hxx> #include <tools/zcodec.hxx> #include <unotools/configmgr.hxx> #include <vcl/bitmapex.hxx> @@ -3901,10 +3902,64 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry c { appendObjectID(rNote.m_nObject, aLine); - aLine.append("<</Type /Annot /Subtype /Text "); + aLine.append("<</Type /Annot /Subtype "); + if (rNote.m_aContents.maPolygons.size() == 1) + { + auto const& rPolygon = rNote.m_aContents.maPolygons[0]; + aLine.append(rPolygon.isClosed() ? "/Polygon " : "/Polyline "); + aLine.append("/Vertices ["); + 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("] "); + if (rPolygon.isClosed()) + { + aLine.append("/IC ["); + appendColor(rNote.m_aContents.interiorColor, aLine, false); + aLine.append("] "); + } + } + else if (rNote.m_aContents.maPolygons.size() > 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<</W 0>>"); + + // 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); |