1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_VCL_PDFWRITER_HXX
20 #define INCLUDED_VCL_PDFWRITER_HXX
22 #include <config_options.h>
23 #include <sal/types.h>
25 #include <tools/gen.hxx>
26 #include <tools/color.hxx>
27 #include <rtl/strbuf.hxx>
29 #include <vcl/dllapi.h>
30 #include <vcl/font.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/graph.hxx>
34 #include <com/sun/star/lang/Locale.hpp>
35 #include <com/sun/star/util/DateTime.hpp>
41 namespace com::sun::star::beans
{ class XMaterialHolder
; }
42 namespace com::sun::star::io
{ class XOutputStream
; }
43 namespace com::sun::star::security
{ class XCertificate
; }
61 class PDFExtOutDevData
;
66 OUString Title
; // optional title for the popup containing the note
67 OUString Contents
; // contents of the note
68 css::util::DateTime maModificationDate
;
69 bool isFreeText
= false;
70 std::vector
<basegfx::B2DPolygon
> maPolygons
;
75 class VCL_DLLPUBLIC PDFOutputStream
78 virtual ~PDFOutputStream();
79 virtual void write( const css::uno::Reference
< css::io::XOutputStream
>& xStream
) = 0;
82 class VCL_DLLPUBLIC PDFWriter
84 ScopedVclPtr
<PDFWriterImpl
> xImplementation
;
86 PDFWriter(const PDFWriter
&) = delete;
87 PDFWriter
& operator=(const PDFWriter
&) = delete;
91 enum CapType
{ capButt
, capRound
, capSquare
};
92 enum JoinType
{ joinMiter
, joinRound
, joinBevel
};
96 double m_fTransparency
;
100 std::vector
< double > m_aDashArray
;
102 ExtLineInfo() : m_fLineWidth( 0.0 ),
103 m_fTransparency( 0.0 ),
105 m_eJoin( joinMiter
),
106 m_fMiterLimit( 10.0 )
110 enum class Orientation
{ Portrait
, Inherit
};
112 // in case the below enum is added PDF_2_0, please add just after PDF_1_7
113 enum class PDFVersion
{ PDF_1_4
, PDF_1_5
, PDF_1_6
, PDF_1_7
, PDF_A_1
, PDF_A_2
, PDF_A_3
};//i59651, PDF/A-1b & -1a, only -1b implemented for now
114 // for the meaning of DestAreaType please look at PDF Reference Manual
115 // version 1.4 section 8.2.1, page 475
116 enum class DestAreaType
{ XYZ
, FitRectangle
};
118 // for a definition of structural element types please refer to
119 // PDF Reference, 3rd ed. section 9.7.4
122 // special element to place outside the structure hierarchy
125 Document
, Part
, Article
, Section
, Division
, BlockQuote
,
126 Caption
, TOC
, TOCI
, Index
,
128 // block level elements
129 Paragraph
, Heading
, H1
, H2
, H3
, H4
, H5
, H6
,
130 List
, ListItem
, LILabel
, LIBody
,
131 Table
, TableRow
, TableHeader
, TableData
,
133 // inline level elements
134 Span
, Quote
, Note
, Reference
, BibEntry
, Code
, Link
, Annot
,
136 // illustration elements
137 Figure
, Formula
, Form
145 Placement
, WritingMode
, SpaceBefore
, SpaceAfter
, StartIndent
, EndIndent
,
146 TextIndent
, TextAlign
, Width
, Height
, BlockAlign
, InlineAlign
,
147 LineHeight
, BaselineShift
, TextDecorationType
, ListNumbering
,
148 RowSpan
, ColSpan
, Scope
, Role
,
150 // link destination is an artificial attribute that sets
151 // the link annotation ID of a Link element
152 // further note: since structure attributes can only be
153 // set during content creation, but links can be
154 // created after the fact, it is possible to set
155 // an arbitrary id as structure attribute here. In this
156 // case the arbitrary id has to be passed again when the
157 // actual link annotation is created via SetLinkPropertyID
159 // Language currently sets a LanguageType (see i18nlangtag/lang.h)
160 // which will be internally changed to a corresponding locale
164 enum StructAttributeValue
169 Pagination
, Layout
, Page
, Background
,
170 Header
, Footer
, Watermark
,
172 Block
, Inline
, Before
, After
, Start
, End
,
183 // TextDecorationType
184 Underline
, Overline
, LineThrough
,
190 Disc
, Circle
, Square
, Decimal
, UpperRoman
, LowerRoman
, UpperAlpha
, LowerAlpha
193 enum class PageTransition
196 SplitHorizontalInward
, SplitHorizontalOutward
,
197 SplitVerticalInward
, SplitVerticalOutward
,
198 BlindsHorizontal
, BlindsVertical
,
199 BoxInward
, BoxOutward
,
200 WipeLeftToRight
, WipeBottomToTop
, WipeRightToLeft
, WipeTopToBottom
,
206 PushButton
, RadioButton
, CheckBox
, Edit
, ListBox
, ComboBox
, Hierarchy
,
212 Text
, Number
, Time
, Date
217 // transparent object occurred and was draw opaque because
218 // PDF/A does not allow transparency
219 Warning_Transparency_Omitted_PDFA
,
221 // transparent object occurred but is only supported since
223 Warning_Transparency_Omitted_PDF13
,
225 // a form action was exported that is not suitable for PDF/A
226 // the action was skipped
227 Warning_FormAction_Omitted_PDFA
,
229 // transparent objects were converted to a bitmap in order
230 // to removetransparencies from the output
231 Warning_Transparency_Converted
,
233 // signature generation failed
234 Error_Signature_Failed
,
237 struct VCL_DLLPUBLIC AnyWidget
239 WidgetType Type
; // primitive RTTI
241 OUString Name
; // a distinct name to identify the control
242 OUString Description
;// descriptive text for the control (e.g. for tool tip)
243 OUString Text
; // user text to appear on the control
244 DrawTextFlags TextStyle
; // style flags
246 tools::Rectangle Location
; // describes the area filled by the control
247 bool Border
; // true: widget should have a border, false: no border
248 Color BorderColor
;// COL_TRANSPARENT and Border=true means get color from application settings
249 bool Background
; // true: widget shall draw its background, false: no background
250 Color BackgroundColor
; // COL_TRANSPARENT and Background=true means get color from application settings
251 vcl::Font TextFont
; // an empty font will be replaced by the
252 // appropriate font from the user settings
253 Color TextColor
; // COL_TRANSPARENT will be replaced by the appropriate color from application settings
254 sal_Int32 TabOrder
; // lowest number is first in tab order
256 /* style flags for text are those for OutputDevice::DrawText
258 DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
259 DrawTextFlags::VCenter, DrawTextFlags::Bottom,
260 DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
262 if TextStyle is 0, then each control will fill in default values
265 // note: the Name member comprises the field name of the resulting
266 // PDF field names need to be globally unique. Therefore if any
267 // Widget with an already used name is created, the name will be
268 // made unique by adding an underscore ('_') and an ascending number
271 AnyWidget( WidgetType eType
) :
273 TextStyle( DrawTextFlags::NONE
),
276 BorderColor( COL_TRANSPARENT
),
278 BackgroundColor( COL_TRANSPARENT
),
279 TextColor( COL_TRANSPARENT
),
282 virtual ~AnyWidget();
284 WidgetType
getType() const { return Type
; }
286 virtual std::shared_ptr
<AnyWidget
> Clone() const = 0;
289 // note that this equals the default compiler-generated copy-ctor, but we want to have it
290 // protected, to only allow sub classes to access it
291 AnyWidget( const AnyWidget
& rSource
)
292 :Type( rSource
.Type
)
293 ,Name( rSource
.Name
)
294 ,Description( rSource
.Description
)
295 ,Text( rSource
.Text
)
296 ,TextStyle( rSource
.TextStyle
)
297 ,ReadOnly( rSource
.ReadOnly
)
298 ,Location( rSource
.Location
)
299 ,Border( rSource
.Border
)
300 ,BorderColor( rSource
.BorderColor
)
301 ,Background( rSource
.Background
)
302 ,BackgroundColor( rSource
.BackgroundColor
)
303 ,TextFont( rSource
.TextFont
)
304 ,TextColor( rSource
.TextColor
)
305 ,TabOrder( rSource
.TabOrder
)
308 AnyWidget
& operator=( const AnyWidget
& ) = delete; // never implemented
311 struct PushButtonWidget final
: public AnyWidget
313 /* If Dest is set to a valid link destination,
314 Then pressing the button will act as a goto
315 action within the document.
318 An empty URL means this button will reset the form.
320 If URL is not empty and Submit is set, then the URL
321 contained will be set as the URL to submit the
322 form to. In this case the submit method will be
323 either GET if SubmitGet is true or POST if
326 If URL is not empty and Submit is clear, then
327 the URL contained will be interpreted as a
328 hyperlink to be executed on pushing the button.
330 There will be no error checking or any kind of
331 conversion done to the URL parameter execept this:
332 it will be output as 7bit Ascii. The URL
333 will appear literally in the PDF file produced
341 : AnyWidget( vcl::PDFWriter::PushButton
),
342 Dest( -1 ), Submit( false ), SubmitGet( false )
345 virtual std::shared_ptr
<AnyWidget
> Clone() const override
347 return std::make_shared
<PushButtonWidget
>( *this );
351 struct VCL_DLLPUBLIC CheckBoxWidget final
: public AnyWidget
354 OUString OnValue
; // the value of the checkbox if it is selected
355 OUString OffValue
; // the value of the checkbox if it is not selected
358 : AnyWidget( vcl::PDFWriter::CheckBox
),
362 virtual std::shared_ptr
<AnyWidget
> Clone() const override
364 return std::make_shared
<CheckBoxWidget
>( *this );
368 struct RadioButtonWidget final
: public AnyWidget
371 sal_Int32 RadioGroup
;
372 OUString OnValue
; // the value of the radio button if it is selected
373 OUString OffValue
; // the value of the radio button if it is not selected
376 : AnyWidget( vcl::PDFWriter::RadioButton
),
381 virtual std::shared_ptr
<AnyWidget
> Clone() const override
383 return std::make_shared
<RadioButtonWidget
>( *this );
385 // radio buttons having the same RadioGroup id comprise one
386 // logical radio button group, that is at most one of the RadioButtons
387 // in a group can be checked at any time
389 // note: a PDF radio button field consists of a named field
390 // containing unnamed checkbox child fields. The name of the
391 // radio button field is taken from the first RadioButtonWidget created
395 struct VCL_DLLPUBLIC EditWidget final
: public AnyWidget
397 bool MultiLine
; // whether multiple lines are allowed
398 bool Password
; // visible echo off
399 bool FileSelect
; // field is a file selector
400 sal_Int32 MaxLen
; // maximum field length in characters, 0 means unlimited
402 OUString CurrencySymbol
;
403 sal_Int32 DecimalAccuracy
;
404 bool PrependCurrencySymbol
;
409 : AnyWidget( vcl::PDFWriter::Edit
),
414 Format( FormatType::Text
),
415 DecimalAccuracy ( 0 ),
416 PrependCurrencySymbol( false )
419 virtual std::shared_ptr
<AnyWidget
> Clone() const override
421 return std::make_shared
<EditWidget
>( *this );
425 struct VCL_DLLPUBLIC ListBoxWidget final
: public AnyWidget
429 std::vector
<OUString
> Entries
;
430 std::vector
<sal_Int32
> SelectedEntries
;
431 // if MultiSelect is false only the first entry of SelectedEntries
432 // will be taken into account. the same is implicit for PDF < 1.4
433 // since multiselect is a 1.4+ feature
436 : AnyWidget( vcl::PDFWriter::ListBox
),
441 virtual std::shared_ptr
<AnyWidget
> Clone() const override
443 return std::make_shared
<ListBoxWidget
>( *this );
447 // note: PDF only supports dropdown comboboxes
448 struct ComboBoxWidget final
: public AnyWidget
450 std::vector
<OUString
> Entries
;
451 // set the current value in AnyWidget::Text
454 : AnyWidget( vcl::PDFWriter::ComboBox
)
457 virtual std::shared_ptr
<AnyWidget
> Clone() const override
459 return std::make_shared
<ComboBoxWidget
>( *this );
463 struct SignatureWidget final
: public AnyWidget
466 : AnyWidget( vcl::PDFWriter::Signature
)
469 virtual std::shared_ptr
<AnyWidget
> Clone() const override
471 return std::make_shared
<SignatureWidget
>( *this );
475 enum ExportDataFormat
{ HTML
, XML
, FDF
, PDF
};
476 // see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
477 // These emuns are treated as integer while reading/writing to configuration
478 enum PDFViewerPageMode
484 // These emuns are treated as integer while reading/writing to configuration
493 // These enums are treated as integer while reading/writing to configuration
502 // These emuns are treated as integer while reading/writing to configuration
503 //what default action to generate in a PDF hyperlink to external document/site
504 enum PDFLinkDefaultAction
507 URIActionDestination
,
512 The following structure describes the permissions used in PDF security
514 struct PDFEncryptionProperties
517 //for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20.
518 bool CanPrintTheDocument
;
519 bool CanModifyTheContent
;
520 bool CanCopyOrExtract
;
522 //for revision 3 (bit 128 security) only
523 bool CanFillInteractive
;
524 bool CanExtractForAccessibility
;
528 // encryption will only happen if EncryptionKey is not empty
529 // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
530 // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
531 // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
532 // PDFDocInfo, Owner password and User password used the InitEncryption method which
533 // implements the algorithms described in the PDF reference chapter 3.5: Encryption
534 std::vector
<sal_uInt8
> OValue
;
535 std::vector
<sal_uInt8
> UValue
;
536 std::vector
<sal_uInt8
> EncryptionKey
;
537 std::vector
<sal_uInt8
> DocumentIdentifier
;
539 //permission default set for 128 bit, accessibility only
540 PDFEncryptionProperties() :
541 CanPrintTheDocument ( false ),
542 CanModifyTheContent ( false ),
543 CanCopyOrExtract ( false ),
544 CanAddOrModify ( false ),
545 CanFillInteractive ( false ),
546 CanExtractForAccessibility ( true ),
547 CanAssemble ( false ),
548 CanPrintFull ( false )
553 { return ! OValue
.empty() && ! UValue
.empty() && ! DocumentIdentifier
.empty(); }
558 OUString Title
; // document title
559 OUString Author
; // document author
560 OUString Subject
; // subject
561 OUString Keywords
; // keywords
562 OUString Creator
; // application that created the original document
563 OUString Producer
; // OpenOffice
568 DrawColor
, DrawGreyscale
571 struct PDFWriterContext
573 /* must be a valid file: URL usable by osl */
575 /* the URL of the document being exported, used for relative links*/
577 /*if relative to file system should be formed*/
578 bool RelFsys
;//i56629, i49415?, i64585?
579 /*the action to set the PDF hyperlink to*/
580 PDFWriter::PDFLinkDefaultAction DefaultLinkAction
;
581 //convert the .od? target file type in a link to a .pdf type
582 //this is examined before doing anything else
583 bool ConvertOOoTargetToPDFTarget
;
584 //when the file type is .pdf, force the GoToR action
587 /* decides the PDF language level to be produced */
590 /* PDF/UA compliance */
591 bool UniversalAccessibilityCompliance
;
593 /* valid for PDF >= 1.4
594 causes the MarkInfo entry in the document catalog to be set
597 /* determines in which format a form
600 PDFWriter::ExportDataFormat SubmitFormat
;
601 bool AllowDuplicateFieldNames
;
602 /* the following data members are used to customize the PDF viewer
605 /* see 3.6.1 PDF v 1.4 ref*/
606 PDFWriter::PDFViewerPageMode PDFDocumentMode
;
607 PDFWriter::PDFViewerAction PDFDocumentAction
;
608 // in percent, valid only if PDFDocumentAction == ActionZoom
611 /* see 8.6 PDF v 1.4 ref
612 specifies whether to hide the viewer tool
613 bars when the document is active.
615 bool HideViewerToolbar
;
616 bool HideViewerMenubar
;
617 bool HideViewerWindowControls
;
619 bool OpenInFullScreenMode
;
621 bool DisplayPDFDocumentTitle
;
622 PDFPageLayout PageLayout
;
624 // initially visible page in viewer (starting with 0 for first page)
625 sal_Int32 InitialPage
;
626 sal_Int32 OpenBookmarkLevels
; // -1 means all levels
628 PDFWriter::PDFEncryptionProperties Encryption
;
629 PDFWriter::PDFDocInfo DocumentInfo
;
632 OUString SignLocation
;
633 OUString SignPassword
;
635 OUString SignContact
;
636 css::lang::Locale DocumentLocale
; // defines the document default language
637 sal_uInt32 DPIx
, DPIy
; // how to handle MapMode( MapUnit::MapPixel )
638 // 0 here specifies a default handling
639 PDFWriter::ColorMode ColorMode
;
640 css::uno::Reference
< css::security::XCertificate
> SignCertificate
;
642 /// Use reference XObject markup for PDF images.
643 bool UseReferenceXObject
;
646 RelFsys( false ), //i56629, i49415?, i64585?
647 DefaultLinkAction( PDFWriter::URIAction
),
648 ConvertOOoTargetToPDFTarget( false ),
649 ForcePDFAction( false ),
650 Version(PDFWriter::PDFVersion::PDF_1_7
),
651 UniversalAccessibilityCompliance( false ),
653 SubmitFormat( PDFWriter::FDF
),
654 AllowDuplicateFieldNames( false ),
655 PDFDocumentMode( PDFWriter::ModeDefault
),
656 PDFDocumentAction( PDFWriter::ActionDefault
),
658 HideViewerToolbar( false ),
659 HideViewerMenubar( false ),
660 HideViewerWindowControls( false ),
662 OpenInFullScreenMode( false ),
663 CenterWindow( false ),
664 DisplayPDFDocumentTitle( true ),
665 PageLayout( PDFWriter::DefaultLayout
),
666 FirstPageLeft( false ),
668 OpenBookmarkLevels( -1 ),
672 ColorMode( PDFWriter::DrawColor
),
673 UseReferenceXObject( false )
677 PDFWriter( const PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& );
680 /** Returns an OutputDevice for formatting
681 This Output device is guaranteed to use the same
682 font metrics as the resulting PDF file.
685 the reference output device
687 OutputDevice
* GetReferenceDevice();
689 /** Creates a new page to fill
690 If width and height are not set the page size
691 is inherited from the page tree
693 resets the graphics state: MapMode, Font
694 Colors and other state information MUST
695 be set again or are undefined.
697 void NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
= Orientation::Inherit
);
698 /** Play a metafile like an outputdevice would do
700 struct PlayMetafileContext
702 int m_nMaxImageResolution
;
703 bool m_bOnlyLosslessCompression
;
705 bool m_bTransparenciesWereRemoved
;
707 PlayMetafileContext()
708 : m_nMaxImageResolution( 0 )
709 , m_bOnlyLosslessCompression( false )
710 , m_nJPEGQuality( 90 )
711 , m_bTransparenciesWereRemoved( false )
715 void PlayMetafile( const GDIMetaFile
&, const PlayMetafileContext
&, vcl::PDFExtOutDevData
* pDevDat
= nullptr );
717 /* sets the document locale originally passed with the context to a new value
718 * only affects the output if used before calling Emit.
720 void SetDocumentLocale( const css::lang::Locale
& rDocLocale
);
722 /* finishes the file */
726 * Get a list of errors that occurred during processing
727 * this should enable the producer to give feedback about
728 * any anomalies that might have occurred
730 std::set
< ErrorCode
> const & GetErrors() const;
732 // uses 128bit encryption
733 static css::uno::Reference
< css::beans::XMaterialHolder
>
734 InitEncryption( const OUString
& i_rOwnerPassword
,
735 const OUString
& i_rUserPassword
738 /* functions for graphics state */
739 /* flag values: see vcl/outdev.hxx */
740 void Push( PushFlags nFlags
= PushFlags::ALL
);
743 void SetClipRegion();
744 void SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
745 void MoveClipRegion( tools::Long nHorzMove
, tools::Long nVertMove
);
746 void IntersectClipRegion( const tools::Rectangle
& rRect
);
747 void IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
749 void SetLayoutMode( vcl::text::ComplexTextLayoutFlags nMode
);
750 void SetDigitLanguage( LanguageType eLang
);
752 void SetLineColor( const Color
& rColor
);
753 void SetLineColor() { SetLineColor( COL_TRANSPARENT
); }
755 void SetFillColor( const Color
& rColor
);
756 void SetFillColor() { SetFillColor( COL_TRANSPARENT
); }
758 void SetFont( const vcl::Font
& rNewFont
);
759 void SetTextColor( const Color
& rColor
);
760 void SetTextFillColor();
761 void SetTextFillColor( const Color
& rColor
);
763 void SetTextLineColor();
764 void SetTextLineColor( const Color
& rColor
);
765 void SetOverlineColor();
766 void SetOverlineColor( const Color
& rColor
);
767 void SetTextAlign( ::TextAlign eAlign
);
769 void SetMapMode( const MapMode
& rNewMapMode
);
772 /* actual drawing functions */
773 void DrawText( const Point
& rPos
, const OUString
& rText
);
775 void DrawTextLine( const Point
& rPos
, tools::Long nWidth
,
776 FontStrikeout eStrikeout
,
777 FontLineStyle eUnderline
,
778 FontLineStyle eOverline
);
779 void DrawTextArray( const Point
& rStartPt
, const OUString
& rStr
,
780 KernArraySpan aKernArray
,
781 o3tl::span
<const sal_Bool
> pKashidaAry
,
784 void DrawStretchText( const Point
& rStartPt
, sal_Int32 nWidth
,
785 const OUString
& rStr
,
786 sal_Int32 nIndex
, sal_Int32 nLen
);
787 void DrawText( const tools::Rectangle
& rRect
,
788 const OUString
& rStr
, DrawTextFlags nStyle
);
790 void DrawPixel( const Point
& rPt
, const Color
& rColor
);
791 void DrawPixel( const Point
& rPt
)
792 { DrawPixel( rPt
, COL_TRANSPARENT
); }
794 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
);
795 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
,
796 const LineInfo
& rLineInfo
);
797 void DrawPolyLine( const tools::Polygon
& rPoly
);
798 void DrawPolyLine( const tools::Polygon
& rPoly
,
799 const LineInfo
& rLineInfo
);
800 void DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
);
801 void DrawPolygon( const tools::Polygon
& rPoly
);
802 void DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
);
803 void DrawRect( const tools::Rectangle
& rRect
);
804 void DrawRect( const tools::Rectangle
& rRect
,
805 sal_uInt32 nHorzRount
, sal_uInt32 nVertRound
);
806 void DrawEllipse( const tools::Rectangle
& rRect
);
807 void DrawArc( const tools::Rectangle
& rRect
,
808 const Point
& rStartPt
, const Point
& rEndPt
);
809 void DrawPie( const tools::Rectangle
& rRect
,
810 const Point
& rStartPt
, const Point
& rEndPt
);
811 void DrawChord( const tools::Rectangle
& rRect
,
812 const Point
& rStartPt
, const Point
& rEndPt
);
814 void DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
,
815 const Bitmap
& rBitmap
, const Graphic
& rGraphic
);
817 void DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
,
818 const BitmapEx
& rBitmapEx
);
820 void DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
);
821 void DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
823 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
);
825 void DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
);
826 void DrawTransparent( const tools::PolyPolygon
& rPolyPoly
,
827 sal_uInt16 nTransparencePercent
);
829 /** Start a transparency group
831 Drawing operations can be grouped together to acquire a common transparency
832 behaviour; after calling BeginTransparencyGroup all drawing
833 operations will be grouped together into a transparent object.
835 The transparency behaviour is set with one of the EndTransparencyGroup
836 calls and can be either a constant transparency factor or a transparent
837 soft mask in form of an 8 bit gray scale bitmap.
839 It is permissible to nest transparency group.
841 Transparency groups MUST NOT span multiple pages
843 Transparency is a feature introduced in PDF1.4, so transparency group
844 will be ignored if the produced PDF has a lower version. The drawing
845 operations will be emitted normally.
847 void BeginTransparencyGroup();
849 /** End a transparency group with constant transparency factor
851 This ends a transparency group and inserts it on the current page. The
852 coordinates of the group result out of the grouped drawing operations.
855 The bounding rectangle of the group
857 @param nTransparencePercent
858 The transparency factor
860 void EndTransparencyGroup( const tools::Rectangle
& rBoundRect
, sal_uInt16 nTransparencePercent
);
862 /** Insert a JPG encoded image (optionally with mask)
865 a Stream containing the encoded image
868 true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
871 size in pixel of the image
874 where to put the image
877 optional mask; if not empty it must have
878 the same pixel size as the image and
879 be either 1 bit black&white or 8 bit grey
881 void DrawJPGBitmap( SvStream
& rJPGData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const AlphaMask
& rAlphaMask
, const Graphic
& rGraphic
);
883 /** Create a new named destination to be used in a link from another PDF document
886 the name (label) of the bookmark, to be used to jump to
889 target rectangle on page to be displayed if dest is jumped to
892 number of page the dest is on (as returned by NewPage)
893 or -1 in which case the current page is used
896 what dest type to use
899 the destination id (to be used in SetLinkDest) or
900 -1 if page id does not exist
902 sal_Int32
CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
903 /** Create a new destination to be used in a link
906 target rectangle on page to be displayed if dest is jumped to
909 number of page the dest is on (as returned by NewPage)
910 or -1 in which case the current page is used
913 what dest type to use
916 the destination id (to be used in SetLinkDest) or
917 -1 if page id does not exist
919 sal_Int32
CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
920 /** Create a new link on a page
923 active rectangle of the link (that is the area that has to be
924 hit to activate the link)
927 number of page the link is on (as returned by NewPage)
928 or -1 in which case the current page is used
931 the link id (to be used in SetLinkDest, SetLinkURL) or
932 -1 if page id does not exist
934 sal_Int32
CreateLink(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, OUString
const& rAltText
);
936 /// Creates a screen annotation.
937 sal_Int32
CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, OUString
const& rAltText
, OUString
const& rMimeType
);
939 /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
941 Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
942 point to this destination. In such cases, a public destination Id will be assigned to the form widget,
943 and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
949 target rectangle on page to be displayed if dest is jumped to
952 number of page the dest is on (as returned by NewPage)
953 or -1 in which case the current page is used
956 what dest type to use
959 the internal destination Id.
961 sal_Int32
RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
964 /** Set the destination for a link
965 will change a URL type link to a dest link if necessary
968 the link to be changed
971 the dest the link shall point to
973 void SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
);
974 /** Set the URL for a link
975 will change a dest type link to a URL type link if necessary
977 the link to be changed
980 the URL the link shall point to.
981 The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
982 service; the result will then appear literally in the PDF file produced
984 void SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
);
986 /// Sets the URL of a linked screen annotation.
987 void SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
);
988 /// Sets the URL of an embedded screen annotation.
989 void SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
);
991 /** Resolve link in logical structure
993 If a link is created after the corresponding visual appearance was drawn
994 it is not possible to set the link id as a property attribute to the
995 link structure item that should be created in tagged PDF around the
996 visual appearance of a link.
998 For this reason an arbitrary id can be given to
999 SetStructureAttributeNumerical at the time the text for
1000 the link is drawn. To resolve this arbitrary id again when the actual
1001 link annotation is created use SetLinkPropertyID. When Emit
1002 finally gets called all LinkAnnotation type structure attributes
1003 will be replaced with the correct link id.
1005 CAUTION: this technique must be used either for all or none of the links
1006 in a document since the link id space and arbitrary property id space
1007 could overlap and it would be impossible to resolve whether a Link
1008 structure attribute value was arbitrary or already a real id.
1011 the link to be mapped
1014 the arbitrary id set in a Link structure element to address
1015 the link with real id nLinkId
1017 void SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyID
);
1018 /** Create a new outline item
1021 declares the parent of the new item in the outline hierarchy.
1022 An invalid value will result in a new toplevel item.
1025 sets the title text of the item
1028 declares which Dest (created with CreateDest) the outline item
1032 the outline item id of the new item
1034 sal_Int32
CreateOutlineItem( sal_Int32 nParent
, std::u16string_view rText
, sal_Int32 nDestID
);
1036 /** Create a new note on a page
1039 active rectangle of the note (that is the area that has to be
1040 hit to popup the annotation)
1043 specifies the contents of the note
1046 number of page the note is on (as returned by NewPage)
1047 or -1 in which case the current page is used
1049 void CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
);
1051 /** begin a new logical structure element
1053 BeginStructureElement/EndStructureElement calls build the logical structure
1054 of the PDF - the basis for tagged PDF. Structural elements are implemented
1055 using marked content tags. Each structural element can contain sub elements
1056 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1057 is build automatically from the Begin/EndStructureElement calls.
1059 The easy way is to call WrapBeginStructureElement, but it's also possible
1060 to call EnsureStructureElement/InitStructureElement/BeginStructureElement
1061 (its 3 parts) manually for more control; this way a placeholder SE can be
1062 inserted and initialised later.
1064 A structural element need not be contained on one page; e.g. paragraphs often
1065 run from one page to the next. In this case the corresponding EndStructureElement
1066 must be called while drawing the next page.
1068 BeginStructureElement and EndStructureElement must be called only after
1069 PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1070 current page number is an implicit context parameter for Begin/EndStructureElement.
1072 For pagination artifacts that are not part of the logical structure
1073 of the document (like header, footer or page number) the special
1074 StructElement NonStructElement exists. To place content
1075 outside of the structure tree simply call
1076 BeginStructureElement( NonStructElement ) then draw your
1077 content and then call EndStructureElement(). All children
1078 of a NonStructElement will not be part of the structure.
1079 Nonetheless if you add a child structural element to a
1080 NonStructElement you will still have to call
1081 EndStructureElement for it. Best think of the structure
1084 Note: there is always one structural element in existence without having
1085 called BeginStructureElement; this is the root of the structure
1086 tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1089 denotes what kind of element to begin (e.g. a heading or paragraph)
1092 the specified alias will be used as structure tag. Also an entry in the PDF's
1093 role map will be created mapping alias to regular structure type.
1096 the new structure element's id for use in SetCurrentStructureElement
1098 void BeginStructureElement(sal_Int32 id
);
1099 sal_Int32
EnsureStructureElement();
1100 void InitStructureElement(sal_Int32 id
, PDFWriter::StructElement eType
, std::u16string_view rAlias
);
1102 /** end the current logical structure element
1104 Close the current structure element. The current element's
1105 parent becomes the current structure element again.
1107 @see BeginStructureElement
1109 void EndStructureElement();
1110 /** set the current structure element
1112 For different purposes it may be useful to paint a structure element's
1113 content discontinuously. In that case an already existing structure element
1114 can be appended to by using SetCurrentStructureElement. The
1115 referenced structure element becomes the current structure element with
1116 all consequences: all following structure elements are appended as children
1117 of the current element.
1120 the id of the new current structure element
1122 void SetCurrentStructureElement( sal_Int32 nElement
);
1124 /** set a structure attribute on the current structural element
1126 SetStructureAttribute sets an attribute of the current structural element to a
1127 new value. A consistency check is performed before actually setting the value;
1128 if the check fails, the function returns False and the attribute remains
1132 denotes what attribute to change
1135 the value to set the attribute to
1137 void SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
);
1138 /** set a structure attribute on the current structural element
1140 SetStructureAttributeNumerical sets an attribute of the current structural element
1141 to a new numerical value. A consistency check is performed before actually setting
1142 the value; if the check fails, the function returns False and the attribute
1146 denotes what attribute to change
1149 the value to set the attribute to
1151 void SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
);
1152 /** set the bounding box of a structural element
1154 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1155 attribute can only be applied to Table, Figure,
1156 Form and Formula elements, a call of this function
1157 for other element types will be ignored and the BBox attribute not be set.
1160 the new bounding box for the structural element
1162 void SetStructureBoundingBox( const tools::Rectangle
& rRect
);
1164 /** set the annotations that should be referenced as children of the
1165 current structural element.
1167 void SetStructureAnnotIds(::std::vector
<sal_Int32
> const& rAnnotIds
);
1169 /** set the ActualText attribute of a structural element
1171 ActualText contains the Unicode text without layout artifacts that is shown by
1172 a structural element. For example if a line is ended prematurely with a break in
1173 a word and continued on the next line (e.g. "happen-<newline>stance") the
1174 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1177 contains the complete logical text the structural element displays.
1179 void SetActualText( const OUString
& rText
);
1181 /** set the Alt attribute of a strutural element
1183 Alt is s replacement text describing the contents of a structural element. This
1184 is mainly used by accessibility applications; e.g. a screen reader would read
1185 the Alt replacement text for an image to a visually impaired user.
1188 contains the replacement text for the structural element
1190 void SetAlternateText( const OUString
& rText
);
1192 /** Sets the transitional effect to be applied when the current page gets shown.
1195 the kind of effect to be used; use Regular to disable transitional effects
1199 the duration of the transitional effect in milliseconds;
1200 set 0 to disable transitional effects
1203 the page number to apply the effect to; -1 denotes the current page
1205 void SetPageTransition( PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
);
1207 /** create a new form control
1209 This function creates a new form control in the PDF and sets its various
1210 properties. Do not pass an actual AnyWidget as rControlType
1211 will be cast to the type described by the type member.
1214 a descendant of AnyWidget determining the control's properties
1217 the new control's id for reference purposes
1219 sal_Int32
CreateControl( const AnyWidget
& rControlType
);
1221 /** Attaches an additional file to the PDF file
1223 This function adds an arbitrary stream that represents an attached file
1226 This also adds an additional stream array entry (with the mimetype) in
1227 the trailer dictionary for backwards compatibility.
1230 the filename of the additional file as presented in the stream
1233 the mimetype of the stream
1236 the interface to the additional stream
1238 void AddAttachedFile(OUString
const& rFileName
, OUString
const& rMimeType
, OUString
const& rDescription
, std::unique_ptr
<PDFOutputStream
> pStream
);
1240 /// Write rString as a PDF hex string into rBuffer.
1241 static void AppendUnicodeTextString(const OUString
& rString
, OStringBuffer
& rBuffer
);
1243 /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1244 static OString
GetDateTime();
1249 #endif // INCLUDED_VCL_PDFWRITER_HXX
1251 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */