33#include <wx/filename.h>
34#include <wx/mstream.h>
35#include <wx/zstream.h>
36#include <wx/wfstream.h>
37#include <wx/datstrm.h>
38#include <wx/tokenzr.h>
60 bool is_ascii7 =
true;
62 for(
size_t ii = 0; ii < aText.Len(); ii++ )
64 if( aText[ii] >= 0x7F )
75 for(
unsigned ii = 0; ii < aText.Len(); ii++ )
77 unsigned int code = aText[ii];
101 for(
size_t ii = 0; ii < aText.Len(); ii++ )
103 unsigned int code = aText[ii];
105 std::snprintf( buffer,
sizeof( buffer ),
"%4.4X", code );
134 double aScale,
bool aMirror )
161 wxASSERT_MSG( aWidth > 0,
"Plotter called to set negative pen width" );
178 r = ( r * a ) + ( 1 - a );
179 g = ( g * a ) + ( 1 - a );
180 b = ( b * a ) + ( 1 - a );
183 fprintf(
m_workFile,
"%g %g %g rg %g %g %g RG\n", r, g, b, r, g, b );
193 case LINE_STYLE::DASH:
198 case LINE_STYLE::DOT:
203 case LINE_STYLE::DASHDOT:
209 case LINE_STYLE::DASHDOTDOT:
210 fprintf(
m_workFile,
"[%d %d %d %d %d %d] 0 d\n",
226 if( fill == FILL_T::NO_FILL && width <= 0 )
233 if( size.
x == 0 && size.
y == 0 )
245 std::vector<VECTOR2I> cornerList;
247 cornerList.emplace_back( p1.
x, p1.
y );
248 cornerList.emplace_back( p2.
x, p1.
y );
249 cornerList.emplace_back( p2.
x, p2.
y );
250 cornerList.emplace_back( p1.
x, p2.
y );
251 cornerList.emplace_back( p1.
x, p1.
y );
253 PlotPoly( cornerList, fill, width,
nullptr );
263 if( fill == FILL_T::NO_FILL )
266 paintOp = width > 0 ?
'B' :
'f';
268 fprintf(
m_workFile,
"%g %g %g %g re %c\n", p1_dev.
x, p1_dev.
y, p2_dev.
x - p1_dev.
x,
269 p2_dev.
y - p1_dev.
y, paintOp );
277 if( aFill == FILL_T::NO_FILL && width <= 0 )
292 if( aFill == FILL_T::NO_FILL && diametre < width )
294 aFill = FILL_T::FILLED_SHAPE;
300 double magic = radius * 0.551784;
305 "%g %g %g %g %g %g c "
306 "%g %g %g %g %g %g c "
307 "%g %g %g %g %g %g c "
308 "%g %g %g %g %g %g c %c\n",
309 pos_dev.
x - radius, pos_dev.
y,
311 pos_dev.
x - radius, pos_dev.
y + magic,
312 pos_dev.
x - magic, pos_dev.
y + radius,
313 pos_dev.
x, pos_dev.
y + radius,
315 pos_dev.
x + magic, pos_dev.
y + radius,
316 pos_dev.
x + radius, pos_dev.
y + magic,
317 pos_dev.
x + radius, pos_dev.
y,
319 pos_dev.
x + radius, pos_dev.
y - magic,
320 pos_dev.
x + magic, pos_dev.
y - radius,
321 pos_dev.
x, pos_dev.
y - radius,
323 pos_dev.
x - magic, pos_dev.
y - radius,
324 pos_dev.
x - radius, pos_dev.
y - magic,
325 pos_dev.
x - radius, pos_dev.
y,
327 aFill == FILL_T::NO_FILL ?
's' :
'b' );
338 Circle( aCenter, aWidth, FILL_T::FILLED_SHAPE, 0 );
347 EDA_ANGLE endAngle = startAngle - aAngle;
352 if( startAngle > endAngle )
353 std::swap( startAngle, endAngle );
358 start.
x =
KiROUND( aCenter.
x + aRadius * ( -startAngle ).Cos() );
359 start.
y =
KiROUND( aCenter.
y + aRadius * ( -startAngle ).Sin() );
361 fprintf(
m_workFile,
"%g %g m ", pos_dev.
x, pos_dev.
y );
365 end.
x =
KiROUND( aCenter.
x + aRadius * ( -ii ).Cos() );
366 end.
y =
KiROUND( aCenter.
y + aRadius * ( -ii ).Sin() );
368 fprintf(
m_workFile,
"%g %g l ", pos_dev.
x, pos_dev.
y );
371 end.
x =
KiROUND( aCenter.
x + aRadius * ( -endAngle ).Cos() );
372 end.
y =
KiROUND( aCenter.
y + aRadius * ( -endAngle ).Sin() );
374 fprintf(
m_workFile,
"%g %g l ", pos_dev.
x, pos_dev.
y );
378 if( aFill == FILL_T::NO_FILL )
385 fprintf(
m_workFile,
"%g %g l b\n", pos_dev.
x, pos_dev.
y );
395 if( aFill == FILL_T::NO_FILL && aWidth <= 0 )
398 if( aCornerList.size() <= 1 )
406 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
413 if( aFill == FILL_T::NO_FILL )
415 else if( aWidth == 0 )
443 pos_dev.
x, pos_dev.
y,
444 ( plume==
'D' ) ?
'l' :
'm' );
455 VECTOR2I pix_size( aImage.GetWidth(), aImage.GetHeight() );
458 VECTOR2D drawsize( aScaleFactor * pix_size.
x, aScaleFactor * pix_size.
y );
461 VECTOR2I start( aPos.
x - drawsize.
x / 2, aPos.
y + drawsize.
y / 2 );
465 auto findHandleForImage = [&](
const wxImage& aCurrImage ) ->
int
469 if(
image.IsSameAs( aCurrImage ) )
472 if(
image.GetWidth() != aCurrImage.GetWidth() )
475 if(
image.GetHeight() != aCurrImage.GetHeight() )
478 if(
image.GetType() != aCurrImage.GetType() )
481 if(
image.HasAlpha() != aCurrImage.HasAlpha() )
484 if(
image.HasMask() != aCurrImage.HasMask() ||
image.GetMaskRed() != aCurrImage.GetMaskRed()
485 ||
image.GetMaskGreen() != aCurrImage.GetMaskGreen()
486 ||
image.GetMaskBlue() != aCurrImage.GetMaskBlue() )
489 int pixCount =
image.GetWidth() *
image.GetHeight();
491 if( memcmp(
image.GetData(), aCurrImage.GetData(), pixCount * 3 ) != 0 )
494 if(
image.HasAlpha() && memcmp(
image.GetAlpha(), aCurrImage.GetAlpha(), pixCount ) != 0 )
503 int imgHandle = findHandleForImage( aImage );
505 if( imgHandle == -1 )
521 fprintf(
m_workFile,
"q %g 0 0 %g %g %g cm\n",
524 dev_start.
x, dev_start.
y );
526 fprintf(
m_workFile,
"/Im%d Do\n", imgHandle );
573 "<< /Length %d 0 R >>\n"
574 "stream\n", handle + 1 );
579 "<< /Length %d 0 R /Filter /FlateDecode >>\n"
580 "stream\n", handle + 1 );
605 unsigned char *inbuf =
new unsigned char[stream_len];
607 int rc = fread( inbuf, 1, stream_len,
m_workFile );
608 wxASSERT( rc == stream_len );
620 out_count = stream_len;
626 wxMemoryOutputStream memos(
nullptr, std::max( 2000l, stream_len ) ) ;
636 wxZlibOutputStream zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
638 zos.Write( inbuf, stream_len );
641 wxStreamBuffer* sb = memos.GetOutputStreamBuffer();
643 out_count = sb->Tell();
644 fwrite( sb->GetBufferStart(), 1, out_count,
m_outputFile );
679 "%g 0 0 %g 0 0 cm 1 J 1 j 0 0 0 rg 0 0 0 RG %g w\n",
685void WriteImageStream(
const wxImage& aImage, wxDataOutputStream& aOut, wxColor bg,
bool colorMode )
687 int w = aImage.GetWidth();
688 int h = aImage.GetHeight();
690 for(
int y = 0; y < h; y++ )
692 for(
int x = 0; x < w; x++ )
694 unsigned char r = aImage.GetRed( x, y ) & 0xFF;
695 unsigned char g = aImage.GetGreen( x, y ) & 0xFF;
696 unsigned char b = aImage.GetBlue( x, y ) & 0xFF;
698 if( aImage.HasMask() )
700 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen()
701 && b == aImage.GetMaskBlue() )
718 unsigned char grey =
KiROUND( r * 0.2126 + g * 0.7152 + b * 0.0722 );
729 int w = aImage.GetWidth();
730 int h = aImage.GetHeight();
732 if( aImage.HasMask() )
734 for(
int y = 0; y < h; y++ )
736 for(
int x = 0; x < w; x++ )
738 unsigned char a = 255;
739 unsigned char r = aImage.GetRed( x, y );
740 unsigned char g = aImage.GetGreen( x, y );
741 unsigned char b = aImage.GetBlue( x, y );
743 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen()
744 && b == aImage.GetMaskBlue() )
753 else if( aImage.HasAlpha() )
756 aOut.Write8( aImage.GetAlpha(), size );
771 const double PTsPERMIL = 0.072;
774 auto iuToPdfUserSpace =
779 retval.
y = psPaperSize.
y - retval.
y;
784 std::vector<int> hyperlinkHandles;
790 const BOX2I& box = linkPair.first;
791 const wxString& url = linkPair.second;
798 userSpaceBox.
SetEnd( topRight );
807 const BOX2I& box = menuPair.first;
808 const std::vector<wxString>& urls = menuPair.second;
815 userSpaceBox.
SetEnd( topRight );
822 int hyperLinkArrayHandle = -1;
825 if( hyperlinkHandles.size() > 0 )
832 for(
int handle : hyperlinkHandles )
855 " /ProcSet [/PDF /Text /ImageC /ImageB]\n"
857 " /XObject %d 0 R >>\n"
858 "/MediaBox [0 0 %g %g]\n"
859 "/Contents %d 0 R\n",
867 if( hyperlinkHandles.size() > 0 )
868 fprintf(
m_outputFile,
"/Annots %d 0 R", hyperLinkArrayHandle );
877 wxString pageOutlineName = wxEmptyString;
881 pageOutlineName = wxString::Format(
_(
"Page %s" ),
m_pageNumbers.back() );
899 for(
const std::pair<BOX2I, wxString>& bookmarkPair : groupVector )
901 const BOX2I& box = bookmarkPair.first;
902 const wxString& ref = bookmarkPair.second;
907 actionHandle =
emitGoToAction( pageHandle, bottomLeft, topRight );
912 std::sort( groupOutlineNode->
children.begin(), groupOutlineNode->
children.end(),
915 return a->title < b->title;
928 return StartPlot( aPageNumber, wxEmptyString );
979 "<</S /GoTo /D [%d 0 R /FitR %d %d %d %d]\n"
981 aPageHandle, aBottomLeft.
x, aBottomLeft.
y, aTopRight.
x, aTopRight.
y );
995 "<</S /GoTo /D [%d 0 R /Fit]\n"
1001 return actionHandle;
1009 int prevHandle = -1;
1010 int nextHandle = -1;
1012 for( std::vector<OUTLINE_NODE*>::iterator it = node->
children.begin();
1015 if( it >= node->
children.end() - 1 )
1021 nextHandle = ( *( it + 1 ) )->entryHandle;
1026 prevHandle = ( *it )->entryHandle;
1030 if( parentHandle != -1 )
1070 const wxString& aTitle )
1091 "<< /Type /Outlines\n"
1125 {
"/Helvetica",
"/KicadFont", 0 },
1126 {
"/Helvetica-Oblique",
"/KicadFontI", 0 },
1127 {
"/Helvetica-Bold",
"/KicadFontB", 0 },
1128 {
"/Helvetica-BoldOblique",
"/KicadFontBI", 0 }
1134 for(
int i = 0; i < 4; i++ )
1140 " /Subtype /Type1\n"
1143 " /Encoding /WinAnsiEncoding\n"
1145 fontdefs[i].psname );
1153 for(
int i = 0; i < 4; i++ )
1156 fontdefs[i].rsname, fontdefs[i].font_handle );
1168 fprintf(
m_outputFile,
" /Im%d %d 0 R\n", imgHandle, imgHandle );
1189 "/BitsPerComponent 8\n"
1193 "/Filter /FlateDecode\n"
1198 if( smaskHandle != -1 )
1199 fprintf(
m_outputFile,
"/SMask %d 0 R\n", smaskHandle );
1207 wxFFileOutputStream ffos( outputFFile );
1208 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1209 wxDataOutputStream dos( zos );
1215 long imgStreamSize = ftell(
m_outputFile ) - imgStreamStart;
1224 if( smaskHandle != -1 )
1234 "/BitsPerComponent 8\n"
1235 "/ColorSpace /DeviceGray\n"
1239 "/Filter /FlateDecode\n"
1241 image.GetWidth(),
image.GetHeight(), smaskLenHandle );
1248 wxFFileOutputStream ffos( outputFFile );
1249 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1250 wxDataOutputStream dos( zos );
1255 long smaskStreamSize = ftell(
m_outputFile ) - smaskStreamStart;
1261 fprintf(
m_outputFile,
"%u\n", (
unsigned) smaskStreamSize );
1265 outputFFile.Detach();
1270 const BOX2D& box = linkPair.first;
1271 const wxString& url = linkPair.second;
1279 "/Rect [%g %g %g %g]\n"
1280 "/Border [16 16 0]\n",
1283 wxString pageNumber;
1284 bool pageFound =
false;
1293 "/Dest [%d 0 R /FitB]\n"
1305 fprintf(
m_outputFile,
"/A << /Type /Action /S /NOP >>\n"
1312 "/A << /Type /Action /S /URI /URI %s >>\n"
1322 const BOX2D& box = menuPair.first;
1323 const std::vector<wxString>& urls = menuPair.second;
1324 wxString js = wxT(
"ShM([\n" );
1326 for(
const wxString& url : urls )
1328 if( url.StartsWith(
"!" ) )
1330 wxString
property = url.AfterFirst(
'!' );
1332 if( property.Find(
"http:" ) >= 0 )
1334 wxString href =
property.substr( property.Find(
"http:" ) );
1336 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1340 else if( property.Find(
"https:" ) >= 0 )
1342 wxString href =
property.substr( property.Find(
"https:" ) );
1344 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1350 js += wxString::Format( wxT(
"[\"%s\"],\n" ),
1354 else if( url.StartsWith(
"#" ) )
1356 wxString pageNumber = url.AfterFirst(
'#' );
1362 wxString menuText = wxString::Format(
_(
"Show Page %s" ), pageNumber );
1364 js += wxString::Format( wxT(
"[\"%s\", \"#%d\"],\n" ),
1366 static_cast<int>( ii ) );
1371 else if( url.StartsWith(
"http:" ) || url.StartsWith(
"https:" ) )
1373 wxString menuText = wxString::Format(
_(
"Open %s" ), url );
1375 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1389 "/Rect [%g %g %g %g]\n"
1390 "/Border [16 16 0]\n",
1394 "/A << /Type /Action /S /JavaScript /JS %s >>\n"
1405function ShM(aEntries) {
1407 for (var i in aEntries) {
1409 cName: aEntries[i][0],
1410 cReturn: aEntries[i][1]
1414 var cChoice = app.popUpMenuEx.apply(app, aParams);
1415 if (cChoice != null && cChoice.substring(0, 1) == '#') this.pageNum = parseInt(cChoice.slice(1));
1416 else if (cChoice != null && cChoice.substring(0, 4) == 'http') app.launchURL(cChoice);
1423 " [ (JSInit) << /Type /Action /S /JavaScript /JS %s >> ]\n"
1452 time_t ltime = time(
nullptr );
1453 strftime( date_buf, 250,
"D:%Y%m%d%H%M%S", localtime( <ime ) );
1464 "/Producer (KiCad PDF)\n"
1465 "/CreationDate (%s)\n"
1485 if( outlineHandle > 0 )
1492 "/PageMode /UseOutlines\n"
1493 "/Outlines %d 0 R\n"
1495 "/PageLayout /SinglePage\n"
1508 "/PageMode /UseNone\n"
1509 "/PageLayout /SinglePage\n"
1523 "0000000000 65535 f \n", (
long)
m_xrefTable.size() );
1525 for(
unsigned i = 1; i <
m_xrefTable.size(); i++ )
1533 "<< /Size %lu /Root %d 0 R /Info %d 0 R >>\n"
1537 (
unsigned long)
m_xrefTable.size(), catalogHandle, infoDictHandle, xref_start );
1548 const wxString& aText,
1556 bool aMultilineAllowed,
1562 if( aSize.
x == 0 || aSize.
y == 0 )
1570 const char *fontname = aItalic ? ( aBold ?
"/KicadFontBI" :
"/KicadFontI" )
1571 : ( aBold ?
"/KicadFontB" :
"/KicadFont" );
1574 double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f;
1575 double wideningFactor, heightFactor;
1578 bool textMirrored = aSize.
x < 0;
1581 aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d,
1582 &ctm_e, &ctm_f, &heightFactor );
1587 wxStringTokenizer str_tok( aText,
" ", wxTOKEN_RET_DELIMS );
1615 while( str_tok.HasMoreTokens() )
1617 wxString word = str_tok.GetNextToken();
1621 &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
1626 aBold, aItalic, aFontMetrics ).
x, 0 );
1635 if( word.Trim(
false ).Trim(
true ).empty() )
1642 fprintf(
m_workFile,
"q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ",
1643 ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
1644 fontname, heightFactor,
render_mode, wideningFactor * 100 );
1647 fprintf(
m_workFile,
"%s Tj ET\n", txt_pdf.c_str() );
1653 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
1654 aBold, aMultilineAllowed, aFont, aFontMetrics );
1660 const wxString& aText,
1669 if( size.
x == 0 || size.
y == 0 )
1694 const wxString &aGroupName )
1697 m_bookmarksInPage[aGroupName].push_back( std::make_pair( aLocation, aSymbolReference ) );
void WriteImageSMaskStream(const wxImage &aImage, wxDataOutputStream &aOut)
void WriteImageStream(const wxImage &aImage, wxDataOutputStream &aOut, wxColor bg, bool colorMode)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr const Vec & GetPosition() const
constexpr const Vec GetEnd() const
constexpr void SetOrigin(const Vec &pos)
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr void SetEnd(coord_type x, coord_type y)
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
static bool IsGotoPageHref(const wxString &aHref, wxString *aDestination=nullptr)
Check if aHref is a valid internal hyperlink.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
A color representation with 4 components: red, green, blue, alpha.
wxColour ToColour() const
int GetDefaultPenWidth() const
virtual const COLOR4D & GetBackgroundColor() const =0
Return current background color settings.
const VECTOR2D & GetSizeMils() const
std::vector< int > m_pageHandles
Handles to the page objects.
FILE * m_workFile
Temporary file to construct the stream before zipping.
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString)
Start a new page in the PDF document.
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
void emitOutlineNode(OUTLINE_NODE *aNode, int aParentHandle, int aNextNode, int aPrevNode)
Emits a outline item object and recurses into any children.
std::map< int, wxImage > m_imageHandles
int emitOutline()
Starts emitting the outline object.
virtual bool EndPlot() override
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Polygon plotting for PDF.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Pen width setting for PDF.
int m_streamLengthHandle
Handle to the deferred stream length.
void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor) override
PDF images are handles as inline, not XObject streams...
int m_jsNamesHandle
Handle for Names dictionary with JS.
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
PDF supports dashed lines.
void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs) override
Create a clickable hyperlink menu with a rectangular click area.
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
int m_fontResDictHandle
Font resource dictionary.
virtual void emitSetRGBColor(double r, double g, double b, double a) override
PDF supports colors fully.
int startPdfStream(int handle=-1)
Starts a PDF stream (for the page).
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Rectangles in PDF.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH) override
The PDF engine can't directly plot arcs so we use polygonization.
std::map< int, std::pair< BOX2D, wxString > > m_hyperlinkHandles
int m_pageTreeHandle
Handle to the root of the page tree object.
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
int emitGoToAction(int aPageHandle, const VECTOR2I &aBottomLeft, const VECTOR2I &aTopRight)
Emits an action object that instructs a goto coordinates on a page.
void closePdfStream()
Finish the current PDF stream (writes the deferred length, too)
void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString) override
Create a bookmark to a symbol.
std::vector< long > m_xrefTable
The PDF xref offset table.
void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL) override
Create a clickable hyperlink with a rectangular click area.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH) override
Circle drawing for PDF.
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
std::map< wxString, std::vector< std::pair< BOX2I, wxString > > > m_bookmarksInPage
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
int startPdfObject(int handle=-1)
Open a new PDF object and returns the handle if the parameter is -1.
OUTLINE_NODE * addOutlineNode(OUTLINE_NODE *aParent, int aActionHandle, const wxString &aTitle)
Adds a new outline node entry.
int m_imgResDictHandle
Image resource dictionary.
std::string encodeStringForPlotter(const wxString &aUnicode) override
convert a wxString unicode string to a char string compatible with the accepted string PDF format (co...
std::vector< wxString > m_pageNumbers
List of loaded hyperlinks in current page.
int allocPdfObject()
Allocate a new handle in the table of the PDF object.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not insid...
std::map< int, std::pair< BOX2D, std::vector< wxString > > > m_hyperlinkMenuHandles
int m_pageStreamHandle
Handle of the page content object.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
std::vector< std::pair< BOX2I, wxString > > m_hyperlinksInPage
std::unique_ptr< OUTLINE_NODE > m_outlineRoot
Root outline node.
std::vector< std::pair< BOX2I, std::vector< wxString > > > m_hyperlinkMenusInPage
Handles for all the hyperlink objects that will be deferred.
void closePdfObject()
Close the current PDF object.
int m_totalOutlineNodes
Total number of outline nodes.
double GetDotMarkLenIU(int aLineWidth) const
double GetDashGapLenIU(int aLineWidth) const
static const int USE_DEFAULT_LINE_WIDTH
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
FILE * m_outputFile
Output file.
static const int DO_NOT_SET_LINE_WIDTH
RENDER_SETTINGS * m_renderSettings
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aPenWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr)
Draw text with the plotter.
double GetDashMarkLenIU(int aLineWidth) const
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: the PSLIKE computes the rgb values,...
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
void computeTextParameters(const VECTOR2I &aPos, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, bool aMirror, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, double *wideningFactor, double *ctm_a, double *ctm_b, double *ctm_c, double *ctm_d, double *ctm_e, double *ctm_f, double *heightFactor)
This is the core for postscript/PDF text alignment.
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
void ignore_unused(const T &)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Plotting engines similar to ps (PostScript, Gerber, svg)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
LINE_STYLE
Dashed line types.
wxString title
Title of outline node.
std::vector< OUTLINE_NODE * > children
Ordered list of children.
int entryHandle
Allocated handle for this outline entry.
OUTLINE_NODE * AddChild(int aActionHandle, const wxString &aTitle, int aEntryHandle)
int actionHandle
Handle to action.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D