From 550a1ea4d615966c545cf522ad4fd4f32f17b318 Mon Sep 17 00:00:00 2001 From: Robbert Lagerweij Date: Fri, 20 Jan 2017 22:00:20 +0100 Subject: [PATCH] eeschema: set title of plotted pdf to sheet title Fixes: lp:1656956 https://bugs.launchpad.net/kicad/+bug/1656956 --- common/common_plotPDF_functions.cpp | 12 ++++++++++-- eeschema/plot_schematic_PDF.cpp | 1 + include/plot_common.h | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp index 8621004cd5..2a7d7e6667 100644 --- a/common/common_plotPDF_functions.cpp +++ b/common/common_plotPDF_functions.cpp @@ -7,7 +7,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Lorenzo Marcantonio, l.marcantonio@logossrl.com - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -692,6 +692,14 @@ bool PDF_PLOTTER::EndPlot() time_t ltime = time( NULL ); strftime( date_buf, 250, "D:%Y%m%d%H%M%S", localtime( <ime ) ); + + if( title.IsEmpty() ) + { + // Windows uses '\' and other platforms ue '/' as sepatator + title = filename.AfterLast('\\'); + title = title.AfterLast('/'); + } + fprintf( outputFile, "<<\n" "/Producer (KiCAD PDF)\n" @@ -701,7 +709,7 @@ bool PDF_PLOTTER::EndPlot() "/Trapped false\n", date_buf, TO_UTF8( creator ), - TO_UTF8( filename ) ); + TO_UTF8( title ) ); fputs( ">>\n", outputFile ); closePdfObject(); diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index fc72b130ef..2d679a8d73 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -62,6 +62,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); plotter->SetColorMode( getModeColor() ); plotter->SetCreator( wxT( "Eeschema-PDF" ) ); + plotter->SetTitle( m_parent->GetTitleBlock().GetTitle() ); wxString msg; wxFileName plotFileName; diff --git a/include/plot_common.h b/include/plot_common.h index f4a5559a6a..e2df2c62a0 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -153,6 +153,11 @@ public: creator = aCreator; } + virtual void SetTitle( const wxString& aTitle ) + { + title = aTitle; + } + /** * Function AddLineToHeader * Add a line to the list of free lines to print at the beginning of the file @@ -539,6 +544,7 @@ protected: // variables used in most of plotters: wxPoint penLastpos; wxString creator; wxString filename; + wxString title; PAGE_INFO pageInfo; /// Paper size in IU - not in mils wxSize paperSize;