Upload 478 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+4
- poppler-23.11.0/Library/bin/Lerc.dllAdded
- poppler-23.11.0/Library/bin/cairo.dllAdded+3
- poppler-23.11.0/Library/bin/charset.dllAdded
- poppler-23.11.0/Library/bin/deflate.dllAdded
- poppler-23.11.0/Library/bin/expat.dllAdded
- poppler-23.11.0/Library/bin/fontconfig-1.dllAdded
- poppler-23.11.0/Library/bin/freetype.dllAdded
- poppler-23.11.0/Library/bin/iconv.dllAdded
- poppler-23.11.0/Library/bin/jpeg8.dllAdded
- poppler-23.11.0/Library/bin/lcms2.dllAdded
- poppler-23.11.0/Library/bin/libcrypto-3-x64.dllAdded+3
- poppler-23.11.0/Library/bin/libcurl.dllAdded
- poppler-23.11.0/Library/bin/libexpat.dllAdded
- poppler-23.11.0/Library/bin/liblzma.dllAdded
- poppler-23.11.0/Library/bin/libpng16.dllAdded
- poppler-23.11.0/Library/bin/libssh2.dllAdded
- poppler-23.11.0/Library/bin/libtiff.dllAdded
- poppler-23.11.0/Library/bin/libzstd.dllAdded
- poppler-23.11.0/Library/bin/openjp2.dllAdded
- poppler-23.11.0/Library/bin/pdfattach.exeAdded
- poppler-23.11.0/Library/bin/pdfdetach.exeAdded
- poppler-23.11.0/Library/bin/pdffonts.exeAdded
- poppler-23.11.0/Library/bin/pdfimages.exeAdded
- poppler-23.11.0/Library/bin/pdfinfo.exeAdded
- poppler-23.11.0/Library/bin/pdfseparate.exeAdded
- poppler-23.11.0/Library/bin/pdftocairo.exeAdded
- poppler-23.11.0/Library/bin/pdftohtml.exeAdded
- poppler-23.11.0/Library/bin/pdftoppm.exeAdded
- poppler-23.11.0/Library/bin/pdftops.exeAdded
- poppler-23.11.0/Library/bin/pdftotext.exeAdded
- poppler-23.11.0/Library/bin/pdfunite.exeAdded
- poppler-23.11.0/Library/bin/pixman-1-0.dllAdded
- poppler-23.11.0/Library/bin/poppler-cpp.dllAdded
- poppler-23.11.0/Library/bin/poppler-glib.dllAdded
- poppler-23.11.0/Library/bin/poppler.dllAdded+3
- poppler-23.11.0/Library/bin/tiff.dllAdded
- poppler-23.11.0/Library/bin/zlib.dllAdded
- poppler-23.11.0/Library/bin/zstd.dllAdded
- poppler-23.11.0/Library/bin/zstd.exeAdded
- poppler-23.11.0/Library/include/poppler/Annot.hAdded+1784
- poppler-23.11.0/Library/include/poppler/AnnotStampImageHelper.hAdded+68
- poppler-23.11.0/Library/include/poppler/Array.hAdded+92
- poppler-23.11.0/Library/include/poppler/BBoxOutputDev.hAdded+54
- poppler-23.11.0/Library/include/poppler/CMap.hAdded+128
- poppler-23.11.0/Library/include/poppler/CachedFile.hAdded+149
- poppler-23.11.0/Library/include/poppler/CairoFontEngine.hAdded+143
- poppler-23.11.0/Library/include/poppler/CairoOutputDev.hAdded+537
- poppler-23.11.0/Library/include/poppler/CairoRescaleBox.hAdded+60
- poppler-23.11.0/Library/include/poppler/Catalog.hAdded+321
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353637383932 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textpoppler-23.11.0/Library/bin/cairo.dll filter=lfs diff=lfs merge=lfs -textpoppler-23.11.0/Library/bin/libcrypto-3-x64.dll filter=lfs diff=lfs merge=lfs -textpoppler-23.11.0/Library/bin/poppler.dll filter=lfs diff=lfs merge=lfs -textpoppler-23.11.0/Library/lib/poppler.lib filter=lfs diff=lfs merge=lfs -text
123version https://git-lfs.github.com/spec/v1oid sha256:0d41677d426dff76abe58600bfac9e7c845f6f0da9042eb7c22b64a3d5e533dasize 1016320123version https://git-lfs.github.com/spec/v1oid sha256:2108d58bcd283f875a4f4c9c4d6c25ba2ac7fef1d0a7c22ba957403033f96e03size 6194176123version https://git-lfs.github.com/spec/v1oid sha256:b2252a2476bf23c24d65fed0fe0d12ee314feb9d935d6379c2838cd3c49b1a89size 500582412345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784//========================================================================//// Annot.h//// Copyright 2000-2003 Glyph & Cog, LLC////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2006 Scott Turner <scotty1024@mac.com>// Copyright (C) 2007, 2008 Julien Rebetez <julienr@svn.gnome.org>// Copyright (C) 2007-2011, 2013, 2015, 2018 Carlos Garcia Campos <carlosgc@gnome.org>// Copyright (C) 2007, 2008 Iñigo Martínez <inigomartinez@gmail.com>// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>// Copyright (C) 2008 Pino Toscano <pino@kde.org>// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>// Copyright (C) 2009-2011, 2013, 2016-2023 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>// Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com>// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>// Copyright (C) 2013, 2017, 2023 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich// Copyright (C) 2018 Dileep Sankhla <sankhla.dileep96@gmail.com>// Copyright (C) 2018-2020 Tobias Deiminger <haxtibal@posteo.de>// Copyright (C) 2018, 2020, 2022 Oliver Sander <oliver.sander@tu-dresden.de>// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>// Copyright (C) 2019 Umang Malik <umang99m@gmail.com>// Copyright (C) 2019 João Netto <joaonetto901@gmail.com>// Copyright (C) 2020 Nelson Benítez León <nbenitezl@gmail.com>// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden// Copyright (C) 2020 Katarina Behrens <Katarina.Behrens@cib.de>// Copyright (C) 2020 Thorsten Behrens <Thorsten.Behrens@CIB.de>// Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>.// Copyright (C) 2021 Zachary Travis <ztravis@everlaw.com>// Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>// Copyright (C) 2021 Georgiy Sgibnev <georgiy@sgibnev.com>. Work sponsored by lab50.net.// Copyright (C) 2022 Martin <martinbts@gmx.net>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef ANNOT_H#define ANNOT_H
#include <memory>#include <atomic>#include <mutex>#include <vector>
#include "AnnotStampImageHelper.h"#include "Object.h"#include "poppler_private_export.h"
class XRef;class Gfx;class CharCodeToUnicode;class GfxFont;class GfxResources;class Page;class PDFDoc;class Form;class FormWidget;class FormField;class FormFieldButton;class FormFieldText;class FormFieldChoice;class FormFieldSignature;class PDFRectangle;class Movie;class LinkAction;class Sound;class FileSpec;
enum AnnotLineEndingStyle{ annotLineEndingSquare, // Square annotLineEndingCircle, // Circle annotLineEndingDiamond, // Diamond annotLineEndingOpenArrow, // OpenArrow annotLineEndingClosedArrow, // ClosedArrow annotLineEndingNone, // None annotLineEndingButt, // Butt annotLineEndingROpenArrow, // ROpenArrow annotLineEndingRClosedArrow, // RClosedArrow annotLineEndingSlash // Slash};
enum AnnotExternalDataType{ annotExternalDataMarkupUnknown, annotExternalDataMarkup3D // Markup3D};
enum class VariableTextQuadding{ leftJustified, centered, rightJustified};
//------------------------------------------------------------------------// AnnotCoord//------------------------------------------------------------------------
class AnnotCoord{public: AnnotCoord() : x(0), y(0) { } AnnotCoord(double _x, double _y) : x(_x), y(_y) { }
double getX() const { return x; } double getY() const { return y; }
protected: double x, y;};
//------------------------------------------------------------------------// AnnotPath//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotPath{public: AnnotPath(); explicit AnnotPath(Array *array); explicit AnnotPath(std::vector<AnnotCoord> &&coords); ~AnnotPath();
AnnotPath(const AnnotPath &) = delete; AnnotPath &operator=(const AnnotPath &other) = delete;
double getX(int coord) const; double getY(int coord) const; AnnotCoord *getCoord(int coord); int getCoordsLength() const { return coords.size(); }
protected: std::vector<AnnotCoord> coords;
void parsePathArray(Array *array);};
//------------------------------------------------------------------------// AnnotCalloutLine//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotCalloutLine{public: AnnotCalloutLine(double x1, double y1, double x2, double y2); virtual ~AnnotCalloutLine();
AnnotCalloutLine(const AnnotCalloutLine &) = delete; AnnotCalloutLine &operator=(const AnnotCalloutLine &other) = delete;
double getX1() const { return coord1.getX(); } double getY1() const { return coord1.getY(); } double getX2() const { return coord2.getX(); } double getY2() const { return coord2.getY(); }
protected: AnnotCoord coord1, coord2;};
//------------------------------------------------------------------------// AnnotCalloutMultiLine//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotCalloutMultiLine : public AnnotCalloutLine{public: AnnotCalloutMultiLine(double x1, double y1, double x2, double y2, double x3, double y3); ~AnnotCalloutMultiLine() override;
double getX3() const { return coord3.getX(); } double getY3() const { return coord3.getY(); }
protected: AnnotCoord coord3;};
//------------------------------------------------------------------------// AnnotBorderEffect//------------------------------------------------------------------------
class AnnotBorderEffect{public: enum AnnotBorderEffectType { borderEffectNoEffect, // S borderEffectCloudy // C };
explicit AnnotBorderEffect(Dict *dict);
AnnotBorderEffectType getEffectType() const { return effectType; } double getIntensity() const { return intensity; }
private: AnnotBorderEffectType effectType; // S (Default S) double intensity; // I (Default 0)};
//------------------------------------------------------------------------// AnnotQuadrilateral//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotQuadrilaterals{public: class POPPLER_PRIVATE_EXPORT AnnotQuadrilateral { public: AnnotQuadrilateral(); AnnotQuadrilateral(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
AnnotCoord coord1, coord2, coord3, coord4; };
AnnotQuadrilaterals(Array *array, PDFRectangle *rect); AnnotQuadrilaterals(std::unique_ptr<AnnotQuadrilateral[]> &&quads, int quadsLength); ~AnnotQuadrilaterals();
AnnotQuadrilaterals(const AnnotQuadrilaterals &) = delete; AnnotQuadrilaterals &operator=(const AnnotQuadrilaterals &other) = delete;
double getX1(int quadrilateral); double getY1(int quadrilateral); double getX2(int quadrilateral); double getY2(int quadrilateral); double getX3(int quadrilateral); double getY3(int quadrilateral); double getX4(int quadrilateral); double getY4(int quadrilateral); int getQuadrilateralsLength() const { return quadrilateralsLength; }
protected: std::unique_ptr<AnnotQuadrilateral[]> quadrilaterals; int quadrilateralsLength;};
//------------------------------------------------------------------------// AnnotBorder//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotBorder{public: enum AnnotBorderType { typeArray, typeBS };
enum AnnotBorderStyle { borderSolid, // Solid borderDashed, // Dashed borderBeveled, // Beveled borderInset, // Inset borderUnderlined // Underlined };
virtual ~AnnotBorder();
AnnotBorder(const AnnotBorder &) = delete; AnnotBorder &operator=(const AnnotBorder &other) = delete;
virtual void setWidth(double new_width) { width = new_width; }
virtual AnnotBorderType getType() const = 0; virtual double getWidth() const { return width; } virtual const std::vector<double> &getDash() const { return dash; } virtual AnnotBorderStyle getStyle() const { return style; }
virtual Object writeToObject(XRef *xref) const = 0; virtual std::unique_ptr<AnnotBorder> copy() const = 0;
protected: AnnotBorder();
bool parseDashArray(Object *dashObj);
AnnotBorderType type; double width; static const int DASH_LIMIT = 10; // implementation note 82 in Appendix H. std::vector<double> dash; AnnotBorderStyle style;};
//------------------------------------------------------------------------// AnnotBorderArray//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotBorderArray : public AnnotBorder{public: AnnotBorderArray(); explicit AnnotBorderArray(Array *array);
void setHorizontalCorner(double hc) { horizontalCorner = hc; } void setVerticalCorner(double vc) { verticalCorner = vc; }
double getHorizontalCorner() const { return horizontalCorner; } double getVerticalCorner() const { return verticalCorner; }
std::unique_ptr<AnnotBorder> copy() const override;
private: AnnotBorderType getType() const override { return typeArray; } Object writeToObject(XRef *xref) const override;
double horizontalCorner; // (Default 0) double verticalCorner; // (Default 0) // double width; // (Default 1) (inherited from AnnotBorder)};
//------------------------------------------------------------------------// AnnotBorderBS//------------------------------------------------------------------------
class AnnotBorderBS : public AnnotBorder{public: AnnotBorderBS(); explicit AnnotBorderBS(Dict *dict);
private: AnnotBorderType getType() const override { return typeBS; } Object writeToObject(XRef *xref) const override;
const char *getStyleName() const;
std::unique_ptr<AnnotBorder> copy() const override;
// double width; // W (Default 1) (inherited from AnnotBorder) // AnnotBorderStyle style; // S (Default S) (inherited from AnnotBorder) // double *dash; // D (Default [3]) (inherited from AnnotBorder)};
//------------------------------------------------------------------------// AnnotColor//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotColor{public: enum AnnotColorSpace { colorTransparent = 0, colorGray = 1, colorRGB = 3, colorCMYK = 4 };
AnnotColor(); explicit AnnotColor(double gray); AnnotColor(double r, double g, double b); AnnotColor(double c, double m, double y, double k); explicit AnnotColor(Array *array, int adjust = 0);
void adjustColor(int adjust);
AnnotColorSpace getSpace() const { return (AnnotColorSpace)length; } const double *getValues() const { return values; }
Object writeToObject(XRef *xref) const;
private: double values[4]; int length;};
//------------------------------------------------------------------------// DefaultAppearance//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT DefaultAppearance{public: DefaultAppearance(Object &&fontNameA, double fontPtSizeA, std::unique_ptr<AnnotColor> &&fontColorA); explicit DefaultAppearance(const GooString *da); void setFontName(Object &&fontNameA); const Object &getFontName() const { return fontName; } void setFontPtSize(double fontPtSizeA); double getFontPtSize() const { return fontPtSize; } void setFontColor(std::unique_ptr<AnnotColor> fontColorA); const AnnotColor *getFontColor() const { return fontColor.get(); } std::string toAppearanceString() const;
DefaultAppearance(const DefaultAppearance &) = delete; DefaultAppearance &operator=(const DefaultAppearance &) = delete;
private: Object fontName; double fontPtSize; std::unique_ptr<AnnotColor> fontColor;};
//------------------------------------------------------------------------// AnnotIconFit//------------------------------------------------------------------------
class AnnotIconFit{public: enum AnnotIconFitScaleWhen { scaleAlways, // A scaleBigger, // B scaleSmaller, // S scaleNever // N };
enum AnnotIconFitScale { scaleAnamorphic, // A scaleProportional // P };
explicit AnnotIconFit(Dict *dict);
AnnotIconFitScaleWhen getScaleWhen() { return scaleWhen; } AnnotIconFitScale getScale() { return scale; } double getLeft() { return left; } double getBottom() { return bottom; } bool getFullyBounds() { return fullyBounds; }
protected: AnnotIconFitScaleWhen scaleWhen; // SW (Default A) AnnotIconFitScale scale; // S (Default P) double left; // A (Default [0.5 0.5] double bottom; // Only if scale is P bool fullyBounds; // FB (Default false)};
//------------------------------------------------------------------------// AnnotAppearance//------------------------------------------------------------------------
class AnnotAppearance{public: enum AnnotAppearanceType { appearNormal, appearRollover, appearDown };
AnnotAppearance(PDFDoc *docA, Object *dict); ~AnnotAppearance();
// State is ignored if no subdictionary is present Object getAppearanceStream(AnnotAppearanceType type, const char *state);
// Access keys in normal appearance subdictionary (N) std::unique_ptr<GooString> getStateKey(int i); int getNumStates();
// Removes all associated streams in the xref table. Caller is required to // reset parent annotation's AP and AS after this call. void removeAllStreams();
// Test if this AnnotAppearance references the specified stream bool referencesStream(Ref refToStream);
private: static bool referencesStream(const Object *stateObj, Ref refToStream); void removeStream(Ref refToStream); void removeStateStreams(const Object *state);
protected: PDFDoc *doc; Object appearDict; // Annotation's AP};
//------------------------------------------------------------------------// AnnotAppearanceCharacs//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotAppearanceCharacs{public: enum AnnotAppearanceCharacsTextPos { captionNoIcon, // 0 captionNoCaption, // 1 captionBelow, // 2 captionAbove, // 3 captionRight, // 4 captionLeft, // 5 captionOverlaid // 6 };
explicit AnnotAppearanceCharacs(Dict *dict); ~AnnotAppearanceCharacs();
AnnotAppearanceCharacs(const AnnotAppearanceCharacs &) = delete; AnnotAppearanceCharacs &operator=(const AnnotAppearanceCharacs &) = delete;
int getRotation() const { return rotation; } const AnnotColor *getBorderColor() const { return borderColor.get(); } void setBorderColor(std::unique_ptr<AnnotColor> &&color) { borderColor = std::move(color); } const AnnotColor *getBackColor() const { return backColor.get(); } void setBackColor(std::unique_ptr<AnnotColor> &&color) { backColor = std::move(color); } const GooString *getNormalCaption() const { return normalCaption.get(); } const GooString *getRolloverCaption() { return rolloverCaption.get(); } const GooString *getAlternateCaption() { return alternateCaption.get(); } const AnnotIconFit *getIconFit() { return iconFit.get(); } AnnotAppearanceCharacsTextPos getPosition() const { return position; }
std::unique_ptr<AnnotAppearanceCharacs> copy() const;
protected: int rotation; // R (Default 0) std::unique_ptr<AnnotColor> borderColor; // BC std::unique_ptr<AnnotColor> backColor; // BG std::unique_ptr<GooString> normalCaption; // CA std::unique_ptr<GooString> rolloverCaption; // RC std::unique_ptr<GooString> alternateCaption; // AC // I // RI // IX std::unique_ptr<AnnotIconFit> iconFit; // IF AnnotAppearanceCharacsTextPos position; // TP (Default 0)};
//------------------------------------------------------------------------// AnnotAppearanceBBox//------------------------------------------------------------------------
class AnnotAppearanceBBox{public: explicit AnnotAppearanceBBox(PDFRectangle *rect);
void setBorderWidth(double w) { borderWidth = w; }
// The following functions operate on coords relative to [origX origY] void extendTo(double x, double y); void getBBoxRect(double bbox[4]) const;
// Get boundaries in page coordinates double getPageXMin() const; double getPageYMin() const; double getPageXMax() const; double getPageYMax() const;
private: double origX, origY, borderWidth; double minX, minY, maxX, maxY;};
//------------------------------------------------------------------------// AnnotAppearanceBuilder//------------------------------------------------------------------------class Matrix;
class AnnotAppearanceBuilder{public: AnnotAppearanceBuilder(); ~AnnotAppearanceBuilder();
AnnotAppearanceBuilder(const AnnotAppearanceBuilder &) = delete; AnnotAppearanceBuilder &operator=(const AnnotAppearanceBuilder &) = delete;
void setDrawColor(const AnnotColor *color, bool fill); void setLineStyleForBorder(const AnnotBorder *border); void setTextFont(const Object &fontName, double fontSize); void drawCircle(double cx, double cy, double r, bool fill); void drawEllipse(double cx, double cy, double rx, double ry, bool fill, bool stroke); void drawCircleTopLeft(double cx, double cy, double r); void drawCircleBottomRight(double cx, double cy, double r); void drawLineEnding(AnnotLineEndingStyle endingStyle, double x, double y, double size, bool fill, const Matrix &m); void drawLineEndSquare(double x, double y, double size, bool fill, const Matrix &m); void drawLineEndCircle(double x, double y, double size, bool fill, const Matrix &m); void drawLineEndDiamond(double x, double y, double size, bool fill, const Matrix &m); void drawLineEndArrow(double x, double y, double size, int orientation, bool isOpen, bool fill, const Matrix &m); void drawLineEndSlash(double x, double y, double size, const Matrix &m); void drawFieldBorder(const FormField *field, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect); bool drawFormField(const FormField *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, const GooString *appearState, XRef *xref, Dict *resourcesDict); static double lineEndingXShorten(AnnotLineEndingStyle endingStyle, double size); static double lineEndingXExtendBBox(AnnotLineEndingStyle endingStyle, double size); void writeString(const std::string &str);
void append(const char *text); void appendf(const char *fmt, ...) GOOSTRING_FORMAT;
const GooString *buffer() const;
private: enum DrawTextFlags { NoDrawTextFlags = 0, MultilineDrawTextFlag = 1, EmitMarkedContentDrawTextFlag = 2, ForceZapfDingbatsDrawTextFlag = 4, TurnTextToStarsDrawTextFlag = 8 };
bool drawListBox(const FormFieldChoice *fieldChoice, const AnnotBorder *border, const PDFRectangle *rect, const GooString *da, const GfxResources *resources, VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict); bool drawFormFieldButton(const FormFieldButton *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, const GooString *appearState, XRef *xref, Dict *resourcesDict); bool drawFormFieldText(const FormFieldText *fieldText, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict); bool drawFormFieldChoice(const FormFieldChoice *fieldChoice, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict); bool drawSignatureFieldText(const FormFieldSignature *field, const Form *form, const GfxResources *resources, const GooString *da, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict); void drawSignatureFieldText(const GooString &text, const Form *form, const DefaultAppearance &da, const AnnotBorder *border, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict, double leftMargin, bool centerVertically, bool centerHorizontally); bool drawText(const GooString *text, const Form *form, const GooString *da, const GfxResources *resources, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags = NoDrawTextFlags, const int nCombs = 0); void drawArrowPath(double x, double y, const Matrix &m, int orientation = 1);
GooString *appearBuf;};
//------------------------------------------------------------------------// Annot//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT Annot{ friend class Annots; friend class Page;
public: enum AnnotFlag { flagUnknown = 0x0000, flagInvisible = 0x0001, flagHidden = 0x0002, flagPrint = 0x0004, flagNoZoom = 0x0008, flagNoRotate = 0x0010, flagNoView = 0x0020, flagReadOnly = 0x0040, flagLocked = 0x0080, flagToggleNoView = 0x0100, flagLockedContents = 0x0200 };
enum AnnotSubtype { typeUnknown, // 0 typeText, // Text 1 typeLink, // Link 2 typeFreeText, // FreeText 3 typeLine, // Line 4 typeSquare, // Square 5 typeCircle, // Circle 6 typePolygon, // Polygon 7 typePolyLine, // PolyLine 8 typeHighlight, // Highlight 9 typeUnderline, // Underline 10 typeSquiggly, // Squiggly 11 typeStrikeOut, // StrikeOut 12 typeStamp, // Stamp 13 typeCaret, // Caret 14 typeInk, // Ink 15 typePopup, // Popup 16 typeFileAttachment, // FileAttachment 17 typeSound, // Sound 18 typeMovie, // Movie 19 typeWidget, // Widget 20 typeScreen, // Screen 21 typePrinterMark, // PrinterMark 22 typeTrapNet, // TrapNet 23 typeWatermark, // Watermark 24 type3D, // 3D 25 typeRichMedia // RichMedia 26 };
/** * Describes the additional actions of a screen or widget annotation. */ enum AdditionalActionsType { actionCursorEntering, ///< Performed when the cursor enters the annotation's active area actionCursorLeaving, ///< Performed when the cursor exists the annotation's active area actionMousePressed, ///< Performed when the mouse button is pressed inside the annotation's active area actionMouseReleased, ///< Performed when the mouse button is released inside the annotation's active area actionFocusIn, ///< Performed when the annotation receives the input focus actionFocusOut, ///< Performed when the annotation loses the input focus actionPageOpening, ///< Performed when the page containing the annotation is opened actionPageClosing, ///< Performed when the page containing the annotation is closed actionPageVisible, ///< Performed when the page containing the annotation becomes visible actionPageInvisible ///< Performed when the page containing the annotation becomes invisible };
enum FormAdditionalActionsType { actionFieldModified, ///< Performed when the when the user modifies the field actionFormatField, ///< Performed before the field is formatted to display its value actionValidateField, ///< Performed when the field value changes actionCalculateField, ///< Performed when the field needs to be recalculated };
Annot(PDFDoc *docA, PDFRectangle *rectA); Annot(PDFDoc *docA, Object &&dictObject); Annot(PDFDoc *docA, Object &&dictObject, const Object *obj); bool isOk() { return ok; }
void incRefCnt(); void decRefCnt();
virtual void draw(Gfx *gfx, bool printing); // Get the resource dict of the appearance stream virtual Object getAppearanceResDict();
bool match(const Ref *refA) const { return ref == *refA; }
double getXMin(); double getYMin(); double getXMax(); double getYMax();
void setRect(const PDFRectangle *rect); void setRect(double x1, double y1, double x2, double y2);
// Sets the annot contents to new_content // new_content should never be NULL virtual void setContents(std::unique_ptr<GooString> &&new_content); void setName(GooString *new_name); void setModified(GooString *new_modified); void setFlags(unsigned int new_flags);
void setBorder(std::unique_ptr<AnnotBorder> &&new_border); void setColor(std::unique_ptr<AnnotColor> &&new_color);
void setAppearanceState(const char *state);
// getters PDFDoc *getDoc() const { return doc; } bool getHasRef() const { return hasRef; } Ref getRef() const { return ref; } const Object &getAnnotObj() const { return annotObj; } AnnotSubtype getType() const { return type; } const PDFRectangle &getRect() const { return *rect; } void getRect(double *x1, double *y1, double *x2, double *y2) const; const GooString *getContents() const { return contents.get(); } int getPageNum() const { return page; } const GooString *getName() const { return name.get(); } const GooString *getModified() const { return modified.get(); } unsigned int getFlags() const { return flags; } Object getAppearance() const; void setNewAppearance(Object &&newAppearance); AnnotAppearance *getAppearStreams() const { return appearStreams.get(); } const GooString *getAppearState() const { return appearState.get(); } AnnotBorder *getBorder() const { return border.get(); } AnnotColor *getColor() const { return color.get(); } int getTreeKey() const { return treeKey; }
int getId() { return ref.num; }
// Check if point is inside the annot rectangle. bool inRect(double x, double y) const;
// If newFontNeeded is not null, it will contain whether the given font has glyphs to represent the needed text static void layoutText(const GooString *text, GooString *outBuf, int *i, const GfxFont &font, double *width, double widthLimit, int *charCount, bool noReencode, bool *newFontNeeded = nullptr);
private: void readArrayNum(Object *pdfArray, int key, double *value); // write vStr[i:j[ in appearBuf
void initialize(PDFDoc *docA, Dict *dict); void setPage(int pageIndex, bool updateP); // Called by Page::addAnnot and Annots ctor
protected: virtual ~Annot(); virtual void removeReferencedObjects(); // Called by Page::removeAnnot Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Dict *resDict); Object createForm(const GooString *appearBuf, const double *bbox, bool transparencyGroup, Object &&resDictObject); // overload to support incRef/decRef Dict *createResourcesDict(const char *formName, Object &&formStream, const char *stateName, double opacity, const char *blendMode); bool isVisible(bool printing); int getRotation() const;
// Updates the field key of the annotation dictionary // and sets M to the current time void update(const char *key, Object &&value);
// Delete appearance streams and reset appearance state virtual void invalidateAppearance();
Object annotObj;
std::atomic_int refCnt;
// required data AnnotSubtype type; // Annotation type std::unique_ptr<PDFRectangle> rect; // Rect
// optional data std::unique_ptr<GooString> contents; // Contents std::unique_ptr<GooString> name; // NM std::unique_ptr<GooString> modified; // M int page; // P unsigned int flags; // F (must be a 32 bit unsigned int) std::unique_ptr<AnnotAppearance> appearStreams; // AP Object appearance; // a reference to the Form XObject stream // for the normal appearance std::unique_ptr<AnnotAppearanceBBox> appearBBox; // BBox of generated appearance std::unique_ptr<GooString> appearState; // AS int treeKey; // Struct Parent; Object oc; // OC
PDFDoc *doc; Ref ref; // object ref identifying this annotation std::unique_ptr<AnnotBorder> border; // Border, BS std::unique_ptr<AnnotColor> color; // C bool ok;
bool hasRef; mutable std::recursive_mutex mutex;
bool hasBeenUpdated = false;};
//------------------------------------------------------------------------// AnnotPopup//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotPopup : public Annot{public: AnnotPopup(PDFDoc *docA, PDFRectangle *rect); AnnotPopup(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotPopup() override;
bool hasParent() const { return parentRef != Ref::INVALID(); } void setParent(Annot *parentA); bool getOpen() const { return open; } void setOpen(bool openA);
protected: void initialize(PDFDoc *docA, Dict *dict);
Ref parentRef; // Parent bool open; // Open};
//------------------------------------------------------------------------// AnnotMarkup//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotMarkup : public Annot{public: enum AnnotMarkupReplyType { replyTypeR, // R replyTypeGroup // Group };
AnnotMarkup(PDFDoc *docA, PDFRectangle *rect); AnnotMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotMarkup() override;
// getters const GooString *getLabel() const { return label.get(); } AnnotPopup *getPopup() const { return popup.get(); } double getOpacity() const { return opacity; } // getRC const GooString *getDate() const { return date.get(); } bool isInReplyTo() const { return inReplyTo != Ref::INVALID(); } int getInReplyToID() const { return inReplyTo.num; } const GooString *getSubject() const { return subject.get(); } AnnotMarkupReplyType getReplyTo() const { return replyTo; } AnnotExternalDataType getExData() const { return exData; }
// The annotation takes the ownership of new_popup void setPopup(std::unique_ptr<AnnotPopup> &&new_popup); void setLabel(std::unique_ptr<GooString> &&new_label); void setOpacity(double opacityA); void setDate(GooString *new_date);
protected: void removeReferencedObjects() override;
std::unique_ptr<GooString> label; // T (Default author) std::unique_ptr<AnnotPopup> popup; // Popup double opacity; // CA (Default 1.0) // RC std::unique_ptr<GooString> date; // CreationDate Ref inReplyTo; // IRT std::unique_ptr<GooString> subject; // Subj AnnotMarkupReplyType replyTo; // RT (Default R) // this object is overridden by the custom intent fields defined in some // annotation types. // GooString *intent; // IT AnnotExternalDataType exData; // ExData
private: void initialize(PDFDoc *docA, Dict *dict);};
//------------------------------------------------------------------------// AnnotText//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotText : public AnnotMarkup{public: enum AnnotTextState { stateUnknown, // Marked state model stateMarked, // Marked stateUnmarked, // Unmarked // Review state model stateAccepted, // Accepted stateRejected, // Rejected stateCancelled, // Cancelled stateCompleted, // Completed stateNone // None };
AnnotText(PDFDoc *docA, PDFRectangle *rect); AnnotText(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotText() override;
void draw(Gfx *gfx, bool printing) override;
// getters bool getOpen() const { return open; } const GooString *getIcon() const { return icon.get(); } AnnotTextState getState() const { return state; }
void setOpen(bool openA); void setIcon(GooString *new_icon);
private: void initialize(PDFDoc *docA, Dict *dict);
bool open; // Open (Default false) std::unique_ptr<GooString> icon; // Name (Default Note) AnnotTextState state; // State (Default Umarked if // StateModel Marked // None if StareModel Review)};
//------------------------------------------------------------------------// AnnotMovie//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotMovie : public Annot{public: AnnotMovie(PDFDoc *docA, PDFRectangle *rect, Movie *movieA); AnnotMovie(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotMovie() override;
void draw(Gfx *gfx, bool printing) override;
const GooString *getTitle() const { return title.get(); } Movie *getMovie() { return movie.get(); }
private: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<GooString> title; // T std::unique_ptr<Movie> movie; // Movie + A};
//------------------------------------------------------------------------// AnnotScreen//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotScreen : public Annot{public: AnnotScreen(PDFDoc *docA, PDFRectangle *rect); AnnotScreen(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotScreen() override;
const GooString *getTitle() const { return title.get(); }
AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); } LinkAction *getAction() { return action.get(); } // The caller should not delete the result std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type);
private: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<GooString> title; // T
std::unique_ptr<AnnotAppearanceCharacs> appearCharacs; // MK
std::unique_ptr<LinkAction> action; // A Object additionalActions; // AA};
//------------------------------------------------------------------------// AnnotLink//------------------------------------------------------------------------
class AnnotLink : public Annot{public: enum AnnotLinkEffect { effectNone, // N effectInvert, // I effectOutline, // O effectPush // P };
AnnotLink(PDFDoc *docA, PDFRectangle *rect); AnnotLink(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotLink() override;
void draw(Gfx *gfx, bool printing) override;
// getters LinkAction *getAction() const { return action.get(); } AnnotLinkEffect getLinkEffect() const { return linkEffect; } AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
protected: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<LinkAction> action; // A, Dest AnnotLinkEffect linkEffect; // H (Default I) // Dict *uriAction; // PA
std::unique_ptr<AnnotQuadrilaterals> quadrilaterals; // QuadPoints};
//------------------------------------------------------------------------// AnnotFreeText//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotFreeText : public AnnotMarkup{public: enum AnnotFreeTextIntent { intentFreeText, // FreeText intentFreeTextCallout, // FreeTextCallout intentFreeTextTypeWriter // FreeTextTypeWriter };
static const double undefinedFontPtSize;
AnnotFreeText(PDFDoc *docA, PDFRectangle *rect); AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotFreeText() override;
void draw(Gfx *gfx, bool printing) override; Object getAppearanceResDict() override; void setContents(std::unique_ptr<GooString> &&new_content) override;
void setDefaultAppearance(const DefaultAppearance &da); void setQuadding(VariableTextQuadding new_quadding); void setStyleString(GooString *new_string); void setCalloutLine(AnnotCalloutLine *line); void setIntent(AnnotFreeTextIntent new_intent);
// getters std::unique_ptr<DefaultAppearance> getDefaultAppearance() const; VariableTextQuadding getQuadding() const { return quadding; } // return rc const GooString *getStyleString() const { return styleString.get(); } AnnotCalloutLine *getCalloutLine() const { return calloutLine.get(); } AnnotFreeTextIntent getIntent() const { return intent; } AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); } PDFRectangle *getRectangle() const { return rectangle.get(); } AnnotLineEndingStyle getEndStyle() const { return endStyle; }
protected: void initialize(PDFDoc *docA, Dict *dict); void generateFreeTextAppearance();
// required std::unique_ptr<GooString> appearanceString; // DA
// optional VariableTextQuadding quadding; // Q (Default 0) // RC std::unique_ptr<GooString> styleString; // DS std::unique_ptr<AnnotCalloutLine> calloutLine; // CL AnnotFreeTextIntent intent; // IT std::unique_ptr<AnnotBorderEffect> borderEffect; // BE std::unique_ptr<PDFRectangle> rectangle; // RD // inherited from Annot // AnnotBorderBS border; // BS AnnotLineEndingStyle endStyle; // LE (Default None)};
//------------------------------------------------------------------------// AnnotLine//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotLine : public AnnotMarkup{public: enum AnnotLineIntent { intentLineArrow, // LineArrow intentLineDimension // LineDimension };
enum AnnotLineCaptionPos { captionPosInline, // Inline captionPosTop // Top };
AnnotLine(PDFDoc *docA, PDFRectangle *rect); AnnotLine(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotLine() override;
void draw(Gfx *gfx, bool printing) override; Object getAppearanceResDict() override; void setContents(std::unique_ptr<GooString> &&new_content) override;
void setVertices(double x1, double y1, double x2, double y2); void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color); void setLeaderLineLength(double len); void setLeaderLineExtension(double len); void setCaption(bool new_cap); void setIntent(AnnotLineIntent new_intent);
// getters AnnotLineEndingStyle getStartStyle() const { return startStyle; } AnnotLineEndingStyle getEndStyle() const { return endStyle; } AnnotColor *getInteriorColor() const { return interiorColor.get(); } double getLeaderLineLength() const { return leaderLineLength; } double getLeaderLineExtension() const { return leaderLineExtension; } bool getCaption() const { return caption; } AnnotLineIntent getIntent() const { return intent; } double getLeaderLineOffset() const { return leaderLineOffset; } AnnotLineCaptionPos getCaptionPos() const { return captionPos; } Dict *getMeasure() const { return measure; } double getCaptionTextHorizontal() const { return captionTextHorizontal; } double getCaptionTextVertical() const { return captionTextVertical; } double getX1() const { return coord1->getX(); } double getY1() const { return coord1->getY(); } double getX2() const { return coord2->getX(); } double getY2() const { return coord2->getY(); }
protected: void initialize(PDFDoc *docA, Dict *dict); void generateLineAppearance();
// required std::unique_ptr<AnnotCoord> coord1; std::unique_ptr<AnnotCoord> coord2;
// optional // inherited from Annot // AnnotBorderBS border; // BS AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) AnnotLineEndingStyle endStyle; // std::unique_ptr<AnnotColor> interiorColor; // IC double leaderLineLength; // LL (Default 0) double leaderLineExtension; // LLE (Default 0) bool caption; // Cap (Default false) AnnotLineIntent intent; // IT double leaderLineOffset; // LLO AnnotLineCaptionPos captionPos; // CP (Default Inline) Dict *measure; // Measure double captionTextHorizontal; // CO (Default [0, 0]) double captionTextVertical; //};
//------------------------------------------------------------------------// AnnotTextMarkup//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotTextMarkup : public AnnotMarkup{public: AnnotTextMarkup(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); AnnotTextMarkup(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotTextMarkup() override;
void draw(Gfx *gfx, bool printing) override;
// typeHighlight, typeUnderline, typeSquiggly or typeStrikeOut void setType(AnnotSubtype new_type);
void setQuadrilaterals(AnnotQuadrilaterals *quadPoints);
AnnotQuadrilaterals *getQuadrilaterals() const { return quadrilaterals.get(); }
protected: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<AnnotQuadrilaterals> quadrilaterals; // QuadPoints
private: bool shouldCreateApperance(Gfx *gfx) const;};
//------------------------------------------------------------------------// AnnotStamp//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotStamp : public AnnotMarkup{public: AnnotStamp(PDFDoc *docA, PDFRectangle *rect); AnnotStamp(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotStamp() override;
void draw(Gfx *gfx, bool printing) override;
void setIcon(GooString *new_icon);
void setCustomImage(AnnotStampImageHelper *stampImageHelperA);
void clearCustomImage();
// getters const GooString *getIcon() const { return icon.get(); }
private: void initialize(PDFDoc *docA, Dict *dict); void generateStampDefaultAppearance(); void generateStampCustomAppearance();
std::unique_ptr<GooString> icon; // Name (Default Draft) AnnotStampImageHelper *stampImageHelper; Ref updatedAppearanceStream;};
//------------------------------------------------------------------------// AnnotGeometry//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotGeometry : public AnnotMarkup{public: AnnotGeometry(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); AnnotGeometry(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotGeometry() override;
void draw(Gfx *gfx, bool printing) override;
void setType(AnnotSubtype new_type); // typeSquare or typeCircle void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color);
// getters AnnotColor *getInteriorColor() const { return interiorColor.get(); } AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); } PDFRectangle *getGeometryRect() const { return geometryRect.get(); }
private: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<AnnotColor> interiorColor; // IC std::unique_ptr<AnnotBorderEffect> borderEffect; // BE std::unique_ptr<PDFRectangle> geometryRect; // RD (combined with Rect)};
//------------------------------------------------------------------------// AnnotPolygon//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotPolygon : public AnnotMarkup{public: enum AnnotPolygonIntent { polygonCloud, // PolygonCloud polylineDimension, // PolyLineDimension polygonDimension // PolygonDimension };
AnnotPolygon(PDFDoc *docA, PDFRectangle *rect, AnnotSubtype subType); AnnotPolygon(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotPolygon() override;
void draw(Gfx *gfx, bool printing) override; void generatePolyLineAppearance(AnnotAppearanceBuilder *appearBuilder); void setType(AnnotSubtype new_type); // typePolygon or typePolyLine void setVertices(AnnotPath *path); void setStartEndStyle(AnnotLineEndingStyle start, AnnotLineEndingStyle end); void setInteriorColor(std::unique_ptr<AnnotColor> &&new_color); void setIntent(AnnotPolygonIntent new_intent);
// getters AnnotPath *getVertices() const { return vertices.get(); } AnnotLineEndingStyle getStartStyle() const { return startStyle; } AnnotLineEndingStyle getEndStyle() const { return endStyle; } AnnotColor *getInteriorColor() const { return interiorColor.get(); } AnnotBorderEffect *getBorderEffect() const { return borderEffect.get(); } AnnotPolygonIntent getIntent() const { return intent; }
private: void initialize(PDFDoc *docA, Dict *dict);
// required std::unique_ptr<AnnotPath> vertices; // Vertices
// optional AnnotLineEndingStyle startStyle; // LE (Default [/None /None]) AnnotLineEndingStyle endStyle; // // inherited from Annot // AnnotBorderBS border; // BS std::unique_ptr<AnnotColor> interiorColor; // IC std::unique_ptr<AnnotBorderEffect> borderEffect; // BE AnnotPolygonIntent intent; // IT // Measure};
//------------------------------------------------------------------------// AnnotCaret//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotCaret : public AnnotMarkup{public: enum AnnotCaretSymbol { symbolNone, // None symbolP // P };
AnnotCaret(PDFDoc *docA, PDFRectangle *rect); AnnotCaret(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotCaret() override;
void setSymbol(AnnotCaretSymbol new_symbol);
// getters AnnotCaretSymbol getSymbol() const { return symbol; } PDFRectangle *getCaretRect() const { return caretRect.get(); }
private: void initialize(PDFDoc *docA, Dict *dict);
AnnotCaretSymbol symbol; // Sy (Default None) std::unique_ptr<PDFRectangle> caretRect; // RD (combined with Rect)};
//------------------------------------------------------------------------// AnnotInk//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotInk : public AnnotMarkup{public: AnnotInk(PDFDoc *docA, PDFRectangle *rect); AnnotInk(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotInk() override;
void draw(Gfx *gfx, bool printing) override;
void setInkList(AnnotPath **paths, int n_paths);
// getters AnnotPath **getInkList() const { return inkList; } int getInkListLength() const { return inkListLength; }
private: void initialize(PDFDoc *docA, Dict *dict); void writeInkList(AnnotPath **paths, int n_paths, Array *dest_array); void parseInkList(Array *src_array); void freeInkList();
// required AnnotPath **inkList; // InkList int inkListLength;
// optional // inherited from Annot // AnnotBorderBS border; // BS};
//------------------------------------------------------------------------// AnnotFileAttachment//------------------------------------------------------------------------
class AnnotFileAttachment : public AnnotMarkup{public: AnnotFileAttachment(PDFDoc *docA, PDFRectangle *rect, GooString *filename); AnnotFileAttachment(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotFileAttachment() override;
void draw(Gfx *gfx, bool printing) override;
// getters Object *getFile() { return &file; } const GooString *getName() const { return name.get(); }
private: void initialize(PDFDoc *docA, Dict *dict);
// required Object file; // FS
// optional std::unique_ptr<GooString> name; // Name};
//------------------------------------------------------------------------// AnnotSound//------------------------------------------------------------------------
class AnnotSound : public AnnotMarkup{public: AnnotSound(PDFDoc *docA, PDFRectangle *rect, Sound *soundA); AnnotSound(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotSound() override;
void draw(Gfx *gfx, bool printing) override;
// getters Sound *getSound() { return sound.get(); } const GooString *getName() const { return name.get(); }
private: void initialize(PDFDoc *docA, Dict *dict);
// required std::unique_ptr<Sound> sound; // Sound
// optional std::unique_ptr<GooString> name; // Name};
//------------------------------------------------------------------------// AnnotWidget//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotWidget : public Annot{public: enum AnnotWidgetHighlightMode { highlightModeNone, // N highlightModeInvert, // I highlightModeOutline, // O highlightModePush // P,T };
AnnotWidget(PDFDoc *docA, Object &&dictObject, const Object *obj); AnnotWidget(PDFDoc *docA, Object *dictObject, Object *obj, FormField *fieldA); ~AnnotWidget() override;
void draw(Gfx *gfx, bool printing) override; void invalidateAppearance() override;
void generateFieldAppearance(); void updateAppearanceStream();
AnnotWidgetHighlightMode getMode() { return mode; } AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs.get(); } void setAppearCharacs(std::unique_ptr<AnnotAppearanceCharacs> &&appearCharacsA) { appearCharacs = std::move(appearCharacsA); } LinkAction *getAction() { return action.get(); } // The caller should not delete the result std::unique_ptr<LinkAction> getAdditionalAction(AdditionalActionsType type); std::unique_ptr<LinkAction> getFormAdditionalAction(FormAdditionalActionsType type); Dict *getParent() { return parent; }
bool setFormAdditionalAction(FormAdditionalActionsType type, const std::string &js);
void setField(FormField *f) { field = f; };
private: void initialize(PDFDoc *docA, Dict *dict);
Form *form; FormField *field; // FormField object for this annotation AnnotWidgetHighlightMode mode; // H (Default I) std::unique_ptr<AnnotAppearanceCharacs> appearCharacs; // MK std::unique_ptr<LinkAction> action; // A Object additionalActions; // AA // inherited from Annot // AnnotBorderBS border; // BS Dict *parent; // Parent Ref updatedAppearanceStream; // {-1,-1} if updateAppearanceStream has never been called};
//------------------------------------------------------------------------// Annot3D//------------------------------------------------------------------------
class Annot3D : public Annot{ class Activation { public: enum ActivationATrigger { aTriggerUnknown, aTriggerPageOpened, // PO aTriggerPageVisible, // PV aTriggerUserAction // XA };
enum ActivationAState { aStateUnknown, aStateEnabled, // I aStateDisabled // L };
enum ActivationDTrigger { dTriggerUnknown, dTriggerPageClosed, // PC dTriggerPageInvisible, // PI dTriggerUserAction // XD };
enum ActivationDState { dStateUnknown, dStateUninstantiaded, // U dStateInstantiated, // I dStateLive // L };
explicit Activation(Dict *dict);
private: ActivationATrigger aTrigger; // A (Default XA) ActivationAState aState; // AIS (Default L) ActivationDTrigger dTrigger; // D (Default PI) ActivationDState dState; // DIS (Default U) bool displayToolbar; // TB (Default true) bool displayNavigation; // NP (Default false); };
public: Annot3D(PDFDoc *docA, PDFRectangle *rect); Annot3D(PDFDoc *docA, Object &&dictObject, const Object *obj); ~Annot3D() override;
// getters
private: void initialize(PDFDoc *docA, Dict *dict);
std::unique_ptr<Activation> activation; // 3DA};
//------------------------------------------------------------------------// AnnotRichMedia//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT AnnotRichMedia : public Annot{public: class POPPLER_PRIVATE_EXPORT Params { public: explicit Params(Dict *dict); ~Params();
Params(const Params &) = delete; Params &operator=(const Params &) = delete;
const GooString *getFlashVars() const;
private: // optional std::unique_ptr<GooString> flashVars; // FlashVars };
class POPPLER_PRIVATE_EXPORT Instance { public: enum Type { type3D, // 3D typeFlash, // Flash typeSound, // Sound typeVideo // Video };
explicit Instance(Dict *dict); ~Instance();
Instance(const Instance &) = delete; Instance &operator=(const Instance &) = delete;
Type getType() const; Params *getParams() const;
private: // optional Type type; // Subtype std::unique_ptr<Params> params; // Params };
class POPPLER_PRIVATE_EXPORT Configuration { public: enum Type { type3D, // 3D typeFlash, // Flash typeSound, // Sound typeVideo // Video };
explicit Configuration(Dict *dict); ~Configuration();
Configuration(const Configuration &) = delete; Configuration &operator=(const Configuration &) = delete;
Type getType() const; const GooString *getName() const; int getInstancesCount() const; Instance *getInstance(int index) const;
private: // optional Type type; // Subtype std::unique_ptr<GooString> name; // Name Instance **instances; // Instances int nInstances; };
class Content;
class POPPLER_PRIVATE_EXPORT Asset { public: Asset(); ~Asset();
Asset(const Asset &) = delete; Asset &operator=(const Asset &) = delete;
const GooString *getName() const; Object *getFileSpec() const;
private: friend class AnnotRichMedia::Content;
std::unique_ptr<GooString> name; Object fileSpec; };
class POPPLER_PRIVATE_EXPORT Content { public: explicit Content(Dict *dict); ~Content();
Content(const Content &) = delete; Content &operator=(const Content &) = delete;
int getConfigurationsCount() const; Configuration *getConfiguration(int index) const;
int getAssetsCount() const; Asset *getAsset(int index) const;
private: // optional Configuration **configurations; // Configurations int nConfigurations;
Asset **assets; // Assets int nAssets; };
class POPPLER_PRIVATE_EXPORT Activation { public: enum Condition { conditionPageOpened, // PO conditionPageVisible, // PV conditionUserAction // XA };
explicit Activation(Dict *dict);
Condition getCondition() const;
private: // optional Condition condition; };
class POPPLER_PRIVATE_EXPORT Deactivation { public: enum Condition { conditionPageClosed, // PC conditionPageInvisible, // PI conditionUserAction // XD };
explicit Deactivation(Dict *dict);
Condition getCondition() const;
private: // optional Condition condition; };
class POPPLER_PRIVATE_EXPORT Settings { public: explicit Settings(Dict *dict); ~Settings();
Settings(const Settings &) = delete; Settings &operator=(const Settings &) = delete;
Activation *getActivation() const; Deactivation *getDeactivation() const;
private: // optional std::unique_ptr<Activation> activation; std::unique_ptr<Deactivation> deactivation; };
AnnotRichMedia(PDFDoc *docA, PDFRectangle *rect); AnnotRichMedia(PDFDoc *docA, Object &&dictObject, const Object *obj); ~AnnotRichMedia() override;
Content *getContent() const;
Settings *getSettings() const;
private: void initialize(PDFDoc *docA, Dict *dict);
// required std::unique_ptr<Content> content; // RichMediaContent
// optional std::unique_ptr<Settings> settings; // RichMediaSettings};
//------------------------------------------------------------------------// Annots//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT Annots{public: // Build a list of Annot objects and call setPage on them Annots(PDFDoc *docA, int page, Object *annotsObj);
~Annots();
Annots(const Annots &) = delete; Annots &operator=(const Annots &) = delete;
const std::vector<Annot *> &getAnnots() { return annots; }
void appendAnnot(Annot *annot); bool removeAnnot(Annot *annot);
private: Annot *createAnnot(Object &&dictObject, const Object *obj); Annot *findAnnot(Ref *ref);
PDFDoc *doc; std::vector<Annot *> annots;};
#endif1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768//========================================================================//// AnnotStampImageHelper.h//// Copyright (C) 2021 Mahmoud Ahmed Khalil <mahmoudkhalil11@gmail.com>// Copyright (C) 2021 Albert Astals Cid <aacid@kde.org>//// Licensed under GPLv2 or later////========================================================================
#ifndef ANNOTSTAMPIMAGEHELPER_H#define ANNOTSTAMPIMAGEHELPER_H
#include "Object.h"
class PDFDoc;
enum ColorSpace{ DeviceGray, DeviceRGB, DeviceCMYK};
/** * This class is used only to load Image XObjects into stamp annotations. It takes in * the image parameters in its constructors and creates a new Image XObject that gets * added to the XRef table, so that the annotations that would like to use it be able * to get its ref number. * * To have transparency in the image, you should first try to create the soft * mask of the image, by creating a AnnotStampImageHelper object giving it the soft * image data normally. You would then need to pass in the created soft mask Image XObject * ref to the actual image you'd like to be created by this helper class. */class POPPLER_PRIVATE_EXPORT AnnotStampImageHelper{public: AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength); AnnotStampImageHelper(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength, Ref softMaskRef); ~AnnotStampImageHelper() { }
// Returns the ref to the created Image XObject Ref getRef() const { return ref; }
// Returns the width of the image int getWidth() const { return width; } // Returns the height of the image int getHeight() const { return height; }
// Removes the created Image XObject as well as its soft mask from the XRef Table void removeAnnotStampImageObject();
private: void initialize(PDFDoc *docA, int widthA, int heightA, ColorSpace colorSpace, int bitsPerComponent, char *data, int dataLength);
PDFDoc *doc;
Object imgObj; Ref ref; Ref sMaskRef;
int width; int height;};
#endif1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192//========================================================================//// Array.h//// Copyright 1996-2003 Glyph & Cog, LLC////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>// Copyright (C) 2017-2019, 2021 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2018, 2019 Adam Reichold <adam.reichold@t-online.de>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef ARRAY_H#define ARRAY_H
#include <atomic>#include <mutex>#include <vector>
#include "poppler-config.h"#include "poppler_private_export.h"#include "Object.h"
class XRef;
//------------------------------------------------------------------------// Array//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT Array{public: // Constructor. explicit Array(XRef *xrefA);
// Destructor. ~Array();
Array(const Array &) = delete; Array &operator=(const Array &) = delete;
// Get number of elements. int getLength() const { return elems.size(); }
// Copy array with new xref Array *copy(XRef *xrefA) const;
Array *deepCopy() const;
// Add an element // elem becomes a dead object after this call void add(Object &&elem);
// Remove an element by position void remove(int i);
// Accessors. Object get(int i, int recursion = 0) const; // Same as above but if the returned object is a fetched Ref returns such Ref in returnRef, otherwise returnRef is Ref::INVALID() Object get(int i, Ref *returnRef, int recursion = 0) const; const Object &getNF(int i) const; bool getString(int i, GooString *string) const;
private: friend class Object; // for incRef/decRef
// Reference counting. int incRef() { return ++ref; } int decRef() { return --ref; }
XRef *xref; // the xref table for this PDF file std::vector<Object> elems; // array of elements std::atomic_int ref; // reference count mutable std::recursive_mutex mutex;};
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354//========================================================================//// BBoxOutputDev.cc//// This file is licensed under the GPLv2 or later//// Copyright 2020 sgerwk <sgerwk@aol.com>////========================================================================
#include <PDFDoc.h>#include <GfxState.h>#include <OutputDev.h>
class POPPLER_PRIVATE_EXPORT BBoxOutputDev : public OutputDev{public: bool upsideDown() override { return false; } bool useDrawChar() override { return true; } bool interpretType3Chars() override { return false; }
BBoxOutputDev(); BBoxOutputDev(bool text, bool vector, bool raster); BBoxOutputDev(bool text, bool vector, bool raster, bool lwidth); void endPage() override; void stroke(GfxState *state) override; void fill(GfxState *state) override; void eoFill(GfxState *state) override; void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) override; void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override; void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, bool maskInterpolate) override;
double getX1() const; double getY1() const; double getX2() const; double getY2() const; double getHasGraphics() const;
private: PDFRectangle bb; bool hasGraphics;
bool text; bool vector; bool raster; bool lwidth;
void updatePoint(PDFRectangle *bbA, double x, double y, const GfxState *state); void updatePath(PDFRectangle *bbA, const GfxPath *path, const GfxState *state); void updateImage(PDFRectangle *bbA, const GfxState *state);};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128//========================================================================//// CMap.h//// Copyright 2001-2003 Glyph & Cog, LLC////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2008 Koji Otani <sho@bbr.jp>// Copyright (C) 2009, 2018-2020, 2022 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2012, 2017 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef CMAP_H#define CMAP_H
#include <array>#include <atomic>#include <memory>
#include "poppler-config.h"#include "CharTypes.h"
class GooString;class Object;struct CMapVectorEntry;class CMapCache;class Stream;
//------------------------------------------------------------------------
class CMap{public: // Parse a CMap from <obj>, which can be a name or a stream. Sets // the initial reference count to 1. Returns NULL on failure. static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Object *obj);
// Create the CMap specified by <collection> and <cMapName>. Sets // the initial reference count to 1. Returns NULL on failure. static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, const GooString *cMapNameA);
// Parse a CMap from <str>. Sets the initial reference count to 1. // Returns NULL on failure. static std::shared_ptr<CMap> parse(CMapCache *cache, const GooString *collectionA, Stream *str);
~CMap();
CMap(const CMap &) = delete; CMap &operator=(const CMap &) = delete;
// Return collection name (<registry>-<ordering>). const GooString *getCollection() const { return collection; }
const GooString *getCMapName() const { return cMapName; }
// Return true if this CMap matches the specified <collectionA>, and // <cMapNameA>. bool match(const GooString *collectionA, const GooString *cMapNameA);
// Return the CID corresponding to the character code starting at // <s>, which contains <len> bytes. Sets *<c> to the char code, and // *<nUsed> to the number of bytes used by the char code. CID getCID(const char *s, int len, CharCode *c, int *nUsed);
// Return the writing mode (0=horizontal, 1=vertical). int getWMode() const { return wMode; }
void setReverseMap(unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
private: void parse2(CMapCache *cache, int (*getCharFunc)(void *), void *data); CMap(GooString *collectionA, GooString *cMapNameA); CMap(GooString *collectionA, GooString *cMapNameA, int wModeA); void useCMap(CMapCache *cache, const char *useName); void useCMap(CMapCache *cache, Object *obj); void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src); void addCIDs(unsigned int start, unsigned int end, unsigned int nBytes, CID firstCID); void freeCMapVector(CMapVectorEntry *vec); void setReverseMapVector(unsigned int startCode, CMapVectorEntry *vec, unsigned int *rmap, unsigned int rmapSize, unsigned int ncand);
GooString *collection; GooString *cMapName; bool isIdent; // true if this CMap is an identity mapping, // or is based on one (via usecmap) int wMode; // writing mode (0=horizontal, 1=vertical) CMapVectorEntry *vector; // vector for first byte (NULL for // identity CMap)};
//------------------------------------------------------------------------
#define cMapCacheSize 4
class CMapCache{public: CMapCache(); ~CMapCache() = default;
CMapCache(const CMapCache &) = delete; CMapCache &operator=(const CMapCache &) = delete;
// Get the <cMapName> CMap for the specified character collection. // Increments its reference count; there will be one reference for // the cache plus one for the caller of this function. // Stream is a stream containing the CMap, can be NULL and // this means the CMap will be searched in the CMap files // Returns NULL on failure. std::shared_ptr<CMap> getCMap(const GooString *collection, const GooString *cMapName);
private: std::array<std::shared_ptr<CMap>, cMapCacheSize> cache;};
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149//========================================================================//// CachedFile.h//// Caching files support.//// This file is licensed under the GPLv2 or later//// Copyright 2009 Stefan Thomas <thomas@eload24.com>// Copyright 2010 Hib Eris <hib@hiberis.nl>// Copyright 2010, 2018-2020, 2022 Albert Astals Cid <aacid@kde.org>////========================================================================
#ifndef CACHEDFILE_H#define CACHEDFILE_H
#include "poppler-config.h"#include "poppler_private_export.h"
#include "Object.h"#include "Stream.h"
#include <vector>
//------------------------------------------------------------------------
#define CachedFileChunkSize 8192 // This should be a multiple of cachedStreamBufSize
class GooString;class CachedFileLoader;
//------------------------------------------------------------------------// CachedFile//// CachedFile gives FILE-like access to a document at a specified URI.// In the constructor, you specify a CachedFileLoader that handles loading// the data from the document. The CachedFile requests no more data then it// needs from the CachedFileLoader.//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT CachedFile{
friend class CachedFileWriter;
public: explicit CachedFile(CachedFileLoader *cacheLoader);
CachedFile(const CachedFile &) = delete; CachedFile &operator=(const CachedFile &) = delete;
unsigned int getLength() const { return length; } long int tell(); int seek(long int offset, int origin); size_t read(void *ptr, size_t unitsize, size_t count); size_t write(const char *ptr, size_t size, size_t fromByte); int cache(const std::vector<ByteRange> &ranges);
// Reference counting. void incRefCnt(); void decRefCnt();
private: ~CachedFile();
enum ChunkState { chunkStateNew = 0, chunkStateLoaded };
typedef struct { ChunkState state; char data[CachedFileChunkSize]; } Chunk;
int cache(size_t offset, size_t length);
CachedFileLoader *loader;
size_t length; size_t streamPos;
std::vector<Chunk> *chunks;
int refCnt; // reference count};
//------------------------------------------------------------------------// CachedFileWriter//// CachedFileWriter handles sequential writes to a CachedFile.// On construction, you specify the CachedFile and the chunks of it to which data// should be written.//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT CachedFileWriter{
public: // Construct a CachedFile Writer. // The caller is responsible for deleting the cachedFile and chunksA. CachedFileWriter(CachedFile *cachedFile, std::vector<int> *chunksA);
~CachedFileWriter();
// Writes size bytes from ptr to cachedFile, returns number of bytes written. size_t write(const char *ptr, size_t size);
private: CachedFile *cachedFile; std::vector<int> *chunks; std::vector<int>::iterator it; size_t offset;};
//------------------------------------------------------------------------// CachedFileLoader//// CachedFileLoader is an abstact class that specifies the interface for// loadng data from an URI into a CachedFile.//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT CachedFileLoader{
public: CachedFileLoader() = default; virtual ~CachedFileLoader();
CachedFileLoader(const CachedFileLoader &) = delete; CachedFileLoader &operator=(const CachedFileLoader &) = delete;
// Initializes the file load. // Returns the length of the file. // The caller is responsible for deleting cachedFile. virtual size_t init(CachedFile *cachedFile) = 0;
// Loads specified byte ranges and passes it to the writer to store them. // Returns 0 on success, Anything but 0 on failure. // The caller is responsible for deleting the writer. virtual int load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer) = 0;};
//------------------------------------------------------------------------
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143//========================================================================//// CairoFontEngine.h//// Copyright 2003 Glyph & Cog, LLC// Copyright 2004 Red Hat, Inc////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>// Copyright (C) 2005, 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net>// Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc@gnome.org>// Copyright (C) 2008, 2017, 2022 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>// Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de>// Copyright (C) 2022 Marek Kasik <mkasik@redhat.com>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef CAIROFONTENGINE_H#define CAIROFONTENGINE_H
#include <memory>#include <mutex>#include <unordered_map>#include <vector>
#include "poppler-config.h"#include <cairo-ft.h>
#include "GfxFont.h"#include "PDFDoc.h"
class CairoFontEngine;
class CairoFont{public: CairoFont(Ref refA, cairo_font_face_t *cairo_font_faceA, std::vector<int> &&codeToGIDA, bool substituteA, bool printingA); virtual ~CairoFont(); CairoFont(const CairoFont &) = delete; CairoFont &operator=(const CairoFont &other) = delete;
virtual bool matches(Ref &other, bool printing); cairo_font_face_t *getFontFace(); unsigned long getGlyph(CharCode code, const Unicode *u, int uLen); double getSubstitutionCorrection(const std::shared_ptr<GfxFont> &gfxFont);
bool isSubstitute() { return substitute; }
Ref getRef() { return ref; }
protected: Ref ref; cairo_font_face_t *cairo_font_face;
std::vector<int> codeToGID;
bool substitute; bool printing;};
//------------------------------------------------------------------------
struct FreeTypeFontFace{ FT_Face face; cairo_font_face_t *cairo_font_face;};
class CairoFreeTypeFont : public CairoFont{public: static CairoFreeTypeFont *create(const std::shared_ptr<GfxFont> &gfxFont, XRef *xref, FT_Library lib, CairoFontEngine *fontEngine, bool useCIDs); ~CairoFreeTypeFont() override;
private: CairoFreeTypeFont(Ref ref, cairo_font_face_t *cairo_font_face, std::vector<int> &&codeToGID, bool substitute);
static std::optional<FreeTypeFontFace> getFreeTypeFontFace(CairoFontEngine *fontEngine, FT_Library lib, const std::string &filename, std::vector<unsigned char> &&data);};
//------------------------------------------------------------------------
class CairoType3Font : public CairoFont{public: static CairoType3Font *create(const std::shared_ptr<GfxFont> &gfxFont, PDFDoc *doc, CairoFontEngine *fontEngine, bool printing, XRef *xref); ~CairoType3Font() override;
bool matches(Ref &other, bool printing) override;
private: CairoType3Font(Ref ref, cairo_font_face_t *cairo_font_face, std::vector<int> &&codeToGIDA, bool printing, XRef *xref);};
//------------------------------------------------------------------------
//------------------------------------------------------------------------// CairoFontEngine//------------------------------------------------------------------------
class CairoFontEngine{public: // Create a font engine. explicit CairoFontEngine(FT_Library libA); ~CairoFontEngine(); CairoFontEngine(const CairoFontEngine &) = delete; CairoFontEngine &operator=(const CairoFontEngine &other) = delete;
std::shared_ptr<CairoFont> getFont(const std::shared_ptr<GfxFont> &gfxFont, PDFDoc *doc, bool printing, XRef *xref);
static std::optional<FreeTypeFontFace> getExternalFontFace(FT_Library ftlib, const std::string &filename);
private: FT_Library lib; bool useCIDs; mutable std::mutex mutex;
// Cache of CairoFont for current document // Most recently used is at the end of the vector. static const size_t cairoFontCacheSize = 64; std::vector<std::shared_ptr<CairoFont>> fontCache;
// Global cache of cairo_font_face_t for external font files. static std::unordered_map<std::string, FreeTypeFontFace> fontFileCache; static std::recursive_mutex fontFileCacheMutex;};
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537//========================================================================//// CairoOutputDev.h//// Copyright 2003 Glyph & Cog, LLC// Copyright 2004 Red Hat, INC////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>// Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org>// Copyright (C) 2008, 2009, 2011-2017, 2022, 2023 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>// Copyright (C) 2018, 2019, 2021 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich// Copyright (C) 2020 Michal <sudolskym@gmail.com>// Copyright (C) 2021 Christian Persch <chpe@src.gnome.org>// Copyright (C) 2022 Marek Kasik <mkasik@redhat.com>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef CAIROOUTPUTDEV_H#define CAIROOUTPUTDEV_H
#include <unordered_set>
#include <cairo-ft.h>#include "OutputDev.h"#include "TextOutputDev.h"#include "GfxState.h"#include "StructElement.h"#include "StructTreeRoot.h"#include "Annot.h"#include "Link.h"
class PDFDoc;class GfxState;class GfxPath;class Gfx8BitFont;struct GfxRGB;class CairoFontEngine;class CairoFont;
//------------------------------------------------------------------------
//------------------------------------------------------------------------// CairoImage//------------------------------------------------------------------------class CairoImage{public: // Constructor. CairoImage(double x1, double y1, double x2, double y2);
// Destructor. ~CairoImage();
CairoImage(const CairoImage &) = delete; CairoImage &operator=(const CairoImage &) = delete;
// Set the image cairo surface void setImage(cairo_surface_t *image);
// Get the image cairo surface cairo_surface_t *getImage() const { return image; }
// Get the image rectangle void getRect(double *xa1, double *ya1, double *xa2, double *ya2) { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
private: cairo_surface_t *image; // image cairo surface double x1, y1; // upper left corner double x2, y2; // lower right corner};
//------------------------------------------------------------------------// CairoOutputDev//------------------------------------------------------------------------
class CairoOutputDev : public OutputDev{public: // Constructor. CairoOutputDev();
// Destructor. ~CairoOutputDev() override;
//----- get info about output device
// Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) bool upsideDown() override { return true; }
// Does this device use drawChar() or drawString()? bool useDrawChar() override { return true; }
// Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. bool useTilingPatternFill() override { return true; }
// Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations.#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) bool useShadedFills(int type) override { return type <= 7; }#else bool useShadedFills(int type) override { return type > 1 && type < 4; }#endif
// Does this device use FillColorStop()? bool useFillColorStop() override { return true; }
// Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. bool interpretType3Chars() override { return false; }
// Does this device need to clip pages to the crop box even when the // box is the crop box? bool needClipToCropBox() override { return true; }
//----- initialization and control
// Start a page. void startPage(int pageNum, GfxState *state, XRef *xref) override;
// End a page. void endPage() override;
// Must be called before last call to endPage() void emitStructTree();
void beginForm(Object *obj, Ref id) override; void endForm(Object *obj, Ref id) override;
//----- save/restore graphics state void saveState(GfxState *state) override; void restoreState(GfxState *state) override;
//----- update graphics state void updateAll(GfxState *state) override; void setDefaultCTM(const double *ctm) override; void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override; void updateLineDash(GfxState *state) override; void updateFlatness(GfxState *state) override; void updateLineJoin(GfxState *state) override; void updateLineCap(GfxState *state) override; void updateMiterLimit(GfxState *state) override; void updateLineWidth(GfxState *state) override; void updateFillColor(GfxState *state) override; void updateStrokeColor(GfxState *state) override; void updateFillOpacity(GfxState *state) override; void updateStrokeOpacity(GfxState *state) override; void updateFillColorStop(GfxState *state, double offset) override; void updateBlendMode(GfxState *state) override;
//----- update text state void updateFont(GfxState *state) override;
//----- path painting void stroke(GfxState *state) override; void fill(GfxState *state) override; void eoFill(GfxState *state) override; void clipToStrokePath(GfxState *state) override; bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override;#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) bool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;#endif bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override; bool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override; bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override; bool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override;#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override; bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;#endif
//----- path clipping void clip(GfxState *state) override; void eoClip(GfxState *state) override;
//----- text drawing void beginString(GfxState *state, const GooString *s) override; void endString(GfxState *state) override; void drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) override; void beginActualText(GfxState *state, const GooString *text) override; void endActualText(GfxState *state) override;
bool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, const Unicode *u, int uLen) override; void endType3Char(GfxState *state) override; void beginTextObject(GfxState *state) override; void endTextObject(GfxState *state) override;
void beginMarkedContent(const char *name, Dict *properties) override; void endMarkedContent(GfxState *state) override;
//----- image drawing void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix) override; void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override; void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg); void drawImageMaskRegular(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg);
void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, bool maskInterpolate) override;
void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override;
//----- transparency groups and soft masks void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override; void endTransparencyGroup(GfxState * /*state*/) override; void popTransparencyGroup(); void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override; void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override; void clearSoftMask(GfxState * /*state*/) override;
//----- Type 3 font operators void type3D0(GfxState *state, double wx, double wy) override; void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) override;
//----- special access
// Called to indicate that a new PDF document has been loaded. void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = nullptr);
// Called to prepare this output dev for rendering CairoType3Font. void startType3Render(GfxState *state, XRef *xref);
bool isReverseVideo() { return false; }
void setCairo(cairo_t *cr); void setTextPage(TextPage *text); void setPrinting(bool printingA) { printing = printingA; needFontUpdate = true; } void copyAntialias(cairo_t *cr, cairo_t *source_cr); void setLogicalStructure(bool logStruct) { this->logicalStruct = logStruct; }
enum Type3RenderType { Type3RenderNone, Type3RenderMask, Type3RenderColor }; void setType3RenderType(Type3RenderType state) { t3_render_state = state; } void getType3GlyphWidth(double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; } bool hasType3GlyphBBox() { return t3_glyph_has_bbox; } double *getType3GlyphBBox() { return t3_glyph_bbox; } bool type3GlyphHasColor() { return t3_glyph_has_color; }
protected: void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path); cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface); void getScaledSize(const cairo_matrix_t *matrix, int orig_width, int orig_height, int *scaledWidth, int *scaledHeight); cairo_filter_t getFilterForSurface(cairo_surface_t *image, bool interpolate); bool getStreamData(Stream *str, char **buffer, int *length); void setMimeData(GfxState *state, Stream *str, Object *ref, GfxImageColorMap *colorMap, cairo_surface_t *image, int height); void fillToStrokePathClip(GfxState *state); void alignStrokeCoords(const GfxSubpath *subpath, int i, double *x, double *y); AnnotLink *findLinkObject(const StructElement *elem); void quadToCairoRect(AnnotQuadrilaterals *quads, int idx, double destPageHeight, cairo_rectangle_t *rect); bool appendLinkDestRef(GooString *s, const LinkDest *dest); void appendLinkDestXY(GooString *s, const LinkDest *dest, double destPageHeight); bool beginLinkTag(AnnotLink *annotLink); bool beginLink(const StructElement *linkElem); void getStructElemAttributeString(const StructElement *elem); int getContentElementStructParents(const StructElement *element); bool checkIfStructElementNeeded(const StructElement *element); void emitStructElement(const StructElement *elem); void startFirstPage(int pageNum, GfxState *state, XRef *xrefA);#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) bool setMimeDataForJBIG2Globals(Stream *str, cairo_surface_t *image);#endif#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10) bool setMimeDataForCCITTParams(Stream *str, cairo_surface_t *image, int height);#endif static void textStringToQuotedUtf8(const GooString *text, GooString *s); bool isPDF();
std::optional<GfxRGB> fill_color, stroke_color; cairo_pattern_t *fill_pattern, *stroke_pattern; double fill_opacity; double stroke_opacity; bool stroke_adjust; bool adjusted_stroke_width; bool align_stroke_coords; std::shared_ptr<CairoFont> currentFont; XRef *xref;
struct StrokePathClip { GfxPath *path; cairo_matrix_t ctm; double line_width; double *dashes; int dash_count; double dash_offset; cairo_line_cap_t cap; cairo_line_join_t join; double miter; int ref_count; } *strokePathClip;
PDFDoc *doc; // the current document
static FT_Library ft_lib; static std::once_flag ft_lib_once_flag;
CairoFontEngine *fontEngine; bool fontEngine_owner;
cairo_t *cairo; cairo_matrix_t orig_matrix; bool needFontUpdate; // set when the font needs to be updated bool printing; bool use_show_text_glyphs; bool text_matrix_valid; cairo_glyph_t *glyphs; int glyphCount; cairo_text_cluster_t *clusters; int clusterCount; char *utf8; int utf8Count; int utf8Max; cairo_path_t *textClipPath; bool inUncoloredPattern; // inside a uncolored pattern (PaintType = 2) Type3RenderType t3_render_state; double t3_glyph_wx, t3_glyph_wy; bool t3_glyph_has_bbox; bool t3_glyph_has_color; bool has_color; double t3_glyph_bbox[4]; bool prescaleImages; bool logicalStruct; bool firstPage; int pdfPageNum; // page number of the PDF file int cairoPageNum; // page number in cairo output std::vector<std::string> markedContentStack; std::vector<Annot *> annotations; std::set<std::string> emittedDestinations; std::map<int, int> pdfPageToCairoPageMap;
TextPage *textPage; // text for the current page ActualText *actualText;
cairo_pattern_t *group; cairo_pattern_t *shape; cairo_pattern_t *mask; cairo_matrix_t mask_matrix; cairo_t *cairo_shape; int knockoutCount; struct ColorSpaceStack { bool knockout; GfxColorSpace *cs; cairo_matrix_t group_matrix; struct ColorSpaceStack *next; } *groupColorSpaceStack;
struct SaveStateElement { // These patterns hold a reference cairo_pattern_t *fill_pattern; cairo_pattern_t *stroke_pattern; double fill_opacity; double stroke_opacity; cairo_pattern_t *mask; // can be null cairo_matrix_t mask_matrix; Ref fontRef; }; std::vector<SaveStateElement> saveStateStack;
std::map<Ref, std::map<std::string, std::unique_ptr<LinkDest>>> destsMap; std::map<Ref, int> pdfPageRefToCairoPageNumMap; std::vector<int> structParentsStack; int currentStructParents;
struct StructParentsMcidHash { size_t operator()(std::pair<int, int> x) const { return x.first << 16 | x.second; } }; std::unordered_set<std::pair<int, int>, StructParentsMcidHash> mcidEmitted; // <structParent, MCID>
std::unordered_set<const StructElement *> structElementNeeded;};
//------------------------------------------------------------------------// CairoImageOutputDev//------------------------------------------------------------------------
// XXX: this should ideally not inherit from CairoOutputDev but use it instead perhapsclass CairoImageOutputDev : public CairoOutputDev{public: // Constructor. CairoImageOutputDev();
// Destructor. ~CairoImageOutputDev() override;
//----- get info about output device
// Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) bool upsideDown() override { return true; }
// Does this device use drawChar() or drawString()? bool useDrawChar() override { return false; }
// Does this device use tilingPatternFill()? If this returns false, // tiling pattern fills will be reduced to a series of other drawing // operations. bool useTilingPatternFill() override { return true; }
// Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations.#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2) bool useShadedFills(int type) override { return type <= 7; }#else bool useShadedFills(int type) override { return type < 4; }#endif
// Does this device use FillColorStop()? bool useFillColorStop() override { return false; }
// Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. bool interpretType3Chars() override { return false; }
// Does this device need non-text content? bool needNonText() override { return true; }
//----- save/restore graphics state void saveState(GfxState *state) override { } void restoreState(GfxState *state) override { }
//----- update graphics state void updateAll(GfxState *state) override { } void setDefaultCTM(const double *ctm) override { } void updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) override { } void updateLineDash(GfxState *state) override { } void updateFlatness(GfxState *state) override { } void updateLineJoin(GfxState *state) override { } void updateLineCap(GfxState *state) override { } void updateMiterLimit(GfxState *state) override { } void updateLineWidth(GfxState *state) override { } void updateFillColor(GfxState *state) override { } void updateStrokeColor(GfxState *state) override { } void updateFillOpacity(GfxState *state) override { } void updateStrokeOpacity(GfxState *state) override { } void updateBlendMode(GfxState *state) override { }
//----- update text state void updateFont(GfxState *state) override { }
//----- path painting void stroke(GfxState *state) override { } void fill(GfxState *state) override { } void eoFill(GfxState *state) override { } void clipToStrokePath(GfxState *state) override { } bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override { return true; } bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override { return true; } bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override { return true; }
//----- path clipping void clip(GfxState *state) override { } void eoClip(GfxState *state) override { }
//----- image drawing void drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) override; void drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) override; void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, bool maskInterpolate) override; void drawMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, bool maskInvert, bool maskInterpolate) override; void setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool inlineImg, double *baseMatrix) override; void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override { }
//----- transparency groups and soft masks void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) override { } void endTransparencyGroup(GfxState * /*state*/) override { } void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) override { } void setSoftMask(GfxState * /*state*/, const double * /*bbox*/, bool /*alpha*/, Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override { } void clearSoftMask(GfxState * /*state*/) override { }
//----- Image list // By default images are not rendred void setImageDrawDecideCbk(bool (*cbk)(int img_id, void *data), void *data) { imgDrawCbk = cbk; imgDrawCbkData = data; } // Iterate through list of images. int getNumImages() const { return numImages; } CairoImage *getImage(int i) const { return images[i]; }
private: void saveImage(CairoImage *image); void getBBox(GfxState *state, int width, int height, double *x1, double *y1, double *x2, double *y2);
CairoImage **images; int numImages; int size; bool (*imgDrawCbk)(int img_id, void *data); void *imgDrawCbkData;};
#endif123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960/* * Copyright © 2009 Mozilla Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of Mozilla Corporation not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. Mozilla Corporation makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL MOZILLA CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * * Author: Jeff Muizelaar, Mozilla Corp. */
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef CAIRO_RESCALE_BOX_H#define CAIRO_RESCALE_BOX_H
#include <cairo.h>
class CairoRescaleBox{public: CairoRescaleBox() {}; virtual ~CairoRescaleBox() {};
CairoRescaleBox(const CairoRescaleBox &) = delete; CairoRescaleBox &operator=(const CairoRescaleBox &) = delete;
virtual bool downScaleImage(unsigned orig_width, unsigned orig_height, signed scaled_width, signed scaled_height, unsigned short int start_column, unsigned short int start_row, unsigned short int width, unsigned short int height, cairo_surface_t *dest_surface);
virtual void getRow(int row_num, uint32_t *row_data) = 0;};
#endif /* CAIRO_RESCALE_BOX_H */123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321//========================================================================//// Catalog.h//// Copyright 1996-2007 Glyph & Cog, LLC////========================================================================
//========================================================================//// Modified under the Poppler project - http://poppler.freedesktop.org//// All changes made under the Poppler project to this file are licensed// under GPL version 2 or later//// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>// Copyright (C) 2005, 2007, 2009-2011, 2013, 2017-2023 Albert Astals Cid <aacid@kde.org>// Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com>// Copyright (C) 2005, 2006, 2008 Brad Hards <bradh@frogmouth.net>// Copyright (C) 2007 Julien Rebetez <julienr@svn.gnome.org>// Copyright (C) 2008, 2011 Pino Toscano <pino@kde.org>// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>// Copyright (C) 2013 Adrian Perez de Castro <aperez@igalia.com>// Copyright (C) 2013, 2017 Adrian Johnson <ajohnson@redneon.com>// Copyright (C) 2013 José Aliste <jaliste@src.gnome.org>// Copyright (C) 2016 Masamichi Hosoda <trueroad@trueroad.jp>// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich// Copyright (C) 2018 Adam Reichold <adam.reichold@t-online.de>// Copyright (C) 2020 Oliver Sander <oliver.sander@tu-dresden.de>// Copyright (C) 2020 Katarina Behrens <Katarina.Behrens@cib.de>// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by Technische Universität Dresden// Copyright (C) 2021 RM <rm+git@arcsin.org>//// To see a description of the changes please see the Changelog file that// came with your tarball or type make ChangeLog if you are building from git////========================================================================
#ifndef CATALOG_H#define CATALOG_H
#include "poppler-config.h"#include "poppler_private_export.h"#include "Object.h"#include "Link.h"
#include <memory>#include <optional>#include <vector>
class PDFDoc;class XRef;class Object;class Page;class PageAttrs;struct Ref;class PageLabelInfo;class Form;class OCGs;class ViewerPreferences;class FileSpec;class StructTreeRoot;
//------------------------------------------------------------------------// NameTree//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT NameTree{public: NameTree(); ~NameTree();
NameTree(const NameTree &) = delete; NameTree &operator=(const NameTree &) = delete;
void init(XRef *xref, Object *tree); Object lookup(const GooString *name); int numEntries() { return length; }; // iterator accessor, note it returns a pointer to the internal object, do not free nor delete it Object *getValue(int i); const GooString *getName(int i) const;
private: struct Entry { Entry(Array *array, int index); ~Entry(); GooString name; Object value; static int cmpEntry(const void *voidEntry, const void *voidOtherEntry); static int cmp(const void *key, const void *entry); };
void parse(const Object *tree, RefRecursionChecker &seen); void addEntry(Entry *entry);
XRef *xref; Entry **entries; int size, length; // size is the number of entries in // the array of Entry* // length is the number of real Entry};
//------------------------------------------------------------------------// Catalog//------------------------------------------------------------------------
class POPPLER_PRIVATE_EXPORT Catalog{public: // Constructor. explicit Catalog(PDFDoc *docA);
// Destructor. ~Catalog();
Catalog(const Catalog &) = delete; Catalog &operator=(const Catalog &) = delete;
// Is catalog valid? bool isOk() { return ok; }
// Get number of pages. int getNumPages();
// Get a page. Page *getPage(int i);
// Get the reference for a page object. Ref *getPageRef(int i);
// Return base URI, or NULL if none. const std::optional<std::string> &getBaseURI() const { return baseURI; }
// Return the contents of the metadata stream, or NULL if there is // no metadata. std::unique_ptr<GooString> readMetadata();
// Return the structure tree root object. StructTreeRoot *getStructTreeRoot();
// Return values from the MarkInfo dictionary as flags in a bitfield. enum MarkInfoFlags { markInfoNull = 1 << 0, markInfoMarked = 1 << 1, markInfoUserProperties = 1 << 2, markInfoSuspects = 1 << 3, }; unsigned int getMarkInfo();
// Find a page, given its object ID. Returns page number, or 0 if // not found. int findPage(const Ref pageRef);
// Find a named destination. Returns the link destination, or // NULL if <name> is not a destination. std::unique_ptr<LinkDest> findDest(const GooString *name);
Object *getDests();
// Get the number of named destinations in name-dict int numDests();
// Get the i'th named destination name in name-dict const char *getDestsName(int i);
// Get the i'th named destination link destination in name-dict std::unique_ptr<LinkDest> getDestsDest(int i);
// Get the number of named destinations in name-tree int numDestNameTree() { return getDestNameTree()->numEntries(); }
// Get the i'th named destination name in name-tree const GooString *getDestNameTreeName(int i) { return getDestNameTree()->getName(i); }
// Get the i'th named destination link destination in name-tree std::unique_ptr<LinkDest> getDestNameTreeDest(int i);
// Get the number of embedded files int numEmbeddedFiles() { return getEmbeddedFileNameTree()->numEntries(); }
// Get the i'th file embedded (at the Document level) in the document std::unique_ptr<FileSpec> embeddedFile(int i);
// Is there an embedded file with the given name? bool hasEmbeddedFile(const std::string &fileName);
// Adds and embeddedFile // If there is already an existing embedded file with the given fileName // it gets replaced, if that's not what you want check hasEmbeddedFile first void addEmbeddedFile(GooFile *file, const std::string &fileName);
// Get the number of javascript scripts int numJS() { return getJSNameTree()->numEntries(); } const GooString *getJSName(int i) { return getJSNameTree()->getName(i); }
// Get the i'th JavaScript script (at the Document level) in the document GooString *getJS(int i);
// Convert between page indices and page labels. bool labelToIndex(GooString *label, int *index); bool indexToLabel(int index, GooString *label);
Object *getOutline(); // returns the existing outline or new one if it doesn't exist Object *getCreateOutline();
Object *getAcroForm() { return &acroForm; } void addFormToAcroForm(const Ref formRef); void removeFormFromAcroForm(const Ref formRef); void setAcroFormModified();
OCGs *getOptContentConfig() { return optContent; }
int getPDFMajorVersion() const { return catalogPdfMajorVersion; } int getPDFMinorVersion() const { return catalogPdfMinorVersion; }
enum FormType { NoForm, AcroForm, XfaForm };
FormType getFormType(); // This can return nullptr if the document is in a very damaged state Form *getCreateForm(); Form *getForm();
ViewerPreferences *getViewerPreferences();
enum PageMode { pageModeNone, pageModeOutlines, pageModeThumbs, pageModeFullScreen, pageModeOC, pageModeAttach, pageModeNull }; enum PageLayout { pageLayoutNone, pageLayoutSinglePage, pageLayoutOneColumn, pageLayoutTwoColumnLeft, pageLayoutTwoColumnRight, pageLayoutTwoPageLeft, pageLayoutTwoPageRight, pageLayoutNull };
// Returns the page mode. PageMode getPageMode(); PageLayout getPageLayout();
enum DocumentAdditionalActionsType { actionCloseDocument, ///< Performed before closing the document actionSaveDocumentStart, ///< Performed before saving the document actionSaveDocumentFinish, ///< Performed after saving the document actionPrintDocumentStart, ///< Performed before printing the document actionPrintDocumentFinish, ///< Performed after printing the document };
std::unique_ptr<LinkAction> getAdditionalAction(DocumentAdditionalActionsType type);
private: // Get page label info. PageLabelInfo *getPageLabelInfo();
PDFDoc *doc; XRef *xref; // the xref table for this PDF file std::vector<std::pair<std::unique_ptr<Page>, Ref>> pages; std::vector<Object> *pagesList; std::vector<Ref> *pagesRefList; std::vector<PageAttrs *> *attrsList; std::vector<int> *kidsIdxList; Form *form; ViewerPreferences *viewerPrefs; int numPages; // number of pages Object dests; // named destination dictionary Object names; // named names dictionary NameTree *destNameTree; // named destination name-tree NameTree *embeddedFileNameTree; // embedded file name-tree NameTree *jsNameTree; // Java Script name-tree std::optional<std::string> baseURI; // base URI for URI-type links Object metadata; // metadata stream StructTreeRoot *structTreeRoot; // structure tree root unsigned int markInfo; // Flags from MarkInfo dictionary Object outline; // outline dictionary Object acroForm; // AcroForm dictionary Object viewerPreferences; // ViewerPreference dictionary OCGs *optContent; // Optional Content groups bool ok; // true if catalog is valid PageLabelInfo *pageLabelInfo; // info about page labels PageMode pageMode; // page mode PageLayout pageLayout; // page layout Object additionalActions; // page additional actions
bool cachePageTree(int page); // Cache first <page> pages. Object *findDestInTree(Object *tree, GooString *name, Object *obj);
Object *getNames(); NameTree *getDestNameTree(); NameTree *getEmbeddedFileNameTree(); NameTree *getJSNameTree(); std::unique_ptr<LinkDest> createLinkDest(Object *obj);
int catalogPdfMajorVersion = -1; int catalogPdfMinorVersion = -1;
mutable std::recursive_mutex mutex;};
#endif.gitattributes+4
poppler-23.11.0/Library/bin/Lerc.dllAdded
poppler-23.11.0/Library/bin/cairo.dllAdded+3
poppler-23.11.0/Library/bin/charset.dllAdded
poppler-23.11.0/Library/bin/deflate.dllAdded
poppler-23.11.0/Library/bin/expat.dllAdded
poppler-23.11.0/Library/bin/fontconfig-1.dllAdded
poppler-23.11.0/Library/bin/freetype.dllAdded
poppler-23.11.0/Library/bin/iconv.dllAdded
poppler-23.11.0/Library/bin/jpeg8.dllAdded
poppler-23.11.0/Library/bin/lcms2.dllAdded
poppler-23.11.0/Library/bin/libcrypto-3-x64.dllAdded+3
poppler-23.11.0/Library/bin/libcurl.dllAdded
poppler-23.11.0/Library/bin/libexpat.dllAdded
poppler-23.11.0/Library/bin/liblzma.dllAdded
poppler-23.11.0/Library/bin/libpng16.dllAdded
poppler-23.11.0/Library/bin/libssh2.dllAdded
poppler-23.11.0/Library/bin/libtiff.dllAdded
poppler-23.11.0/Library/bin/libzstd.dllAdded
poppler-23.11.0/Library/bin/openjp2.dllAdded
poppler-23.11.0/Library/bin/pdfattach.exeAdded
poppler-23.11.0/Library/bin/pdfdetach.exeAdded
poppler-23.11.0/Library/bin/pdffonts.exeAdded
poppler-23.11.0/Library/bin/pdfimages.exeAdded
poppler-23.11.0/Library/bin/pdfinfo.exeAdded
poppler-23.11.0/Library/bin/pdfseparate.exeAdded
poppler-23.11.0/Library/bin/pdftocairo.exeAdded
poppler-23.11.0/Library/bin/pdftohtml.exeAdded
poppler-23.11.0/Library/bin/pdftoppm.exeAdded
poppler-23.11.0/Library/bin/pdftops.exeAdded
poppler-23.11.0/Library/bin/pdftotext.exeAdded
poppler-23.11.0/Library/bin/pdfunite.exeAdded
poppler-23.11.0/Library/bin/pixman-1-0.dllAdded
poppler-23.11.0/Library/bin/poppler-cpp.dllAdded
poppler-23.11.0/Library/bin/poppler-glib.dllAdded
poppler-23.11.0/Library/bin/poppler.dllAdded+3
poppler-23.11.0/Library/bin/tiff.dllAdded
poppler-23.11.0/Library/bin/zlib.dllAdded
poppler-23.11.0/Library/bin/zstd.dllAdded
poppler-23.11.0/Library/bin/zstd.exeAdded
poppler-23.11.0/Library/include/poppler/Annot.hAdded+1784
poppler-23.11.0/Library/include/poppler/AnnotStampImageHelper.hAdded+68
poppler-23.11.0/Library/include/poppler/Array.hAdded+92
poppler-23.11.0/Library/include/poppler/BBoxOutputDev.hAdded+54
poppler-23.11.0/Library/include/poppler/CMap.hAdded+128
poppler-23.11.0/Library/include/poppler/CachedFile.hAdded+149
poppler-23.11.0/Library/include/poppler/CairoFontEngine.hAdded+143
poppler-23.11.0/Library/include/poppler/CairoOutputDev.hAdded+537
poppler-23.11.0/Library/include/poppler/CairoRescaleBox.hAdded+60
poppler-23.11.0/Library/include/poppler/Catalog.hAdded+321