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 <sal/types.h>
24 #include <tools/gen.hxx>
25 #include <tools/color.hxx>
26 #include <rtl/strbuf.hxx>
28 #include <vcl/dllapi.h>
29 #include <vcl/vclenum.hxx>
30 #include <vcl/font.hxx>
31 #include <vcl/graphictools.hxx>
32 #include <vcl/outdevstate.hxx>
33 #include <vcl/outdev.hxx>
35 #include <com/sun/star/io/XOutputStream.hpp>
36 #include <com/sun/star/beans/XMaterialHolder.hpp>
37 #include <com/sun/star/security/XCertificate.hpp>
38 #include <com/sun/star/lang/Locale.hpp>
45 namespace vcl
{ class Font
; }
65 class PDFExtOutDevData
;
70 OUString Title
; // optional title for the popup containing the note
71 OUString Contents
; // contents of the note
74 class VCL_DLLPUBLIC PDFOutputStream
77 virtual ~PDFOutputStream();
78 virtual void write( const css::uno::Reference
< css::io::XOutputStream
>& xStream
) = 0;
81 class VCL_DLLPUBLIC PDFWriter
83 std::unique_ptr
<PDFWriterImpl
> xImplementation
;
86 enum CapType
{ capButt
, capRound
, capSquare
};
87 enum JoinType
{ joinMiter
, joinRound
, joinBevel
};
91 double m_fTransparency
;
95 std::vector
< double > m_aDashArray
;
97 ExtLineInfo() : m_fLineWidth( 0.0 ),
98 m_fTransparency( 0.0 ),
100 m_eJoin( joinMiter
),
101 m_fMiterLimit( 10.0 )
105 enum class Orientation
{ Portrait
, Inherit
};
107 // in case the below enum is added PDF_1_6 PDF_1_7, please add them just after PDF_1_5
108 enum class PDFVersion
{ PDF_1_2
, PDF_1_3
, PDF_1_4
, PDF_1_5
, PDF_A_1
};//i59651, PDF/A-1b & -1a, only -1b implemented for now
109 // for the meaning of DestAreaType please look at PDF Reference Manual
110 // version 1.4 section 8.2.1, page 475
111 enum class DestAreaType
{ XYZ
, FitRectangle
};
113 // for a definition of structural element types please refer to
114 // PDF Reference, 3rd ed. section 9.7.4
117 // special element to place outside the structure hierarchy
120 Document
, Part
, Article
, Section
, Division
, BlockQuote
,
121 Caption
, TOC
, TOCI
, Index
,
123 // block level elements
124 Paragraph
, Heading
, H1
, H2
, H3
, H4
, H5
, H6
,
125 List
, ListItem
, LILabel
, LIBody
,
126 Table
, TableRow
, TableHeader
, TableData
,
128 // inline level elements
129 Span
, Quote
, Note
, Reference
, BibEntry
, Code
, Link
,
131 // illustration elements
132 Figure
, Formula
, Form
137 Placement
, WritingMode
, SpaceBefore
, SpaceAfter
, StartIndent
, EndIndent
,
138 TextIndent
, TextAlign
, Width
, Height
, BlockAlign
, InlineAlign
,
139 LineHeight
, BaselineShift
, TextDecorationType
, ListNumbering
,
142 // link destination is an artificial attribute that sets
143 // the link annotation ID of a Link element
144 // further note: since structure attributes can only be
145 // set during content creation, but links can be
146 // created after the fact, it is possible to set
147 // an arbitrary id as structure attribute here. In this
148 // case the arbitrary id has to be passed again when the
149 // actual link annotation is created via SetLinkPropertyID
151 // Language currently sets a LanguageType (see i18nlangtag/lang.h)
152 // which will be internally changed to a corresponding locale
156 enum StructAttributeValue
161 Block
, Inline
, Before
, After
, Start
, End
,
172 // TextDecorationType
173 Underline
, Overline
, LineThrough
,
175 Disc
, Circle
, Square
, Decimal
, UpperRoman
, LowerRoman
, UpperAlpha
, LowerAlpha
178 enum class PageTransition
181 SplitHorizontalInward
, SplitHorizontalOutward
,
182 SplitVerticalInward
, SplitVerticalOutward
,
183 BlindsHorizontal
, BlindsVertical
,
184 BoxInward
, BoxOutward
,
185 WipeLeftToRight
, WipeBottomToTop
, WipeRightToLeft
, WipeTopToBottom
,
191 PushButton
, RadioButton
, CheckBox
, Edit
, ListBox
, ComboBox
, Hierarchy
,
197 // PushButton, RadioButton, CheckBox; Down means selected for
198 // RadioButton and CheckBox
204 // transparent object occurred and was draw opaque because
205 // PDF/A does not allow transparency
206 Warning_Transparency_Omitted_PDFA
,
208 // transparent object occurred but is only supported since
210 Warning_Transparency_Omitted_PDF13
,
212 // a form action was exported that is not suitable for PDF/A
213 // the action was skipped
214 Warning_FormAction_Omitted_PDFA
,
216 // transparent objects were converted to a bitmap in order
217 // to removetransparencies from the output
218 Warning_Transparency_Converted
,
220 // signature generation failed
221 Error_Signature_Failed
,
224 struct VCL_DLLPUBLIC AnyWidget
226 WidgetType Type
; // primitive RTTI
228 OUString Name
; // a distinct name to identify the control
229 OUString Description
;// descriptive text for the control (e.g. for tool tip)
230 OUString Text
; // user text to appear on the control
231 DrawTextFlags TextStyle
; // style flags
233 tools::Rectangle Location
; // describes the area filled by the control
234 bool Border
; // true: widget should have a border, false: no border
235 Color BorderColor
;// COL_TRANSPARENT and Border=true means get color from application settings
236 bool Background
; // true: widget shall draw its background, false: no background
237 Color BackgroundColor
; // COL_TRANSPARENT and Background=true means get color from application settings
238 vcl::Font TextFont
; // an empty font will be replaced by the
239 // appropriate font from the user settings
240 Color TextColor
; // COL_TRANSPARENT will be replaced by the appropriate color from application settings
241 sal_Int32 TabOrder
; // lowest number is first in tab order
243 /* style flags for text are those for OutputDevice::DrawText
245 DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top,
246 DrawTextFlags::VCenter, DrawTextFlags::Bottom,
247 DrawTextFlags::MultiLine, DrawTextFlags::WordBreak
249 if TextStyle is 0, then each control will fill in default values
252 // note: the Name member comprises the field name of the resulting
253 // PDF field names need to be globally unique. Therefore if any
254 // Widget with an already used name is created, the name will be
255 // made unique by adding an underscore ('_') and an ascending number
258 AnyWidget( WidgetType eType
) :
260 TextStyle( DrawTextFlags::NONE
),
263 BorderColor( COL_TRANSPARENT
),
265 BackgroundColor( COL_TRANSPARENT
),
266 TextColor( COL_TRANSPARENT
),
269 virtual ~AnyWidget();
271 WidgetType
getType() const { return Type
; }
273 virtual AnyWidget
* Clone() const = 0;
276 // note that this equals the default compiler-generated copy-ctor, but we want to have it
277 // protected, to only allow sub classes to access it
278 AnyWidget( const AnyWidget
& rSource
)
279 :Type( rSource
.Type
)
280 ,Name( rSource
.Name
)
281 ,Description( rSource
.Description
)
282 ,Text( rSource
.Text
)
283 ,TextStyle( rSource
.TextStyle
)
284 ,ReadOnly( rSource
.ReadOnly
)
285 ,Location( rSource
.Location
)
286 ,Border( rSource
.Border
)
287 ,BorderColor( rSource
.BorderColor
)
288 ,Background( rSource
.Background
)
289 ,BackgroundColor( rSource
.BackgroundColor
)
290 ,TextFont( rSource
.TextFont
)
291 ,TextColor( rSource
.TextColor
)
292 ,TabOrder( rSource
.TabOrder
)
295 AnyWidget
& operator=( const AnyWidget
& ); // never implemented
298 struct PushButtonWidget
: public AnyWidget
300 /* If Dest is set to a valid link destination,
301 Then pressing the button will act as a goto
302 action within the document.
305 An empty URL means this button will reset the form.
307 If URL is not empty and Submit is set, then the URL
308 contained will be set as the URL to submit the
309 form to. In this case the submit method will be
310 either GET if SubmitGet is true or POST if
313 If URL is not empty and Submit is clear, then
314 the URL contained will be interpreted as a
315 hyperlink to be executed on pushing the button.
317 There will be no error checking or any kind of
318 conversion done to the URL parameter execept this:
319 it will be output as 7bit Ascii. The URL
320 will appear literally in the PDF file produced
328 : AnyWidget( vcl::PDFWriter::PushButton
),
329 Dest( -1 ), Submit( false ), SubmitGet( false )
332 virtual AnyWidget
* Clone() const override
334 return new PushButtonWidget( *this );
338 struct CheckBoxWidget
: public AnyWidget
343 : AnyWidget( vcl::PDFWriter::CheckBox
),
347 virtual AnyWidget
* Clone() const override
349 return new CheckBoxWidget( *this );
353 struct RadioButtonWidget
: public AnyWidget
356 sal_Int32 RadioGroup
;
357 OUString OnValue
; // the value of the radio button if it is selected
360 : AnyWidget( vcl::PDFWriter::RadioButton
),
365 virtual AnyWidget
* Clone() const override
367 return new RadioButtonWidget( *this );
369 // radio buttons having the same RadioGroup id comprise one
370 // logical radio button group, that is at most one of the RadioButtons
371 // in a group can be checked at any time
373 // note: a PDF radio button field consists of a named field
374 // containing unnamed checkbox child fields. The name of the
375 // radio button field is taken from the first RadioButtonWidget created
379 struct EditWidget
: public AnyWidget
381 bool MultiLine
; // whether multiple lines are allowed
382 bool Password
; // visible echo off
383 bool FileSelect
; // field is a file selector
384 sal_Int32 MaxLen
; // maximum field length in characters, 0 means unlimited
387 : AnyWidget( vcl::PDFWriter::Edit
),
394 virtual AnyWidget
* Clone() const override
396 return new EditWidget( *this );
400 struct ListBoxWidget
: public AnyWidget
404 std::vector
<OUString
> Entries
;
405 std::vector
<sal_Int32
> SelectedEntries
;
406 // if MultiSelect is false only the first entry of SelectedEntries
407 // will be taken into account. the same is implicit for PDF < 1.4
408 // since multiselect is a 1.4+ feature
411 : AnyWidget( vcl::PDFWriter::ListBox
),
416 virtual AnyWidget
* Clone() const override
418 return new ListBoxWidget( *this );
422 // note: PDF only supports dropdown comboboxes
423 struct ComboBoxWidget
: public AnyWidget
425 std::vector
<OUString
> Entries
;
426 // set the current value in AnyWidget::Text
429 : AnyWidget( vcl::PDFWriter::ComboBox
)
432 virtual AnyWidget
* Clone() const override
434 return new ComboBoxWidget( *this );
438 struct SignatureWidget
: public AnyWidget
441 : AnyWidget( vcl::PDFWriter::Signature
)
444 virtual AnyWidget
* Clone() const override
446 return new SignatureWidget( *this );
450 enum ExportDataFormat
{ HTML
, XML
, FDF
, PDF
};
451 // see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also
452 // These emuns are treated as integer while reading/writing to configuration
453 enum PDFViewerPageMode
459 // These emuns are treated as integer while reading/writing to configuration
468 // These enums are treated as integer while reading/writing to configuration
477 // These emuns are treated as integer while reading/writing to configuration
478 //what default action to generate in a PDF hyperlink to external document/site
479 enum PDFLinkDefaultAction
482 URIActionDestination
,
487 The following structure describes the permissions used in PDF security
489 struct PDFEncryptionProperties
492 //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.
493 bool CanPrintTheDocument
;
494 bool CanModifyTheContent
;
495 bool CanCopyOrExtract
;
497 //for revision 3 (bit 128 security) only
498 bool CanFillInteractive
;
499 bool CanExtractForAccessibility
;
503 // encryption will only happen if EncryptionKey is not empty
504 // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier
505 // if these do not match, behavior is undefined, most likely an invalid PDF will be produced
506 // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from
507 // PDFDocInfo, Owner password and User password used the InitEncryption method which
508 // implements the algorithms described in the PDF reference chapter 3.5: Encryption
509 std::vector
<sal_uInt8
> OValue
;
510 std::vector
<sal_uInt8
> UValue
;
511 std::vector
<sal_uInt8
> EncryptionKey
;
512 std::vector
<sal_uInt8
> DocumentIdentifier
;
514 //permission default set for 128 bit, accessibility only
515 PDFEncryptionProperties() :
516 CanPrintTheDocument ( false ),
517 CanModifyTheContent ( false ),
518 CanCopyOrExtract ( false ),
519 CanAddOrModify ( false ),
520 CanFillInteractive ( false ),
521 CanExtractForAccessibility ( true ),
522 CanAssemble ( false ),
523 CanPrintFull ( false )
528 { return ! OValue
.empty() && ! UValue
.empty() && ! DocumentIdentifier
.empty(); }
533 OUString Title
; // document title
534 OUString Author
; // document author
535 OUString Subject
; // subject
536 OUString Keywords
; // keywords
537 OUString Creator
; // application that created the original document
538 OUString Producer
; // OpenOffice
543 DrawColor
, DrawGreyscale
546 /// Holds all information to be able to fill a PDF signature template.
547 struct VCL_DLLPUBLIC PDFSignContext
549 /// DER-encoded certificate buffer.
550 sal_Int8
* m_pDerEncoded
;
551 /// Length of m_pDerEncoded.
552 sal_Int32 m_nDerEncoded
;
553 /// Bytes before the signature itself.
555 /// Length of m_pByteRange1.
556 sal_Int32 m_nByteRange1
;
557 /// Bytes after the signature itself.
559 /// Length of m_pByteRange2.
560 sal_Int32 m_nByteRange2
;
562 OUString m_aSignPassword
;
563 /// The signature (in PKCS#7 format) is written into this buffer.
564 OStringBuffer
& m_rCMSHexBuffer
;
566 PDFSignContext(OStringBuffer
& rCMSHexBuffer
);
569 struct PDFWriterContext
571 /* must be a valid file: URL usable by osl */
573 /* the URL of the document being exported, used for relative links*/
575 /*if relative to file system should be formed*/
576 bool RelFsys
;//i56629, i49415?, i64585?
577 /*the action to set the PDF hyperlink to*/
578 PDFWriter::PDFLinkDefaultAction DefaultLinkAction
;
579 //convert the .od? target file type in a link to a .pdf type
580 //this is examined before doing anything else
581 bool ConvertOOoTargetToPDFTarget
;
582 //when the file type is .pdf, force the GoToR action
585 /* decides the PDF language level to be produced */
587 /* valid for PDF >= 1.4
588 causes the MarkInfo entry in the document catalog to be set
591 /* determines in which format a form
594 PDFWriter::ExportDataFormat SubmitFormat
;
595 bool AllowDuplicateFieldNames
;
596 /* the following data members are used to customize the PDF viewer
599 /* see 3.6.1 PDF v 1.4 ref*/
600 PDFWriter::PDFViewerPageMode PDFDocumentMode
;
601 PDFWriter::PDFViewerAction PDFDocumentAction
;
602 // in percent, valid only if PDFDocumentAction == ActionZoom
605 /* see 8.6 PDF v 1.4 ref
606 specifies whether to hide the viewer tool
607 bars when the document is active.
609 bool HideViewerToolbar
;
610 bool HideViewerMenubar
;
611 bool HideViewerWindowControls
;
613 bool OpenInFullScreenMode
;
615 bool DisplayPDFDocumentTitle
;
616 PDFPageLayout PageLayout
;
618 // initially visible page in viewer (starting with 0 for first page)
619 sal_Int32 InitialPage
;
620 sal_Int32 OpenBookmarkLevels
; // -1 means all levels
622 PDFWriter::PDFEncryptionProperties Encryption
;
623 PDFWriter::PDFDocInfo DocumentInfo
;
626 OUString SignLocation
;
627 OUString SignPassword
;
629 OUString SignContact
;
630 css::lang::Locale DocumentLocale
; // defines the document default language
631 sal_uInt32 DPIx
, DPIy
; // how to handle MapMode( MapUnit::MapPixel )
632 // 0 here specifies a default handling
633 PDFWriter::ColorMode ColorMode
;
634 css::uno::Reference
< css::security::XCertificate
> SignCertificate
;
636 /// Use reference XObject markup for PDF images.
637 bool UseReferenceXObject
;
640 RelFsys( false ), //i56629, i49415?, i64585?
641 DefaultLinkAction( PDFWriter::URIAction
),
642 ConvertOOoTargetToPDFTarget( false ),
643 ForcePDFAction( false ),
644 Version( PDFWriter::PDFVersion::PDF_1_4
),
646 SubmitFormat( PDFWriter::FDF
),
647 AllowDuplicateFieldNames( false ),
648 PDFDocumentMode( PDFWriter::ModeDefault
),
649 PDFDocumentAction( PDFWriter::ActionDefault
),
651 HideViewerToolbar( false ),
652 HideViewerMenubar( false ),
653 HideViewerWindowControls( false ),
655 OpenInFullScreenMode( false ),
656 CenterWindow( false ),
657 DisplayPDFDocumentTitle( true ),
658 PageLayout( PDFWriter::DefaultLayout
),
659 FirstPageLeft( false ),
661 OpenBookmarkLevels( -1 ),
666 ColorMode( PDFWriter::DrawColor
),
667 SignCertificate( nullptr ),
668 UseReferenceXObject( false )
672 PDFWriter( const PDFWriterContext
& rContext
, const css::uno::Reference
< css::beans::XMaterialHolder
>& );
675 /** Returns an OutputDevice for formatting
676 This Output device is guaranteed to use the same
677 font metrics as the resulting PDF file.
680 the reference output device
682 OutputDevice
* GetReferenceDevice();
684 /** Creates a new page to fill
685 If width and height are not set the page size
686 is inherited from the page tree
688 resets the graphics state: MapMode, Font
689 Colors and other state information MUST
690 be set again or are undefined.
692 void NewPage( double nPageWidth
, double nPageHeight
, Orientation eOrientation
= Orientation::Inherit
);
693 /** Play a metafile like an outputdevice would do
695 struct PlayMetafileContext
697 int m_nMaxImageResolution
;
698 bool m_bOnlyLosslessCompression
;
700 bool m_bTransparenciesWereRemoved
;
702 PlayMetafileContext()
703 : m_nMaxImageResolution( 0 )
704 , m_bOnlyLosslessCompression( false )
705 , m_nJPEGQuality( 90 )
706 , m_bTransparenciesWereRemoved( false )
710 void PlayMetafile( const GDIMetaFile
&, const PlayMetafileContext
&, vcl::PDFExtOutDevData
* pDevDat
= nullptr );
712 /* sets the document locale originally passed with the context to a new value
713 * only affects the output if used before calling Emit.
715 void SetDocumentLocale( const css::lang::Locale
& rDocLocale
);
717 /* finishes the file */
721 * Get a list of errors that occurred during processing
722 * this should enable the producer to give feedback about
723 * any anomalies that might have occurred
725 std::set
< ErrorCode
> GetErrors();
727 static css::uno::Reference
< css::beans::XMaterialHolder
>
728 InitEncryption( const OUString
& i_rOwnerPassword
,
729 const OUString
& i_rUserPassword
,
733 /* functions for graphics state */
734 /* flag values: see vcl/outdev.hxx */
735 void Push( PushFlags nFlags
= PushFlags::ALL
);
738 void SetClipRegion();
739 void SetClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
740 void MoveClipRegion( long nHorzMove
, long nVertMove
);
741 void IntersectClipRegion( const tools::Rectangle
& rRect
);
742 void IntersectClipRegion( const basegfx::B2DPolyPolygon
& rRegion
);
744 void SetLayoutMode( ComplexTextLayoutFlags nMode
);
745 void SetDigitLanguage( LanguageType eLang
);
747 void SetLineColor( const Color
& rColor
);
748 void SetLineColor() { SetLineColor( Color( COL_TRANSPARENT
) ); }
750 void SetFillColor( const Color
& rColor
);
751 void SetFillColor() { SetFillColor( Color( COL_TRANSPARENT
) ); }
753 void SetFont( const vcl::Font
& rNewFont
);
754 void SetTextColor( const Color
& rColor
);
755 void SetTextFillColor();
756 void SetTextFillColor( const Color
& rColor
);
758 void SetTextLineColor();
759 void SetTextLineColor( const Color
& rColor
);
760 void SetOverlineColor();
761 void SetOverlineColor( const Color
& rColor
);
762 void SetTextAlign( ::TextAlign eAlign
);
764 void SetMapMode( const MapMode
& rNewMapMode
);
767 /* actual drawing functions */
768 void DrawText( const Point
& rPos
, const OUString
& rText
);
770 void DrawTextLine( const Point
& rPos
, long nWidth
,
771 FontStrikeout eStrikeout
,
772 FontLineStyle eUnderline
,
773 FontLineStyle eOverline
);
774 void DrawTextArray( const Point
& rStartPt
, const OUString
& rStr
,
778 void DrawStretchText( const Point
& rStartPt
, sal_uLong nWidth
,
779 const OUString
& rStr
,
780 sal_Int32 nIndex
, sal_Int32 nLen
);
781 void DrawText( const tools::Rectangle
& rRect
,
782 const OUString
& rStr
, DrawTextFlags nStyle
);
784 void DrawPixel( const Point
& rPt
, const Color
& rColor
);
785 void DrawPixel( const Point
& rPt
)
786 { DrawPixel( rPt
, Color( COL_TRANSPARENT
) ); }
788 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
);
789 void DrawLine( const Point
& rStartPt
, const Point
& rEndPt
,
790 const LineInfo
& rLineInfo
);
791 void DrawPolyLine( const tools::Polygon
& rPoly
);
792 void DrawPolyLine( const tools::Polygon
& rPoly
,
793 const LineInfo
& rLineInfo
);
794 void DrawPolyLine( const tools::Polygon
& rPoly
, const ExtLineInfo
& rInfo
);
795 void DrawPolygon( const tools::Polygon
& rPoly
);
796 void DrawPolyPolygon( const tools::PolyPolygon
& rPolyPoly
);
797 void DrawRect( const tools::Rectangle
& rRect
);
798 void DrawRect( const tools::Rectangle
& rRect
,
799 sal_uLong nHorzRount
, sal_uLong nVertRound
);
800 void DrawEllipse( const tools::Rectangle
& rRect
);
801 void DrawArc( const tools::Rectangle
& rRect
,
802 const Point
& rStartPt
, const Point
& rEndPt
);
803 void DrawPie( const tools::Rectangle
& rRect
,
804 const Point
& rStartPt
, const Point
& rEndPt
);
805 void DrawChord( const tools::Rectangle
& rRect
,
806 const Point
& rStartPt
, const Point
& rEndPt
);
808 void DrawBitmap( const Point
& rDestPt
, const Size
& rDestSize
,
809 const Bitmap
& rBitmap
, const Graphic
& rGraphic
);
811 void DrawBitmapEx( const Point
& rDestPt
, const Size
& rDestSize
,
812 const BitmapEx
& rBitmapEx
);
814 void DrawGradient( const tools::Rectangle
& rRect
, const Gradient
& rGradient
);
815 void DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
);
817 void DrawHatch( const tools::PolyPolygon
& rPolyPoly
, const Hatch
& rHatch
);
819 void DrawWallpaper( const tools::Rectangle
& rRect
, const Wallpaper
& rWallpaper
);
820 void DrawTransparent( const tools::PolyPolygon
& rPolyPoly
,
821 sal_uInt16 nTransparencePercent
);
823 /** Start a transparency group
825 Drawing operations can be grouped together to acquire a common transparency
826 behaviour; after calling BeginTransparencyGroup all drawing
827 operations will be grouped together into a transparent object.
829 The transparency behaviour is set with one of the EndTransparencyGroup
830 calls and can be either a constant transparency factor or a transparent
831 soft mask in form of an 8 bit gray scale bitmap.
833 It is permissible to nest transparency group.
835 Transparency groups MUST NOT span multiple pages
837 Transparency is a feature introduced in PDF1.4, so transparency group
838 will be ignored if the produced PDF has a lower version. The drawing
839 operations will be emitted normally.
841 void BeginTransparencyGroup();
843 /** End a transparency group with constant transparency factor
845 This ends a transparency group and inserts it on the current page. The
846 coordinates of the group result out of the grouped drawing operations.
849 The bounding rectangle of the group
851 @param nTransparencePercent
852 The transparency factor
854 void EndTransparencyGroup( const tools::Rectangle
& rBoundRect
, sal_uInt16 nTransparencePercent
);
856 /** Insert a JPG encoded image (optionally with mask)
859 a Stream containing the encoded image
862 true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale
865 size in pixel of the image
868 where to put the image
871 optional mask; if not empty it must have
872 the same pixel size as the image and
873 be either 1 bit black&white or 8 bit grey
875 void DrawJPGBitmap( SvStream
& rJPGData
, bool bIsTrueColor
, const Size
& rSrcSizePixel
, const tools::Rectangle
& rTargetArea
, const Bitmap
& rMask
, const Graphic
& rGraphic
);
877 /** Create a new named destination to be used in a link from another PDF document
880 the name (label) of the bookmark, to be used to jump to
883 target rectangle on page to be displayed if dest is jumped to
886 number of page the dest is on (as returned by NewPage)
887 or -1 in which case the current page is used
890 what dest type to use
893 the destination id (to be used in SetLinkDest) or
894 -1 if page id does not exist
896 sal_Int32
CreateNamedDest( const OUString
& sDestName
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
897 /** Create a new destination to be used in a link
900 target rectangle on page to be displayed if dest is jumped to
903 number of page the dest is on (as returned by NewPage)
904 or -1 in which case the current page is used
907 what dest type to use
910 the destination id (to be used in SetLinkDest) or
911 -1 if page id does not exist
913 sal_Int32
CreateDest( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
914 /** Create a new link on a page
917 active rectangle of the link (that is the area that has to be
918 hit to activate the link)
921 number of page the link is on (as returned by NewPage)
922 or -1 in which case the current page is used
925 the link id (to be used in SetLinkDest, SetLinkURL) or
926 -1 if page id does not exist
928 sal_Int32
CreateLink( const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
930 /// Creates a screen annotation.
931 sal_Int32
CreateScreen(const tools::Rectangle
& rRect
, sal_Int32 nPageNr
);
933 /** creates a destination which is not intended to be referred to by a link, but by a public destination Id.
935 Form widgets, for instance, might refer to a destination, without ever actually creating a source link to
936 point to this destination. In such cases, a public destination Id will be assigned to the form widget,
937 and later on, the concrete destination data for this public Id will be registered using RegisterDestReference.
943 target rectangle on page to be displayed if dest is jumped to
946 number of page the dest is on (as returned by NewPage)
947 or -1 in which case the current page is used
950 what dest type to use
953 the internal destination Id.
955 sal_Int32
RegisterDestReference( sal_Int32 nDestId
, const tools::Rectangle
& rRect
, sal_Int32 nPageNr
, DestAreaType eType
);
958 /** Set the destination for a link
959 will change a URL type link to a dest link if necessary
962 the link to be changed
965 the dest the link shall point to
967 void SetLinkDest( sal_Int32 nLinkId
, sal_Int32 nDestId
);
968 /** Set the URL for a link
969 will change a dest type link to an URL type link if necessary
971 the link to be changed
974 the URL the link shall point to.
975 The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer
976 service; the result will then appear literally in the PDF file produced
978 void SetLinkURL( sal_Int32 nLinkId
, const OUString
& rURL
);
980 /// Sets the URL of a linked screen annotation.
981 void SetScreenURL(sal_Int32 nScreenId
, const OUString
& rURL
);
982 /// Sets the URL of an embedded screen annotation.
983 void SetScreenStream(sal_Int32 nScreenId
, const OUString
& rURL
);
985 /** Resolve link in logical structure
987 If a link is created after the corresponding visual appearance was drawn
988 it is not possible to set the link id as a property attribute to the
989 link structure item that should be created in tagged PDF around the
990 visual appearance of a link.
992 For this reason an arbitrary id can be given to
993 SetStructureAttributeNumerical at the time the text for
994 the link is drawn. To resolve this arbitrary id again when the actual
995 link annotation is created use SetLinkPropertyID. When Emit
996 finally gets called all LinkAnnotation type structure attributes
997 will be replaced with the correct link id.
999 CAUTION: this technique must be used either for all or none of the links
1000 in a document since the link id space and arbitrary property id space
1001 could overlap and it would be impossible to resolve whether a Link
1002 structure attribute value was arbitrary or already a real id.
1005 the link to be mapped
1008 the arbitrary id set in a Link structure element to address
1009 the link with real id nLinkId
1011 void SetLinkPropertyID( sal_Int32 nLinkId
, sal_Int32 nPropertyID
);
1012 /** Create a new outline item
1015 declares the parent of the new item in the outline hierarchy.
1016 An invalid value will result in a new toplevel item.
1019 sets the title text of the item
1022 declares which Dest (created with CreateDest) the outline item
1026 the outline item id of the new item
1028 sal_Int32
CreateOutlineItem( sal_Int32 nParent
, const OUString
& rText
, sal_Int32 nDestID
);
1030 /** Create a new note on a page
1033 active rectangle of the note (that is the area that has to be
1034 hit to popup the annotation)
1037 specifies the contents of the note
1040 number of page the note is on (as returned by NewPage)
1041 or -1 in which case the current page is used
1043 void CreateNote( const tools::Rectangle
& rRect
, const PDFNote
& rNote
, sal_Int32 nPageNr
);
1045 /** begin a new logical structure element
1047 BeginStructureElement/EndStructureElement calls build the logical structure
1048 of the PDF - the basis for tagged PDF. Structural elements are implemented
1049 using marked content tags. Each structural element can contain sub elements
1050 (e.g. a section can contain a heading and a paragraph). The structure hierarchy
1051 is build automatically from the Begin/EndStructureElement calls.
1053 A structural element need not be contained on one page; e.g. paragraphs often
1054 run from one page to the next. In this case the corresponding EndStructureElement
1055 must be called while drawing the next page.
1057 BeginStructureElement and EndStructureElement must be called only after
1058 PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The
1059 current page number is an implicit context parameter for Begin/EndStructureElement.
1061 For pagination artifacts that are not part of the logical structure
1062 of the document (like header, footer or page number) the special
1063 StructElement NonStructElement exists. To place content
1064 outside of the structure tree simply call
1065 BeginStructureElement( NonStructElement ) then draw your
1066 content and then call EndStructureElement(). All children
1067 of a NonStructElement will not be part of the structure.
1068 Nonetheless if you add a child structural element to a
1069 NonStructElement you will still have to call
1070 EndStructureElement for it. Best think of the structure
1073 Note: there is always one structural element in existence without having
1074 called BeginStructureElement; this is the root of the structure
1075 tree (called StructTreeRoot). The StructTreeRoot has always the id 0.
1078 denotes what kind of element to begin (e.g. a heading or paragraph)
1081 the specified alias will be used as structure tag. Also an entry in the PDF's
1082 role map will be created mapping alias to regular structure type.
1085 the new structure element's id for use in SetCurrentStructureElement
1087 sal_Int32
BeginStructureElement( enum StructElement eType
, const OUString
& rAlias
);
1088 /** end the current logical structure element
1090 Close the current structure element. The current element's
1091 parent becomes the current structure element again.
1093 @see BeginStructureElement
1095 void EndStructureElement();
1096 /** set the current structure element
1098 For different purposes it may be useful to paint a structure element's
1099 content discontinously. In that case an already existing structure element
1100 can be appended to by using SetCurrentStructureElement. The
1101 refenrenced structure element becomes the current structure element with
1102 all consequences: all following structure elements are appended as children
1103 of the current element.
1106 the id of the new current structure element
1109 True if the current structure element could be set successfully
1110 False if the current structure element could not be changed
1111 (e.g. if the passed element id is invalid)
1113 bool SetCurrentStructureElement( sal_Int32 nElement
);
1115 /** set a structure attribute on the current structural element
1117 SetStructureAttribute sets an attribute of the current structural element to a
1118 new value. A consistency check is performed before actually setting the value;
1119 if the check fails, the function returns False and the attribute remains
1123 denotes what attribute to change
1126 the value to set the attribute to
1129 True if the value was valid and the change has been performed,
1130 False if the attribute or value was invalid; attribute remains unchanged
1132 bool SetStructureAttribute( enum StructAttribute eAttr
, enum StructAttributeValue eVal
);
1133 /** set a structure attribute on the current structural element
1135 SetStructureAttributeNumerical sets an attribute of the current structural element
1136 to a new numerical value. A consistency check is performed before actually setting
1137 the value; if the check fails, the function returns False and the attribute
1141 denotes what attribute to change
1144 the value to set the attribute to
1147 True if the value was valid and the change has been performed,
1148 False if the attribute or value was invalid; attribute remains unchanged
1150 bool SetStructureAttributeNumerical( enum StructAttribute eAttr
, sal_Int32 nValue
);
1151 /** set the bounding box of a structural element
1153 SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox
1154 attribute can only be applied to Table, Figure,
1155 Form and Formula elements, a call of this function
1156 for other element types will be ignored and the BBox attribute not be set.
1159 the new bounding box for the structural element
1161 void SetStructureBoundingBox( const tools::Rectangle
& rRect
);
1163 /** set the ActualText attribute of a structural element
1165 ActualText contains the Unicode text without layout artifacts that is shown by
1166 a structural element. For example if a line is ended prematurely with a break in
1167 a word and continued on the next line (e.g. "happen-<newline>stance") the
1168 corresponding ActualText would contain the unbroken line (e.g. "happenstance").
1171 contains the complete logical text the structural element displays.
1173 void SetActualText( const OUString
& rText
);
1175 /** set the Alt attribute of a strutural element
1177 Alt is s replacement text describing the contents of a structural element. This
1178 is mainly used by accessibility applications; e.g. a screen reader would read
1179 the Alt replacement text for an image to a visually impaired user.
1182 contains the replacement text for the structural element
1184 void SetAlternateText( const OUString
& rText
);
1186 /** Sets the transitional effect to be applied when the current page gets shown.
1189 the kind of effect to be used; use Regular to disable transitional effects
1193 the duration of the transitional effect in milliseconds;
1194 set 0 to disable transitional effects
1197 the page number to apply the effect to; -1 denotes the current page
1199 void SetPageTransition( PageTransition eType
, sal_uInt32 nMilliSec
, sal_Int32 nPageNr
);
1201 /** create a new form control
1203 This function creates a new form control in the PDF and sets its various
1204 properties. Do not pass an actual AnyWidget as rControlType
1205 will be cast to the type described by the type member.
1208 a descendant of AnyWidget determining the control's properties
1211 the new control's id for reference purposes
1213 sal_Int32
CreateControl( const AnyWidget
& rControlType
);
1215 /** Inserts an additional stream to the PDF file
1217 This function adds an arbitrary stream to the produced PDF file. May be called
1218 any time before Emit(). The stream will be written during
1219 Emit by calling the PDFOutputStream Object's write
1220 method. After the call the PDFOutputStream will be deleted.
1222 All additional streams and their mimetypes will be entered into an array
1223 in the trailer dictionary.
1226 the mimetype of the stream
1229 the interface to the additional stream
1232 void AddStream( const OUString
& rMimeType
, PDFOutputStream
* pStream
);
1234 /// Fill a PDF signature template.
1235 static bool Sign(PDFSignContext
& rContext
);
1237 /// Write rString as a PDF hex string into rBuffer.
1238 static void AppendUnicodeTextString(const OUString
& rString
, OStringBuffer
& rBuffer
);
1240 /// Get current date/time in PDF D:YYYYMMDDHHMMSS form.
1241 static OString
GetDateTime();
1246 #endif // INCLUDED_VCL_PDFWRITER_HXX
1248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */