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 Text
, Number
, Time
, Date
203 // transparent object occurred and was draw opaque because
204 // PDF/A does not allow transparency
205 Warning_Transparency_Omitted_PDFA
,
207 // transparent object occurred but is only supported since
209 Warning_Transparency_Omitted_PDF13
,
211 // a form action was exported that is not suitable for PDF/A
212 // the action was skipped
213 Warning_FormAction_Omitted_PDFA
,
215 // transparent objects were converted to a bitmap in order
216 // to removetransparencies from the output
217 Warning_Transparency_Converted
,
219 // signature generation failed
220 Error_Signature_Failed
,
223 struct VCL_DLLPUBLIC AnyWidget
225 WidgetType Type
; // primitive RTTI
227 OUString Name
; // a distinct name to identify the control
228 OUString Description
;// descriptive text for the control (e.g. for tool tip)
229 OUString Text
; // user text to appear on the control
230 DrawTextFlags TextStyle
; // style flags
232 tools::Rectangle Location
; // describes the area filled by the control
233 bool Border
; // true: widget should have a border, false: no border
234 Color BorderColor
;// COL_TRANSPARENT and Border=true means get color from application settings
235 bool Background
; // true: widget shall draw its background, false: no background
236 Color BackgroundColor
; // COL_TRANSPARENT and Background=true means get color from application settings
237 vcl::Font TextFont
; // an empty font will be replaced by the
238 // appropriate font from the user settings
239 Color TextColor
; // COL_TRANSPARENT will be replaced by the appropriate color from application settings
240 sal_Int32 TabOrder
; // lowest number is first in tab order
242 /* style flags for text are those for OutputDevice::DrawText
244 DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
245 DrawTextFlags::VCenter, DrawTextFlags::Bottom,
246 DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
248 if TextStyle is 0, then each control will fill in default values
251 // note: the Name member comprises the field name of the resulting
252 // PDF field names need to be globally unique. Therefore if any
253 // Widget with an already used name is created, the name will be
254 // made unique by adding an underscore ('_') and an ascending number
257 AnyWidget( WidgetType eType
) :
259 TextStyle( DrawTextFlags::NONE
),
262 BorderColor( COL_TRANSPARENT
),
264 BackgroundColor( COL_TRANSPARENT
),
265 TextColor( COL_TRANSPARENT
),
268 virtual ~AnyWidget();
270 WidgetType
getType() const { return Type
; }
272 virtual std::shared_ptr
<AnyWidget
> Clone() const = 0;
275 // note that this equals the default compiler-generated copy-ctor, but we want to have it
276 // protected, to only allow sub classes to access it
277 AnyWidget( const AnyWidget
& rSource
)
278 :Type( rSource
.Type
)
279 ,Name( rSource
.Name
)
280 ,Description( rSource
.Description
)
281 ,Text( rSource
.Text
)
282 ,TextStyle( rSource
.TextStyle
)
283 ,ReadOnly( rSource
.ReadOnly
)
284 ,Location( rSource
.Location
)
285 ,Border( rSource
.Border
)
286 ,BorderColor( rSource
.BorderColor
)
287 ,Background( rSource
.Background
)
288 ,BackgroundColor( rSource
.BackgroundColor
)
289 ,TextFont( rSource
.TextFont
)
290 ,TextColor( rSource
.TextColor
)
291 ,TabOrder( rSource
.TabOrder
)
294 AnyWidget
& operator=( const AnyWidget
& ) = delete; // never implemented
297 struct PushButtonWidget final
: public AnyWidget
299 /* If Dest is set to a valid link destination,
300 Then pressing the button will act as a goto
301 action within the document.
304 An empty URL means this button will reset the form.
306 If URL is not empty and Submit is set, then the URL
307 contained will be set as the URL to submit the
308 form to. In this case the submit method will be
309 either GET if SubmitGet is true or POST if
312 If URL is not empty and Submit is clear, then
313 the URL contained will be interpreted as a
314 hyperlink to be executed on pushing the button.
316 There will be no error checking or any kind of
317 conversion done to the URL parameter execept this:
318 it will be output as 7bit Ascii. The URL
319 will appear literally in the PDF file produced
327 : AnyWidget( vcl::PDFWriter::PushButton
),
328 Dest( -1 ), Submit( false ), SubmitGet( false )
331 virtual std::shared_ptr
<AnyWidget
> Clone() const override
333 return std::make_shared
<PushButtonWidget
>( *this );
337 struct VCL_DLLPUBLIC CheckBoxWidget final
: public AnyWidget
340 OUString OnValue
; // the value of the checkbox if it is selected
341 OUString OffValue
; // the value of the checkbox if it is not selected
344 : AnyWidget( vcl::PDFWriter::CheckBox
),
348 virtual std::shared_ptr
<AnyWidget
> Clone() const override
350 return std::make_shared
<CheckBoxWidget
>( *this );
354 struct RadioButtonWidget final
: public AnyWidget
357 sal_Int32 RadioGroup
;
358 OUString OnValue
; // the value of the radio button if it is selected
359 OUString OffValue
; // the value of the radio button if it is not selected
362 : AnyWidget( vcl::PDFWriter::RadioButton
),
367 virtual std::shared_ptr
<AnyWidget
> Clone() const override
369 return std::make_shared
<RadioButtonWidget
>( *this );
371 // radio buttons having the same RadioGroup id comprise one
372 // logical radio button group, that is at most one of the RadioButtons
373 // in a group can be checked at any time
375 // note: a PDF radio button field consists of a named field
376 // containing unnamed checkbox child fields. The name of the
377 // radio button field is taken from the first RadioButtonWidget created
381 struct VCL_DLLPUBLIC EditWidget final
: public AnyWidget
383 bool MultiLine
; // whether multiple lines are allowed
384 bool Password
; // visible echo off
385 bool FileSelect
; // field is a file selector
386 sal_Int32 MaxLen
; // maximum field length in characters, 0 means unlimited
388 OUString CurrencySymbol
;
389 sal_Int32 DecimalAccuracy
;
390 bool PrependCurrencySymbol
;
395 : AnyWidget( vcl::PDFWriter::Edit
),
400 Format( FormatType::Text
)
403 virtual std::shared_ptr
<AnyWidget
> Clone() const override
405 return std::make_shared
<EditWidget
>( *this );
409 struct VCL_DLLPUBLIC ListBoxWidget final
: public AnyWidget
413 std::vector
<OUString
> Entries
;
414 std::vector
<sal_Int32
> SelectedEntries
;
415 // if MultiSelect is false only the first entry of SelectedEntries
416 // will be taken into account. the same is implicit for PDF < 1.4
417 // since multiselect is a 1.4+ feature
420 : AnyWidget( vcl::PDFWriter::ListBox
),
425 virtual std::shared_ptr
<AnyWidget
> Clone() const override
427 return std::make_shared
<ListBoxWidget
>( *this );
431 // note: PDF only supports dropdown comboboxes
432 struct ComboBoxWidget final
: public AnyWidget
434 std::vector
<OUString
> Entries
;
435 // set the current value in AnyWidget::Text
438 : AnyWidget( vcl::PDFWriter::ComboBox
)
441 virtual std::shared_ptr
<AnyWidget
> Clone() const override
443 return std::make_shared
<ComboBoxWidget
>( *this );
447 struct SignatureWidget final
: public AnyWidget
450 : AnyWidget( vcl::PDFWriter::Signature
)
453 virtual std::shared_ptr
<AnyWidget
> Clone() const override
455 return std::make_shared
<SignatureWidget
>( *this );
459 enum ExportDataFormat
{ HTML
, XML
, FDF
, PDF
};
460 // see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
461 // These emuns are treated as integer while reading/writing to configuration
462 enum PDFViewerPageMode
468 // These emuns are treated as integer while reading/writing to configuration
477 // These enums are treated as integer while reading/writing to configuration
486 // These emuns are treated as integer while reading/writing to configuration
487 //what default action to generate in a PDF hyperlink to external document/site
488 enum PDFLinkDefaultAction
491 URIActionDestination
,
496 The following structure describes the permissions used in PDF security
498 struct PDFEncryptionProperties
501 //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.
502 bool CanPrintTheDocument
;
503 bool CanModifyTheContent
;
504 bool CanCopyOrExtract
;
506 //for revision 3 (bit 128 security) only
507 bool CanFillInteractive
;
508 bool CanExtractForAccessibility
;
512 // encryption will only happen if EncryptionKey is not empty
513 // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
514 // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
515 // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
516 // PDFDocInfo, Owner password and User password used the InitEncryption method which
517 // implements the algorithms described in the PDF reference chapter 3.5: Encryption
518 std::vector
<sal_uInt8
> OValue
;
519 std::vector
<sal_uInt8
> UValue
;
520 std::vector
<sal_uInt8
> EncryptionKey
;
521 std::vector
<sal_uInt8
> DocumentIdentifier
;
523 //permission default set for 128 bit, accessibility only
524 PDFEncryptionProperties() :
525 CanPrintTheDocument ( false ),
526 CanModifyTheContent ( false ),
527 CanCopyOrExtract ( false ),
528 CanAddOrModify ( false ),
529 CanFillInteractive ( false ),
530 CanExtractForAccessibility ( true ),
531 CanAssemble ( false ),
532 CanPrintFull ( false )
537 { return ! OValue
.empty() && ! UValue
.empty() && ! DocumentIdentifier
.empty(); }
542 OUString Title
; // document title
543 OUString Author
; // document author
544 OUString Subject
; // subject
545 OUString Keywords
; // keywords
546 OUString Creator
; // application that created the original document
547 OUString Producer
; // OpenOffice
552 DrawColor
, DrawGreyscale
555 struct PDFWriterContext
557 /* must be a valid file: URL usable by osl */
559 /* the URL of the document being exported, used for relative links*/
561 /*if relative to file system should be formed*/
562 bool RelFsys
;//i56629, i49415?, i64585?
563 /*the action to set the PDF hyperlink to*/
564 PDFWriter::PDFLinkDefaultAction DefaultLinkAction
;
565 //convert the .od? target file type in a link to a .pdf type
566 //this is examined before doing anything else
567 bool ConvertOOoTargetToPDFTarget
;
568 //when the file type is .pdf, force the GoToR action
571 /* decides the PDF language level to be produced */
574 /* PDF/UA compliance */
575 bool UniversalAccessibilityCompliance
;
577 /* valid for PDF >= 1.4
578 causes the MarkInfo entry in the document catalog to be set
581 /* determines in which format a form
584 PDFWriter::ExportDataFormat SubmitFormat
;
585 bool AllowDuplicateFieldNames
;
586 /* the following data members are used to customize the PDF viewer
589 /* see 3.6.1 PDF v 1.4 ref*/
590 PDFWriter::PDFViewerPageMode PDFDocumentMode
;
591 PDFWriter::PDFViewerAction PDFDocumentAction
;
592 // in percent, valid only if PDFDocumentAction == ActionZoom
595 /* see 8.6 PDF v 1.4 ref
596 specifies whether to hide the viewer tool
597 bars when the document is active.
599 bool HideViewerToolbar
;
600 bool HideViewerMenubar
;
601 bool HideViewerWindowControls
;
603 bool OpenInFullScreenMode
;
605 bool DisplayPDFDocumentTitle
;
606 PDFPageLayout PageLayout
;
608 // initially visible page in viewer (starting with 0 for first page)
609 sal_Int32 InitialPage
;
610 sal_Int32 OpenBookmarkLevels
; // -1 means all levels
612 PDFWriter::PDFEncryptionProperties Encryption
;
613 PDFWriter::PDFDocInfo DocumentInfo
;
616 OUString SignLocation
;
617 OUString SignPassword
;
619 OUString SignContact
;
620 css::lang::Locale DocumentLocale
; // defines the document default language
621 sal_uInt32 DPIx
, DPIy
; // how to handle MapMode( MapUnit::MapPixel )
622 // 0 here specifies a default handling
623 PDFWriter::ColorMode ColorMode
;
624 css::uno::Reference
< css::security::XCertificate
> SignCertificate
;
626 /// Use reference XObject markup for PDF images.
627 bool UseReferenceXObject
;
630 RelFsys( false ), //i56629, i49415?, i64585?
631 DefaultLinkAction( PDFWriter::URIAction
),
632 ConvertOOoTargetToPDFTarget( false ),
633 ForcePDFAction( false ),
634 Version( PDFWriter::PDFVersion::PDF_1_6
),
635 UniversalAccessibilityCompliance( false ),
637 SubmitFormat( PDFWriter::FDF
),
638 AllowDuplicateFieldNames( false ),
639 PDFDocumentMode( PDFWriter::ModeDefault
),
640 PDFDocumentAction( PDFWriter::ActionDefault
),
642 HideViewerToolbar( false ),
643 HideViewerMenubar( false ),
644 HideViewerWindowControls( false ),
646 OpenInFullScreenMode( false ),
647 CenterWindow( false ),
648 DisplayPDFDocumentTitle( true ),
649 PageLayout( PDFWriter::DefaultLayout
),
650 FirstPageLeft( false ),
652 OpenBookmarkLevels( -1 ),
656 ColorMode( PDFWriter::DrawColor
),
657 UseReferenceXObject( false )
661 PDFWriter( const PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& );
664 /** Returns an OutputDevice for formatting
665 This Output device is guaranteed to use the same
666 font metrics as the resulting PDF file.
669 the reference output device
671 OutputDevice
* GetReferenceDevice();
673 /** Creates a new page to fill
674 If width and height are not set the page size
675 is inherited from the page tree
677 resets the graphics state: MapMode, Font
678 Colors and other state information MUST
679 be set again or are undefined.
681 void NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
= Orientation::Inherit
);
682 /** Play a metafile like an outputdevice would do
684 struct PlayMetafileContext
686 int m_nMaxImageResolution
;
687 bool m_bOnlyLosslessCompression
;
689 bool m_bTransparenciesWereRemoved
;
691 PlayMetafileContext()
692 : m_nMaxImageResolution( 0 )
693 , m_bOnlyLosslessCompression( false )
694 , m_nJPEGQuality( 90 )
695 , m_bTransparenciesWereRemoved( false )
699 void PlayMetafile( const GDIMetaFile
&, const PlayMetafileContext
&, vcl::PDFExtOutDevData
* pDevDat
= nullptr );
701 /* sets the document locale originally passed with the context to a new value
702 * only affects the output if used before calling Emit.
704 void SetDocumentLocale( const css::lang::Locale
& rDocLocale
);
706 /* finishes the file */
710 * Get a list of errors that occurred during processing
711 * this should enable the producer to give feedback about
712 * any anomalies that might have occurred
714 std::set
< ErrorCode
> const & GetErrors() const;
716 // uses 128bit encryption
717 static css::uno::Reference
< css::beans::XMaterialHolder
>
718 InitEncryption( const OUString
& i_rOwnerPassword
,
719 const OUString
& i_rUserPassword
722 /* functions for graphics state */
723 /* flag values: see vcl/outdev.hxx */
724 void Push( PushFlags nFlags
= PushFlags::ALL
);
727 void SetClipRegion();
728 void SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
729 void MoveClipRegion( tools::Long nHorzMove
, tools::Long nVertMove
);
730 void IntersectClipRegion( const tools::Rectangle
& rRect
);
731 void IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
733 void SetLayoutMode( vcl::text::ComplexTextLayoutFlags nMode
);
734 void SetDigitLanguage( LanguageType eLang
);
736 void SetLineColor( const Color
& rColor
);
737 void SetLineColor() { SetLineColor( COL_TRANSPARENT
); }
739 void SetFillColor( const Color
& rColor
);
740 void SetFillColor() { SetFillColor( COL_TRANSPARENT
); }
742 void SetFont( const vcl::Font
& rNewFont
);
743 void SetTextColor( const Color
& rColor
);
744 void SetTextFillColor();
745 void SetTextFillColor( const Color
& rColor
);
747 void SetTextLineColor();
748 void SetTextLineColor( const Color
& rColor
);
749 void SetOverlineColor();
750 void SetOverlineColor( const Color
& rColor
);
751 void SetTextAlign( ::TextAlign eAlign
);
753 void SetMapMode( const MapMode
& rNewMapMode
);
756 /* actual drawing functions */
757 void DrawText( const Point
& rPos
, const OUString
& rText
);
759 void DrawTextLine( const Point
& rPos
, tools::Long nWidth
,
760 FontStrikeout eStrikeout
,
761 FontLineStyle eUnderline
,
762 FontLineStyle eOverline
);
763 void DrawTextArray( const Point
& rStartPt
, const OUString
& rStr
,
764 o3tl::span
<const sal_Int32
> pDXAry
,
767 void DrawStretchText( const Point
& rStartPt
, sal_uLong nWidth
,
768 const OUString
& rStr
,
769 sal_Int32 nIndex
, sal_Int32 nLen
);
770 void DrawText( const tools::Rectangle
& rRect
,
771 const OUString
& rStr
, DrawTextFlags nStyle
);
773 void DrawPixel( const Point
& rPt
, const Color
& rColor
);
774 void DrawPixel( const Point
& rPt
)
775 { DrawPixel( rPt
, COL_TRANSPARENT
); }
777 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
);
778 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
,
779 const LineInfo
& rLineInfo
);
780 void DrawPolyLine( const tools::Polygon
& rPoly
);
781 void DrawPolyLine( const tools::Polygon
& rPoly
,
782 const LineInfo
& rLineInfo
);
783 void DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
);
784 void DrawPolygon( const tools::Polygon
& rPoly
);
785 void DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
);
786 void DrawRect( const tools::Rectangle
& rRect
);
787 void DrawRect( const tools::Rectangle
& rRect
,
788 sal_uLong nHorzRount
, sal_uLong nVertRound
);
789 void DrawEllipse( const tools::Rectangle
& rRect
);
790 void DrawArc( const tools::Rectangle
& rRect
,
791 const Point
& rStartPt
, const Point
& rEndPt
);
792 void DrawPie( const tools::Rectangle
& rRect
,
793 const Point
& rStartPt
, const Point
& rEndPt
);
794 void DrawChord( const tools::Rectangle
& rRect
,
795 const Point
& rStartPt
, const Point
& rEndPt
);
797 void DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
,
798 const Bitmap
& rBitmap
, const Graphic
& rGraphic
);
800 void DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
,
801 const BitmapEx
& rBitmapEx
);
803 void DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
);
804 void DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
806 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
);
808 void DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
);
809 void DrawTransparent( const tools::PolyPolygon
& rPolyPoly
,
810 sal_uInt16 nTransparencePercent
);
812 /** Start a transparency group
814 Drawing operations can be grouped together to acquire a common transparency
815 behaviour; after calling BeginTransparencyGroup all drawing
816 operations will be grouped together into a transparent object.
818 The transparency behaviour is set with one of the EndTransparencyGroup
819 calls and can be either a constant transparency factor or a transparent
820 soft mask in form of an 8 bit gray scale bitmap.
822 It is permissible to nest transparency group.
824 Transparency groups MUST NOT span multiple pages
826 Transparency is a feature introduced in PDF1.4, so transparency group
827 will be ignored if the produced PDF has a lower version. The drawing
828 operations will be emitted normally.
830 void BeginTransparencyGroup();
832 /** End a transparency group with constant transparency factor
834 This ends a transparency group and inserts it on the current page. The
835 coordinates of the group result out of the grouped drawing operations.
838 The bounding rectangle of the group
840 @param nTransparencePercent
841 The transparency factor
843 void EndTransparencyGroup( const tools::Rectangle
& rBoundRect
, sal_uInt16 nTransparencePercent
);
845 /** Insert a JPG encoded image (optionally with mask)
848 a Stream containing the encoded image
851 true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
854 size in pixel of the image
857 where to put the image
860 optional mask; if not empty it must have
861 the same pixel size as the image and
862 be either 1 bit black&white or 8 bit grey
864 void DrawJPGBitmap( SvStream
& rJPGData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const AlphaMask
& rAlphaMask
, const Graphic
& rGraphic
);
866 /** Create a new named destination to be used in a link from another PDF document
869 the name (label) of the bookmark, to be used to jump to
872 target rectangle on page to be displayed if dest is jumped to
875 number of page the dest is on (as returned by NewPage)
876 or -1 in which case the current page is used
879 what dest type to use
882 the destination id (to be used in SetLinkDest) or
883 -1 if page id does not exist
885 sal_Int32
CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
886 /** Create a new destination to be used in a link
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
CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
903 /** Create a new link on a page
906 active rectangle of the link (that is the area that has to be
907 hit to activate the link)
910 number of page the link is on (as returned by NewPage)
911 or -1 in which case the current page is used
914 the link id (to be used in SetLinkDest, SetLinkURL) or
915 -1 if page id does not exist
917 sal_Int32
CreateLink( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
919 /// Creates a screen annotation.
920 sal_Int32
CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
922 /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
924 Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
925 point to this destination. In such cases, a public destination Id will be assigned to the form widget,
926 and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
932 target rectangle on page to be displayed if dest is jumped to
935 number of page the dest is on (as returned by NewPage)
936 or -1 in which case the current page is used
939 what dest type to use
942 the internal destination Id.
944 sal_Int32
RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
947 /** Set the destination for a link
948 will change a URL type link to a dest link if necessary
951 the link to be changed
954 the dest the link shall point to
956 void SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
);
957 /** Set the URL for a link
958 will change a dest type link to a URL type link if necessary
960 the link to be changed
963 the URL the link shall point to.
964 The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
965 service; the result will then appear literally in the PDF file produced
967 void SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
);
969 /// Sets the URL of a linked screen annotation.
970 void SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
);
971 /// Sets the URL of an embedded screen annotation.
972 void SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
);
974 /** Resolve link in logical structure
976 If a link is created after the corresponding visual appearance was drawn
977 it is not possible to set the link id as a property attribute to the
978 link structure item that should be created in tagged PDF around the
979 visual appearance of a link.
981 For this reason an arbitrary id can be given to
982 SetStructureAttributeNumerical at the time the text for
983 the link is drawn. To resolve this arbitrary id again when the actual
984 link annotation is created use SetLinkPropertyID. When Emit
985 finally gets called all LinkAnnotation type structure attributes
986 will be replaced with the correct link id.
988 CAUTION: this technique must be used either for all or none of the links
989 in a document since the link id space and arbitrary property id space
990 could overlap and it would be impossible to resolve whether a Link
991 structure attribute value was arbitrary or already a real id.
994 the link to be mapped
997 the arbitrary id set in a Link structure element to address
998 the link with real id nLinkId
1000 void SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyID
);
1001 /** Create a new outline item
1004 declares the parent of the new item in the outline hierarchy.
1005 An invalid value will result in a new toplevel item.
1008 sets the title text of the item
1011 declares which Dest (created with CreateDest) the outline item
1015 the outline item id of the new item
1017 sal_Int32
CreateOutlineItem( sal_Int32 nParent
, const OUString
& rText
, sal_Int32 nDestID
);
1019 /** Create a new note on a page
1022 active rectangle of the note (that is the area that has to be
1023 hit to popup the annotation)
1026 specifies the contents of the note
1029 number of page the note is on (as returned by NewPage)
1030 or -1 in which case the current page is used
1032 void CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
);
1034 /** begin a new logical structure element
1036 BeginStructureElement/EndStructureElement calls build the logical structure
1037 of the PDF - the basis for tagged PDF. Structural elements are implemented
1038 using marked content tags. Each structural element can contain sub elements
1039 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1040 is build automatically from the Begin/EndStructureElement calls.
1042 A structural element need not be contained on one page; e.g. paragraphs often
1043 run from one page to the next. In this case the corresponding EndStructureElement
1044 must be called while drawing the next page.
1046 BeginStructureElement and EndStructureElement must be called only after
1047 PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1048 current page number is an implicit context parameter for Begin/EndStructureElement.
1050 For pagination artifacts that are not part of the logical structure
1051 of the document (like header, footer or page number) the special
1052 StructElement NonStructElement exists. To place content
1053 outside of the structure tree simply call
1054 BeginStructureElement( NonStructElement ) then draw your
1055 content and then call EndStructureElement(). All children
1056 of a NonStructElement will not be part of the structure.
1057 Nonetheless if you add a child structural element to a
1058 NonStructElement you will still have to call
1059 EndStructureElement for it. Best think of the structure
1062 Note: there is always one structural element in existence without having
1063 called BeginStructureElement; this is the root of the structure
1064 tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1067 denotes what kind of element to begin (e.g. a heading or paragraph)
1070 the specified alias will be used as structure tag. Also an entry in the PDF's
1071 role map will be created mapping alias to regular structure type.
1074 the new structure element's id for use in SetCurrentStructureElement
1076 sal_Int32
BeginStructureElement( enum StructElement eType
, const OUString
& rAlias
);
1077 /** end the current logical structure element
1079 Close the current structure element. The current element's
1080 parent becomes the current structure element again.
1082 @see BeginStructureElement
1084 void EndStructureElement();
1085 /** set the current structure element
1087 For different purposes it may be useful to paint a structure element's
1088 content discontinuously. In that case an already existing structure element
1089 can be appended to by using SetCurrentStructureElement. The
1090 referenced structure element becomes the current structure element with
1091 all consequences: all following structure elements are appended as children
1092 of the current element.
1095 the id of the new current structure element
1097 void SetCurrentStructureElement( sal_Int32 nElement
);
1099 /** set a structure attribute on the current structural element
1101 SetStructureAttribute sets an attribute of the current structural element to a
1102 new value. A consistency check is performed before actually setting the value;
1103 if the check fails, the function returns False and the attribute remains
1107 denotes what attribute to change
1110 the value to set the attribute to
1112 void SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
);
1113 /** set a structure attribute on the current structural element
1115 SetStructureAttributeNumerical sets an attribute of the current structural element
1116 to a new numerical value. A consistency check is performed before actually setting
1117 the value; if the check fails, the function returns False and the attribute
1121 denotes what attribute to change
1124 the value to set the attribute to
1126 void SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
);
1127 /** set the bounding box of a structural element
1129 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1130 attribute can only be applied to Table, Figure,
1131 Form and Formula elements, a call of this function
1132 for other element types will be ignored and the BBox attribute not be set.
1135 the new bounding box for the structural element
1137 void SetStructureBoundingBox( const tools::Rectangle
& rRect
);
1139 /** set the ActualText attribute of a structural element
1141 ActualText contains the Unicode text without layout artifacts that is shown by
1142 a structural element. For example if a line is ended prematurely with a break in
1143 a word and continued on the next line (e.g. "happen-<newline>stance") the
1144 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1147 contains the complete logical text the structural element displays.
1149 void SetActualText( const OUString
& rText
);
1151 /** set the Alt attribute of a strutural element
1153 Alt is s replacement text describing the contents of a structural element. This
1154 is mainly used by accessibility applications; e.g. a screen reader would read
1155 the Alt replacement text for an image to a visually impaired user.
1158 contains the replacement text for the structural element
1160 void SetAlternateText( const OUString
& rText
);
1162 /** Sets the transitional effect to be applied when the current page gets shown.
1165 the kind of effect to be used; use Regular to disable transitional effects
1169 the duration of the transitional effect in milliseconds;
1170 set 0 to disable transitional effects
1173 the page number to apply the effect to; -1 denotes the current page
1175 void SetPageTransition( PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
);
1177 /** create a new form control
1179 This function creates a new form control in the PDF and sets its various
1180 properties. Do not pass an actual AnyWidget as rControlType
1181 will be cast to the type described by the type member.
1184 a descendant of AnyWidget determining the control's properties
1187 the new control's id for reference purposes
1189 sal_Int32
CreateControl( const AnyWidget
& rControlType
);
1191 /** Inserts an additional stream to the PDF file
1193 This function adds an arbitrary stream to the produced PDF file. May be called
1194 any time before Emit(). The stream will be written during
1195 Emit by calling the PDFOutputStream Object's write
1196 method. After the call the PDFOutputStream will be deleted.
1198 All additional streams and their mimetypes will be entered into an array
1199 in the trailer dictionary.
1202 the mimetype of the stream
1205 the interface to the additional stream
1208 void AddStream( const OUString
& rMimeType
, PDFOutputStream
* pStream
);
1210 /// Write rString as a PDF hex string into rBuffer.
1211 static void AppendUnicodeTextString(const OUString
& rString
, OStringBuffer
& rBuffer
);
1213 /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1214 static OString
GetDateTime();
1217 VCL_DLLPUBLIC
void escapeStringXML( const OUString
& rStr
, OUString
&rValue
);
1221 #endif // INCLUDED_VCL_PDFWRITER_HXX
1223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */