Debian Codegraph @

podofo/test/WatermarkTest/WatermarkTest.cpp

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominik Seichter *
3 * [email protected] *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #include "../PdfTest.h"
22 #include <cstdio>
23
24 using namespace PoDoFo;
25
26 void WatermarkFile( const char* pszInFilename, const char* pszOutFilename )
27 {
28 printf("Running watermark test\n");
29
30 PdfMemDocument doc( pszInFilename );
31 PdfPainter painter;
32 PdfPage* pPage;
33 PdfRect rect;
34 int i;
35
36 for(i=0;i<doc.GetPageCount();i++)
37 {
38 pPage = doc.GetPage( i );
39 if( !pPage )
40 {
41 PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
42 }
43
44 rect = pPage->GetPageSize();
45
46 painter.SetPage( pPage );
47 painter.SetStrokingColor( 1.0, 0.0, 0.0 );
48 painter.SetStrokeWidth( 5 );
49 painter.DrawLine( 0.0, 0.0, rect.GetWidth(), rect.GetHeight() );
50 painter.DrawLine( 0, rect.GetHeight(), rect.GetWidth(), 0.0 );
51 painter.FinishPage();
52 }
53
54 printf("writing document back\n");
55 doc.Write( pszOutFilename );
56 }
57
58 int main( int argc, char* argv[] )
59 {
60 if( argc != 3 )
61 {
62 printf("Usage: WatermarkTest input_filename output_filename\n");
63 return 0;
64 }
65
66 printf("This test tests the PdfWriter and PdfDocument classes.\n");
67 printf("It opens an existing PDF and draws an X on each page.\n");
68 printf("---\n");
69
70 printf("Watermarking....\n");
71
72 try {
73 WatermarkFile( argv[1], argv[2] );
74 }
75 catch( PdfError & e )
76 {
77 e.PrintErrorMsg();
78 return e.GetError();
79 }
80
81 return 0;
82 }