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
;
71 class VCL_DLLPUBLIC PDFOutputStream
74 virtual ~PDFOutputStream();
75 virtual void write( const css::uno::Reference
< css::io::XOutputStream
>& xStream
) = 0;
78 class VCL_DLLPUBLIC PDFWriter
80 ScopedVclPtr
<PDFWriterImpl
> xImplementation
;
82 PDFWriter(const PDFWriter
&) = delete;
83 PDFWriter
& operator=(const PDFWriter
&) = delete;
87 enum CapType
{ capButt
, capRound
, capSquare
};
88 enum JoinType
{ joinMiter
, joinRound
, joinBevel
};
92 double m_fTransparency
;
96 std::vector
< double > m_aDashArray
;
98 ExtLineInfo() : m_fLineWidth( 0.0 ),
99 m_fTransparency( 0.0 ),
101 m_eJoin( joinMiter
),
102 m_fMiterLimit( 10.0 )
106 enum class Orientation
{ Portrait
, Inherit
};
108 // in case the below enum is added PDF_1_6 PDF_1_7, please add them just after PDF_1_5
109 enum class PDFVersion
{ PDF_1_2
, PDF_1_3
, PDF_1_4
, PDF_1_5
, PDF_1_6
, PDF_A_1
, PDF_A_2
, PDF_A_3
};//i59651, PDF/A-1b & -1a, only -1b implemented for now
110 // for the meaning of DestAreaType please look at PDF Reference Manual
111 // version 1.4 section 8.2.1, page 475
112 enum class DestAreaType
{ XYZ
, FitRectangle
};
114 // for a definition of structural element types please refer to
115 // PDF Reference, 3rd ed. section 9.7.4
118 // special element to place outside the structure hierarchy
121 Document
, Part
, Article
, Section
, Division
, BlockQuote
,
122 Caption
, TOC
, TOCI
, Index
,
124 // block level elements
125 Paragraph
, Heading
, H1
, H2
, H3
, H4
, H5
, H6
,
126 List
, ListItem
, LILabel
, LIBody
,
127 Table
, TableRow
, TableHeader
, TableData
,
129 // inline level elements
130 Span
, Quote
, Note
, Reference
, BibEntry
, Code
, Link
,
132 // illustration elements
133 Figure
, Formula
, Form
138 Placement
, WritingMode
, SpaceBefore
, SpaceAfter
, StartIndent
, EndIndent
,
139 TextIndent
, TextAlign
, Width
, Height
, BlockAlign
, InlineAlign
,
140 LineHeight
, BaselineShift
, TextDecorationType
, ListNumbering
,
143 // link destination is an artificial attribute that sets
144 // the link annotation ID of a Link element
145 // further note: since structure attributes can only be
146 // set during content creation, but links can be
147 // created after the fact, it is possible to set
148 // an arbitrary id as structure attribute here. In this
149 // case the arbitrary id has to be passed again when the
150 // actual link annotation is created via SetLinkPropertyID
152 // Language currently sets a LanguageType (see i18nlangtag/lang.h)
153 // which will be internally changed to a corresponding locale
157 enum StructAttributeValue
162 Block
, Inline
, Before
, After
, Start
, End
,
173 // TextDecorationType
174 Underline
, Overline
, LineThrough
,
176 Disc
, Circle
, Square
, Decimal
, UpperRoman
, LowerRoman
, UpperAlpha
, LowerAlpha
179 enum class PageTransition
182 SplitHorizontalInward
, SplitHorizontalOutward
,
183 SplitVerticalInward
, SplitVerticalOutward
,
184 BlindsHorizontal
, BlindsVertical
,
185 BoxInward
, BoxOutward
,
186 WipeLeftToRight
, WipeBottomToTop
, WipeRightToLeft
, WipeTopToBottom
,
192 PushButton
, RadioButton
, CheckBox
, Edit
, ListBox
, ComboBox
, Hierarchy
,
198 // transparent object occurred and was draw opaque because
199 // PDF/A does not allow transparency
200 Warning_Transparency_Omitted_PDFA
,
202 // transparent object occurred but is only supported since
204 Warning_Transparency_Omitted_PDF13
,
206 // a form action was exported that is not suitable for PDF/A
207 // the action was skipped
208 Warning_FormAction_Omitted_PDFA
,
210 // transparent objects were converted to a bitmap in order
211 // to removetransparencies from the output
212 Warning_Transparency_Converted
,
214 // signature generation failed
215 Error_Signature_Failed
,
218 struct UNLESS_MERGELIBS(VCL_DLLPUBLIC
) AnyWidget
220 WidgetType Type
; // primitive RTTI
222 OUString Name
; // a distinct name to identify the control
223 OUString Description
;// descriptive text for the control (e.g. for tool tip)
224 OUString Text
; // user text to appear on the control
225 DrawTextFlags TextStyle
; // style flags
227 tools::Rectangle Location
; // describes the area filled by the control
228 bool Border
; // true: widget should have a border, false: no border
229 Color BorderColor
;// COL_TRANSPARENT and Border=true means get color from application settings
230 bool Background
; // true: widget shall draw its background, false: no background
231 Color BackgroundColor
; // COL_TRANSPARENT and Background=true means get color from application settings
232 vcl::Font TextFont
; // an empty font will be replaced by the
233 // appropriate font from the user settings
234 Color TextColor
; // COL_TRANSPARENT will be replaced by the appropriate color from application settings
235 sal_Int32 TabOrder
; // lowest number is first in tab order
237 /* style flags for text are those for OutputDevice::DrawText
239 DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
240 DrawTextFlags::VCenter, DrawTextFlags::Bottom,
241 DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
243 if TextStyle is 0, then each control will fill in default values
246 // note: the Name member comprises the field name of the resulting
247 // PDF field names need to be globally unique. Therefore if any
248 // Widget with an already used name is created, the name will be
249 // made unique by adding an underscore ('_') and an ascending number
252 AnyWidget( WidgetType eType
) :
254 TextStyle( DrawTextFlags::NONE
),
257 BorderColor( COL_TRANSPARENT
),
259 BackgroundColor( COL_TRANSPARENT
),
260 TextColor( COL_TRANSPARENT
),
263 virtual ~AnyWidget();
265 WidgetType
getType() const { return Type
; }
267 virtual std::shared_ptr
<AnyWidget
> Clone() const = 0;
270 // note that this equals the default compiler-generated copy-ctor, but we want to have it
271 // protected, to only allow sub classes to access it
272 AnyWidget( const AnyWidget
& rSource
)
273 :Type( rSource
.Type
)
274 ,Name( rSource
.Name
)
275 ,Description( rSource
.Description
)
276 ,Text( rSource
.Text
)
277 ,TextStyle( rSource
.TextStyle
)
278 ,ReadOnly( rSource
.ReadOnly
)
279 ,Location( rSource
.Location
)
280 ,Border( rSource
.Border
)
281 ,BorderColor( rSource
.BorderColor
)
282 ,Background( rSource
.Background
)
283 ,BackgroundColor( rSource
.BackgroundColor
)
284 ,TextFont( rSource
.TextFont
)
285 ,TextColor( rSource
.TextColor
)
286 ,TabOrder( rSource
.TabOrder
)
289 AnyWidget
& operator=( const AnyWidget
& ); // never implemented
292 struct PushButtonWidget final
: public AnyWidget
294 /* If Dest is set to a valid link destination,
295 Then pressing the button will act as a goto
296 action within the document.
299 An empty URL means this button will reset the form.
301 If URL is not empty and Submit is set, then the URL
302 contained will be set as the URL to submit the
303 form to. In this case the submit method will be
304 either GET if SubmitGet is true or POST if
307 If URL is not empty and Submit is clear, then
308 the URL contained will be interpreted as a
309 hyperlink to be executed on pushing the button.
311 There will be no error checking or any kind of
312 conversion done to the URL parameter execept this:
313 it will be output as 7bit Ascii. The URL
314 will appear literally in the PDF file produced
322 : AnyWidget( vcl::PDFWriter::PushButton
),
323 Dest( -1 ), Submit( false ), SubmitGet( false )
326 virtual std::shared_ptr
<AnyWidget
> Clone() const override
328 return std::make_shared
<PushButtonWidget
>( *this );
332 struct CheckBoxWidget final
: public AnyWidget
337 : AnyWidget( vcl::PDFWriter::CheckBox
),
341 virtual std::shared_ptr
<AnyWidget
> Clone() const override
343 return std::make_shared
<CheckBoxWidget
>( *this );
347 struct RadioButtonWidget final
: public AnyWidget
350 sal_Int32 RadioGroup
;
351 OUString OnValue
; // the value of the radio button if it is selected
354 : AnyWidget( vcl::PDFWriter::RadioButton
),
359 virtual std::shared_ptr
<AnyWidget
> Clone() const override
361 return std::make_shared
<RadioButtonWidget
>( *this );
363 // radio buttons having the same RadioGroup id comprise one
364 // logical radio button group, that is at most one of the RadioButtons
365 // in a group can be checked at any time
367 // note: a PDF radio button field consists of a named field
368 // containing unnamed checkbox child fields. The name of the
369 // radio button field is taken from the first RadioButtonWidget created
373 struct EditWidget final
: public AnyWidget
375 bool MultiLine
; // whether multiple lines are allowed
376 bool Password
; // visible echo off
377 bool FileSelect
; // field is a file selector
378 sal_Int32 MaxLen
; // maximum field length in characters, 0 means unlimited
381 : AnyWidget( vcl::PDFWriter::Edit
),
388 virtual std::shared_ptr
<AnyWidget
> Clone() const override
390 return std::make_shared
<EditWidget
>( *this );
394 struct ListBoxWidget final
: public AnyWidget
398 std::vector
<OUString
> Entries
;
399 std::vector
<sal_Int32
> SelectedEntries
;
400 // if MultiSelect is false only the first entry of SelectedEntries
401 // will be taken into account. the same is implicit for PDF < 1.4
402 // since multiselect is a 1.4+ feature
405 : AnyWidget( vcl::PDFWriter::ListBox
),
410 virtual std::shared_ptr
<AnyWidget
> Clone() const override
412 return std::make_shared
<ListBoxWidget
>( *this );
416 // note: PDF only supports dropdown comboboxes
417 struct ComboBoxWidget final
: public AnyWidget
419 std::vector
<OUString
> Entries
;
420 // set the current value in AnyWidget::Text
423 : AnyWidget( vcl::PDFWriter::ComboBox
)
426 virtual std::shared_ptr
<AnyWidget
> Clone() const override
428 return std::make_shared
<ComboBoxWidget
>( *this );
432 struct SignatureWidget final
: public AnyWidget
435 : AnyWidget( vcl::PDFWriter::Signature
)
438 virtual std::shared_ptr
<AnyWidget
> Clone() const override
440 return std::make_shared
<SignatureWidget
>( *this );
444 enum ExportDataFormat
{ HTML
, XML
, FDF
, PDF
};
445 // see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
446 // These emuns are treated as integer while reading/writing to configuration
447 enum PDFViewerPageMode
453 // These emuns are treated as integer while reading/writing to configuration
462 // These enums are treated as integer while reading/writing to configuration
471 // These emuns are treated as integer while reading/writing to configuration
472 //what default action to generate in a PDF hyperlink to external document/site
473 enum PDFLinkDefaultAction
476 URIActionDestination
,
481 The following structure describes the permissions used in PDF security
483 struct PDFEncryptionProperties
486 //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.
487 bool CanPrintTheDocument
;
488 bool CanModifyTheContent
;
489 bool CanCopyOrExtract
;
491 //for revision 3 (bit 128 security) only
492 bool CanFillInteractive
;
493 bool CanExtractForAccessibility
;
497 // encryption will only happen if EncryptionKey is not empty
498 // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
499 // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
500 // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
501 // PDFDocInfo, Owner password and User password used the InitEncryption method which
502 // implements the algorithms described in the PDF reference chapter 3.5: Encryption
503 std::vector
<sal_uInt8
> OValue
;
504 std::vector
<sal_uInt8
> UValue
;
505 std::vector
<sal_uInt8
> EncryptionKey
;
506 std::vector
<sal_uInt8
> DocumentIdentifier
;
508 //permission default set for 128 bit, accessibility only
509 PDFEncryptionProperties() :
510 CanPrintTheDocument ( false ),
511 CanModifyTheContent ( false ),
512 CanCopyOrExtract ( false ),
513 CanAddOrModify ( false ),
514 CanFillInteractive ( false ),
515 CanExtractForAccessibility ( true ),
516 CanAssemble ( false ),
517 CanPrintFull ( false )
522 { return ! OValue
.empty() && ! UValue
.empty() && ! DocumentIdentifier
.empty(); }
527 OUString Title
; // document title
528 OUString Author
; // document author
529 OUString Subject
; // subject
530 OUString Keywords
; // keywords
531 OUString Creator
; // application that created the original document
532 OUString Producer
; // OpenOffice
537 DrawColor
, DrawGreyscale
540 struct PDFWriterContext
542 /* must be a valid file: URL usable by osl */
544 /* the URL of the document being exported, used for relative links*/
546 /*if relative to file system should be formed*/
547 bool RelFsys
;//i56629, i49415?, i64585?
548 /*the action to set the PDF hyperlink to*/
549 PDFWriter::PDFLinkDefaultAction DefaultLinkAction
;
550 //convert the .od? target file type in a link to a .pdf type
551 //this is examined before doing anything else
552 bool ConvertOOoTargetToPDFTarget
;
553 //when the file type is .pdf, force the GoToR action
556 /* decides the PDF language level to be produced */
559 /* PDF/UA compliance */
560 bool UniversalAccessibilityCompliance
;
562 /* valid for PDF >= 1.4
563 causes the MarkInfo entry in the document catalog to be set
566 /* determines in which format a form
569 PDFWriter::ExportDataFormat SubmitFormat
;
570 bool AllowDuplicateFieldNames
;
571 /* the following data members are used to customize the PDF viewer
574 /* see 3.6.1 PDF v 1.4 ref*/
575 PDFWriter::PDFViewerPageMode PDFDocumentMode
;
576 PDFWriter::PDFViewerAction PDFDocumentAction
;
577 // in percent, valid only if PDFDocumentAction == ActionZoom
580 /* see 8.6 PDF v 1.4 ref
581 specifies whether to hide the viewer tool
582 bars when the document is active.
584 bool HideViewerToolbar
;
585 bool HideViewerMenubar
;
586 bool HideViewerWindowControls
;
588 bool OpenInFullScreenMode
;
590 bool DisplayPDFDocumentTitle
;
591 PDFPageLayout PageLayout
;
593 // initially visible page in viewer (starting with 0 for first page)
594 sal_Int32 InitialPage
;
595 sal_Int32 OpenBookmarkLevels
; // -1 means all levels
597 PDFWriter::PDFEncryptionProperties Encryption
;
598 PDFWriter::PDFDocInfo DocumentInfo
;
601 OUString SignLocation
;
602 OUString SignPassword
;
604 OUString SignContact
;
605 css::lang::Locale DocumentLocale
; // defines the document default language
606 sal_uInt32 DPIx
, DPIy
; // how to handle MapMode( MapUnit::MapPixel )
607 // 0 here specifies a default handling
608 PDFWriter::ColorMode ColorMode
;
609 css::uno::Reference
< css::security::XCertificate
> SignCertificate
;
611 /// Use reference XObject markup for PDF images.
612 bool UseReferenceXObject
;
615 RelFsys( false ), //i56629, i49415?, i64585?
616 DefaultLinkAction( PDFWriter::URIAction
),
617 ConvertOOoTargetToPDFTarget( false ),
618 ForcePDFAction( false ),
619 Version( PDFWriter::PDFVersion::PDF_1_6
),
620 UniversalAccessibilityCompliance( false ),
622 SubmitFormat( PDFWriter::FDF
),
623 AllowDuplicateFieldNames( false ),
624 PDFDocumentMode( PDFWriter::ModeDefault
),
625 PDFDocumentAction( PDFWriter::ActionDefault
),
627 HideViewerToolbar( false ),
628 HideViewerMenubar( false ),
629 HideViewerWindowControls( false ),
631 OpenInFullScreenMode( false ),
632 CenterWindow( false ),
633 DisplayPDFDocumentTitle( true ),
634 PageLayout( PDFWriter::DefaultLayout
),
635 FirstPageLeft( false ),
637 OpenBookmarkLevels( -1 ),
641 ColorMode( PDFWriter::DrawColor
),
642 UseReferenceXObject( false )
646 PDFWriter( const PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& );
649 /** Returns an OutputDevice for formatting
650 This Output device is guaranteed to use the same
651 font metrics as the resulting PDF file.
654 the reference output device
656 OutputDevice
* GetReferenceDevice();
658 /** Creates a new page to fill
659 If width and height are not set the page size
660 is inherited from the page tree
662 resets the graphics state: MapMode, Font
663 Colors and other state information MUST
664 be set again or are undefined.
666 void NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
= Orientation::Inherit
);
667 /** Play a metafile like an outputdevice would do
669 struct PlayMetafileContext
671 int m_nMaxImageResolution
;
672 bool m_bOnlyLosslessCompression
;
674 bool m_bTransparenciesWereRemoved
;
676 PlayMetafileContext()
677 : m_nMaxImageResolution( 0 )
678 , m_bOnlyLosslessCompression( false )
679 , m_nJPEGQuality( 90 )
680 , m_bTransparenciesWereRemoved( false )
684 void PlayMetafile( const GDIMetaFile
&, const PlayMetafileContext
&, vcl::PDFExtOutDevData
* pDevDat
= nullptr );
686 /* sets the document locale originally passed with the context to a new value
687 * only affects the output if used before calling Emit.
689 void SetDocumentLocale( const css::lang::Locale
& rDocLocale
);
691 /* finishes the file */
695 * Get a list of errors that occurred during processing
696 * this should enable the producer to give feedback about
697 * any anomalies that might have occurred
699 std::set
< ErrorCode
> const & GetErrors() const;
701 // uses 128bit encryption
702 static css::uno::Reference
< css::beans::XMaterialHolder
>
703 InitEncryption( const OUString
& i_rOwnerPassword
,
704 const OUString
& i_rUserPassword
707 /* functions for graphics state */
708 /* flag values: see vcl/outdev.hxx */
709 void Push( PushFlags nFlags
= PushFlags::ALL
);
712 void SetClipRegion();
713 void SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
714 void MoveClipRegion( tools::Long nHorzMove
, tools::Long nVertMove
);
715 void IntersectClipRegion( const tools::Rectangle
& rRect
);
716 void IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
718 void SetLayoutMode( vcl::text::ComplexTextLayoutFlags nMode
);
719 void SetDigitLanguage( LanguageType eLang
);
721 void SetLineColor( const Color
& rColor
);
722 void SetLineColor() { SetLineColor( COL_TRANSPARENT
); }
724 void SetFillColor( const Color
& rColor
);
725 void SetFillColor() { SetFillColor( COL_TRANSPARENT
); }
727 void SetFont( const vcl::Font
& rNewFont
);
728 void SetTextColor( const Color
& rColor
);
729 void SetTextFillColor();
730 void SetTextFillColor( const Color
& rColor
);
732 void SetTextLineColor();
733 void SetTextLineColor( const Color
& rColor
);
734 void SetOverlineColor();
735 void SetOverlineColor( const Color
& rColor
);
736 void SetTextAlign( ::TextAlign eAlign
);
738 void SetMapMode( const MapMode
& rNewMapMode
);
741 /* actual drawing functions */
742 void DrawText( const Point
& rPos
, const OUString
& rText
);
744 void DrawTextLine( const Point
& rPos
, tools::Long nWidth
,
745 FontStrikeout eStrikeout
,
746 FontLineStyle eUnderline
,
747 FontLineStyle eOverline
);
748 void DrawTextArray( const Point
& rStartPt
, const OUString
& rStr
,
749 o3tl::span
<const sal_Int32
> pDXAry
,
752 void DrawStretchText( const Point
& rStartPt
, sal_uLong nWidth
,
753 const OUString
& rStr
,
754 sal_Int32 nIndex
, sal_Int32 nLen
);
755 void DrawText( const tools::Rectangle
& rRect
,
756 const OUString
& rStr
, DrawTextFlags nStyle
);
758 void DrawPixel( const Point
& rPt
, const Color
& rColor
);
759 void DrawPixel( const Point
& rPt
)
760 { DrawPixel( rPt
, COL_TRANSPARENT
); }
762 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
);
763 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
,
764 const LineInfo
& rLineInfo
);
765 void DrawPolyLine( const tools::Polygon
& rPoly
);
766 void DrawPolyLine( const tools::Polygon
& rPoly
,
767 const LineInfo
& rLineInfo
);
768 void DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
);
769 void DrawPolygon( const tools::Polygon
& rPoly
);
770 void DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
);
771 void DrawRect( const tools::Rectangle
& rRect
);
772 void DrawRect( const tools::Rectangle
& rRect
,
773 sal_uLong nHorzRount
, sal_uLong nVertRound
);
774 void DrawEllipse( const tools::Rectangle
& rRect
);
775 void DrawArc( const tools::Rectangle
& rRect
,
776 const Point
& rStartPt
, const Point
& rEndPt
);
777 void DrawPie( const tools::Rectangle
& rRect
,
778 const Point
& rStartPt
, const Point
& rEndPt
);
779 void DrawChord( const tools::Rectangle
& rRect
,
780 const Point
& rStartPt
, const Point
& rEndPt
);
782 void DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
,
783 const Bitmap
& rBitmap
, const Graphic
& rGraphic
);
785 void DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
,
786 const BitmapEx
& rBitmapEx
);
788 void DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
);
789 void DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
791 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
);
793 void DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
);
794 void DrawTransparent( const tools::PolyPolygon
& rPolyPoly
,
795 sal_uInt16 nTransparencePercent
);
797 /** Start a transparency group
799 Drawing operations can be grouped together to acquire a common transparency
800 behaviour; after calling BeginTransparencyGroup all drawing
801 operations will be grouped together into a transparent object.
803 The transparency behaviour is set with one of the EndTransparencyGroup
804 calls and can be either a constant transparency factor or a transparent
805 soft mask in form of an 8 bit gray scale bitmap.
807 It is permissible to nest transparency group.
809 Transparency groups MUST NOT span multiple pages
811 Transparency is a feature introduced in PDF1.4, so transparency group
812 will be ignored if the produced PDF has a lower version. The drawing
813 operations will be emitted normally.
815 void BeginTransparencyGroup();
817 /** End a transparency group with constant transparency factor
819 This ends a transparency group and inserts it on the current page. The
820 coordinates of the group result out of the grouped drawing operations.
823 The bounding rectangle of the group
825 @param nTransparencePercent
826 The transparency factor
828 void EndTransparencyGroup( const tools::Rectangle
& rBoundRect
, sal_uInt16 nTransparencePercent
);
830 /** Insert a JPG encoded image (optionally with mask)
833 a Stream containing the encoded image
836 true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
839 size in pixel of the image
842 where to put the image
845 optional mask; if not empty it must have
846 the same pixel size as the image and
847 be either 1 bit black&white or 8 bit grey
849 void DrawJPGBitmap( SvStream
& rJPGData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const AlphaMask
& rAlphaMask
, const Graphic
& rGraphic
);
851 /** Create a new named destination to be used in a link from another PDF document
854 the name (label) of the bookmark, to be used to jump to
857 target rectangle on page to be displayed if dest is jumped to
860 number of page the dest is on (as returned by NewPage)
861 or -1 in which case the current page is used
864 what dest type to use
867 the destination id (to be used in SetLinkDest) or
868 -1 if page id does not exist
870 sal_Int32
CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
871 /** Create a new destination to be used in a link
874 target rectangle on page to be displayed if dest is jumped to
877 number of page the dest is on (as returned by NewPage)
878 or -1 in which case the current page is used
881 what dest type to use
884 the destination id (to be used in SetLinkDest) or
885 -1 if page id does not exist
887 sal_Int32
CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
888 /** Create a new link on a page
891 active rectangle of the link (that is the area that has to be
892 hit to activate the link)
895 number of page the link is on (as returned by NewPage)
896 or -1 in which case the current page is used
899 the link id (to be used in SetLinkDest, SetLinkURL) or
900 -1 if page id does not exist
902 sal_Int32
CreateLink( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
904 /// Creates a screen annotation.
905 sal_Int32
CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
907 /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
909 Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
910 point to this destination. In such cases, a public destination Id will be assigned to the form widget,
911 and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
917 target rectangle on page to be displayed if dest is jumped to
920 number of page the dest is on (as returned by NewPage)
921 or -1 in which case the current page is used
924 what dest type to use
927 the internal destination Id.
929 sal_Int32
RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
932 /** Set the destination for a link
933 will change a URL type link to a dest link if necessary
936 the link to be changed
939 the dest the link shall point to
941 void SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
);
942 /** Set the URL for a link
943 will change a dest type link to a URL type link if necessary
945 the link to be changed
948 the URL the link shall point to.
949 The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
950 service; the result will then appear literally in the PDF file produced
952 void SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
);
954 /// Sets the URL of a linked screen annotation.
955 void SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
);
956 /// Sets the URL of an embedded screen annotation.
957 void SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
);
959 /** Resolve link in logical structure
961 If a link is created after the corresponding visual appearance was drawn
962 it is not possible to set the link id as a property attribute to the
963 link structure item that should be created in tagged PDF around the
964 visual appearance of a link.
966 For this reason an arbitrary id can be given to
967 SetStructureAttributeNumerical at the time the text for
968 the link is drawn. To resolve this arbitrary id again when the actual
969 link annotation is created use SetLinkPropertyID. When Emit
970 finally gets called all LinkAnnotation type structure attributes
971 will be replaced with the correct link id.
973 CAUTION: this technique must be used either for all or none of the links
974 in a document since the link id space and arbitrary property id space
975 could overlap and it would be impossible to resolve whether a Link
976 structure attribute value was arbitrary or already a real id.
979 the link to be mapped
982 the arbitrary id set in a Link structure element to address
983 the link with real id nLinkId
985 void SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyID
);
986 /** Create a new outline item
989 declares the parent of the new item in the outline hierarchy.
990 An invalid value will result in a new toplevel item.
993 sets the title text of the item
996 declares which Dest (created with CreateDest) the outline item
1000 the outline item id of the new item
1002 sal_Int32
CreateOutlineItem( sal_Int32 nParent
, const OUString
& rText
, sal_Int32 nDestID
);
1004 /** Create a new note on a page
1007 active rectangle of the note (that is the area that has to be
1008 hit to popup the annotation)
1011 specifies the contents of the note
1014 number of page the note is on (as returned by NewPage)
1015 or -1 in which case the current page is used
1017 void CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
);
1019 /** begin a new logical structure element
1021 BeginStructureElement/EndStructureElement calls build the logical structure
1022 of the PDF - the basis for tagged PDF. Structural elements are implemented
1023 using marked content tags. Each structural element can contain sub elements
1024 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1025 is build automatically from the Begin/EndStructureElement calls.
1027 A structural element need not be contained on one page; e.g. paragraphs often
1028 run from one page to the next. In this case the corresponding EndStructureElement
1029 must be called while drawing the next page.
1031 BeginStructureElement and EndStructureElement must be called only after
1032 PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1033 current page number is an implicit context parameter for Begin/EndStructureElement.
1035 For pagination artifacts that are not part of the logical structure
1036 of the document (like header, footer or page number) the special
1037 StructElement NonStructElement exists. To place content
1038 outside of the structure tree simply call
1039 BeginStructureElement( NonStructElement ) then draw your
1040 content and then call EndStructureElement(). All children
1041 of a NonStructElement will not be part of the structure.
1042 Nonetheless if you add a child structural element to a
1043 NonStructElement you will still have to call
1044 EndStructureElement for it. Best think of the structure
1047 Note: there is always one structural element in existence without having
1048 called BeginStructureElement; this is the root of the structure
1049 tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1052 denotes what kind of element to begin (e.g. a heading or paragraph)
1055 the specified alias will be used as structure tag. Also an entry in the PDF's
1056 role map will be created mapping alias to regular structure type.
1059 the new structure element's id for use in SetCurrentStructureElement
1061 sal_Int32
BeginStructureElement( enum StructElement eType
, const OUString
& rAlias
);
1062 /** end the current logical structure element
1064 Close the current structure element. The current element's
1065 parent becomes the current structure element again.
1067 @see BeginStructureElement
1069 void EndStructureElement();
1070 /** set the current structure element
1072 For different purposes it may be useful to paint a structure element's
1073 content discontinuously. In that case an already existing structure element
1074 can be appended to by using SetCurrentStructureElement. The
1075 referenced structure element becomes the current structure element with
1076 all consequences: all following structure elements are appended as children
1077 of the current element.
1080 the id of the new current structure element
1082 void SetCurrentStructureElement( sal_Int32 nElement
);
1084 /** set a structure attribute on the current structural element
1086 SetStructureAttribute sets an attribute of the current structural element to a
1087 new value. A consistency check is performed before actually setting the value;
1088 if the check fails, the function returns False and the attribute remains
1092 denotes what attribute to change
1095 the value to set the attribute to
1097 void SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
);
1098 /** set a structure attribute on the current structural element
1100 SetStructureAttributeNumerical sets an attribute of the current structural element
1101 to a new numerical value. A consistency check is performed before actually setting
1102 the value; if the check fails, the function returns False and the attribute
1106 denotes what attribute to change
1109 the value to set the attribute to
1111 void SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
);
1112 /** set the bounding box of a structural element
1114 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1115 attribute can only be applied to Table, Figure,
1116 Form and Formula elements, a call of this function
1117 for other element types will be ignored and the BBox attribute not be set.
1120 the new bounding box for the structural element
1122 void SetStructureBoundingBox( const tools::Rectangle
& rRect
);
1124 /** set the ActualText attribute of a structural element
1126 ActualText contains the Unicode text without layout artifacts that is shown by
1127 a structural element. For example if a line is ended prematurely with a break in
1128 a word and continued on the next line (e.g. "happen-<newline>stance") the
1129 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1132 contains the complete logical text the structural element displays.
1134 void SetActualText( const OUString
& rText
);
1136 /** set the Alt attribute of a strutural element
1138 Alt is s replacement text describing the contents of a structural element. This
1139 is mainly used by accessibility applications; e.g. a screen reader would read
1140 the Alt replacement text for an image to a visually impaired user.
1143 contains the replacement text for the structural element
1145 void SetAlternateText( const OUString
& rText
);
1147 /** Sets the transitional effect to be applied when the current page gets shown.
1150 the kind of effect to be used; use Regular to disable transitional effects
1154 the duration of the transitional effect in milliseconds;
1155 set 0 to disable transitional effects
1158 the page number to apply the effect to; -1 denotes the current page
1160 void SetPageTransition( PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
);
1162 /** create a new form control
1164 This function creates a new form control in the PDF and sets its various
1165 properties. Do not pass an actual AnyWidget as rControlType
1166 will be cast to the type described by the type member.
1169 a descendant of AnyWidget determining the control's properties
1172 the new control's id for reference purposes
1174 sal_Int32
CreateControl( const AnyWidget
& rControlType
);
1176 /** Inserts an additional stream to the PDF file
1178 This function adds an arbitrary stream to the produced PDF file. May be called
1179 any time before Emit(). The stream will be written during
1180 Emit by calling the PDFOutputStream Object's write
1181 method. After the call the PDFOutputStream will be deleted.
1183 All additional streams and their mimetypes will be entered into an array
1184 in the trailer dictionary.
1187 the mimetype of the stream
1190 the interface to the additional stream
1193 void AddStream( const OUString
& rMimeType
, PDFOutputStream
* pStream
);
1195 /// Write rString as a PDF hex string into rBuffer.
1196 static void AppendUnicodeTextString(const OUString
& rString
, OStringBuffer
& rBuffer
);
1198 /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1199 static OString
GetDateTime();
1202 VCL_DLLPUBLIC
void escapeStringXML( const OUString
& rStr
, OUString
&rValue
);
1206 #endif // INCLUDED_VCL_PDFWRITER_HXX
1208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */