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>
61 bool is_ascii7 =
true;
63 for(
size_t ii = 0; ii < aText.Len(); ii++ )
65 if( aText[ii] >= 0x7F )
76 for(
unsigned ii = 0; ii < aText.Len(); ii++ )
78 unsigned int code = aText[ii];
102 for(
size_t ii = 0; ii < aText.Len(); ii++ )
104 unsigned int code = aText[ii];
106 std::snprintf( buffer,
sizeof( buffer ),
"%4.4X", code );
135 double aScale,
bool aMirror )
162 wxASSERT_MSG( aWidth > 0,
"Plotter called to set negative pen width" );
179 r = ( r * a ) + ( 1 - a );
180 g = ( g * a ) + ( 1 - a );
181 b = ( b * a ) + ( 1 - a );
184 fprintf(
m_workFile,
"%g %g %g rg %g %g %g RG\n", r, g, b, r, g, b );
194 case LINE_STYLE::DASH:
199 case LINE_STYLE::DOT:
204 case LINE_STYLE::DASHDOT:
210 case LINE_STYLE::DASHDOTDOT:
211 fprintf(
m_workFile,
"[%d %d %d %d %d %d] 0 d\n",
227 if( fill == FILL_T::NO_FILL && width <= 0 )
234 if( size.
x == 0 && size.
y == 0 )
246 std::vector<VECTOR2I> cornerList;
248 cornerList.emplace_back( p1.
x, p1.
y );
249 cornerList.emplace_back( p2.
x, p1.
y );
250 cornerList.emplace_back( p2.
x, p2.
y );
251 cornerList.emplace_back( p1.
x, p2.
y );
252 cornerList.emplace_back( p1.
x, p1.
y );
254 PlotPoly( cornerList, fill, width,
nullptr );
264 if( fill == FILL_T::NO_FILL )
267 paintOp = width > 0 ?
'B' :
'f';
269 fprintf(
m_workFile,
"%g %g %g %g re %c\n", p1_dev.
x, p1_dev.
y, p2_dev.
x - p1_dev.
x,
270 p2_dev.
y - p1_dev.
y, paintOp );
278 if( aFill == FILL_T::NO_FILL && width <= 0 )
293 if( aFill == FILL_T::NO_FILL && diametre < width )
295 aFill = FILL_T::FILLED_SHAPE;
301 double magic = radius * 0.551784;
306 "%g %g %g %g %g %g c "
307 "%g %g %g %g %g %g c "
308 "%g %g %g %g %g %g c "
309 "%g %g %g %g %g %g c %c\n",
310 pos_dev.
x - radius, pos_dev.
y,
312 pos_dev.
x - radius, pos_dev.
y + magic,
313 pos_dev.
x - magic, pos_dev.
y + radius,
314 pos_dev.
x, pos_dev.
y + radius,
316 pos_dev.
x + magic, pos_dev.
y + radius,
317 pos_dev.
x + radius, pos_dev.
y + magic,
318 pos_dev.
x + radius, pos_dev.
y,
320 pos_dev.
x + radius, pos_dev.
y - magic,
321 pos_dev.
x + magic, pos_dev.
y - radius,
322 pos_dev.
x, pos_dev.
y - radius,
324 pos_dev.
x - magic, pos_dev.
y - radius,
325 pos_dev.
x - radius, pos_dev.
y - magic,
326 pos_dev.
x - radius, pos_dev.
y,
328 aFill == FILL_T::NO_FILL ?
's' :
'b' );
339 Circle( aCenter, aWidth, FILL_T::FILLED_SHAPE, 0 );
348 EDA_ANGLE endAngle = startAngle - aAngle;
353 if( startAngle > endAngle )
354 std::swap( startAngle, endAngle );
359 start.
x =
KiROUND( aCenter.
x + aRadius * ( -startAngle ).Cos() );
360 start.
y =
KiROUND( aCenter.
y + aRadius * ( -startAngle ).Sin() );
362 fprintf(
m_workFile,
"%g %g m ", pos_dev.
x, pos_dev.
y );
366 end.
x =
KiROUND( aCenter.
x + aRadius * ( -ii ).Cos() );
367 end.
y =
KiROUND( aCenter.
y + aRadius * ( -ii ).Sin() );
369 fprintf(
m_workFile,
"%g %g l ", pos_dev.
x, pos_dev.
y );
372 end.
x =
KiROUND( aCenter.
x + aRadius * ( -endAngle ).Cos() );
373 end.
y =
KiROUND( aCenter.
y + aRadius * ( -endAngle ).Sin() );
375 fprintf(
m_workFile,
"%g %g l ", pos_dev.
x, pos_dev.
y );
379 if( aFill == FILL_T::NO_FILL )
386 fprintf(
m_workFile,
"%g %g l b\n", pos_dev.
x, pos_dev.
y );
396 if( aFill == FILL_T::NO_FILL && aWidth <= 0 )
399 if( aCornerList.size() <= 1 )
407 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
414 if( aFill == FILL_T::NO_FILL )
416 else if( aWidth == 0 )
444 pos_dev.
x, pos_dev.
y,
445 ( plume==
'D' ) ?
'l' :
'm' );
456 VECTOR2I pix_size( aImage.GetWidth(), aImage.GetHeight() );
459 VECTOR2D drawsize( aScaleFactor * pix_size.
x, aScaleFactor * pix_size.
y );
462 VECTOR2I start( aPos.
x - drawsize.
x / 2, aPos.
y + drawsize.
y / 2 );
466 auto findHandleForImage = [&](
const wxImage& aCurrImage ) ->
int
470 if(
image.IsSameAs( aCurrImage ) )
473 if(
image.GetWidth() != aCurrImage.GetWidth() )
476 if(
image.GetHeight() != aCurrImage.GetHeight() )
479 if(
image.GetType() != aCurrImage.GetType() )
482 if(
image.HasAlpha() != aCurrImage.HasAlpha() )
485 if(
image.HasMask() != aCurrImage.HasMask() ||
image.GetMaskRed() != aCurrImage.GetMaskRed()
486 ||
image.GetMaskGreen() != aCurrImage.GetMaskGreen()
487 ||
image.GetMaskBlue() != aCurrImage.GetMaskBlue() )
490 int pixCount =
image.GetWidth() *
image.GetHeight();
492 if( memcmp(
image.GetData(), aCurrImage.GetData(), pixCount * 3 ) != 0 )
495 if(
image.HasAlpha() && memcmp(
image.GetAlpha(), aCurrImage.GetAlpha(), pixCount ) != 0 )
504 int imgHandle = findHandleForImage( aImage );
506 if( imgHandle == -1 )
522 fprintf(
m_workFile,
"q %g 0 0 %g %g %g cm\n",
525 dev_start.
x, dev_start.
y );
527 fprintf(
m_workFile,
"/Im%d Do\n", imgHandle );
574 "<< /Length %d 0 R >>\n"
575 "stream\n", handle + 1 );
580 "<< /Length %d 0 R /Filter /FlateDecode >>\n"
581 "stream\n", handle + 1 );
606 unsigned char *inbuf =
new unsigned char[stream_len];
608 int rc = fread( inbuf, 1, stream_len,
m_workFile );
609 wxASSERT( rc == stream_len );
621 out_count = stream_len;
627 wxMemoryOutputStream memos(
nullptr, std::max( 2000l, stream_len ) ) ;
637 wxZlibOutputStream zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
639 zos.Write( inbuf, stream_len );
642 wxStreamBuffer* sb = memos.GetOutputStreamBuffer();
644 out_count = sb->Tell();
645 fwrite( sb->GetBufferStart(), 1, out_count,
m_outputFile );
680 "%g 0 0 %g 0 0 cm 1 J 1 j 0 0 0 rg 0 0 0 RG %g w\n",
686void WriteImageStream(
const wxImage& aImage, wxDataOutputStream& aOut, wxColor bg,
bool colorMode )
688 int w = aImage.GetWidth();
689 int h = aImage.GetHeight();
691 for(
int y = 0; y < h; y++ )
693 for(
int x = 0; x < w; x++ )
695 unsigned char r = aImage.GetRed( x, y ) & 0xFF;
696 unsigned char g = aImage.GetGreen( x, y ) & 0xFF;
697 unsigned char b = aImage.GetBlue( x, y ) & 0xFF;
699 if( aImage.HasMask() )
701 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen()
702 && b == aImage.GetMaskBlue() )
719 unsigned char grey =
KiROUND( r * 0.2126 + g * 0.7152 + b * 0.0722 );
730 int w = aImage.GetWidth();
731 int h = aImage.GetHeight();
733 if( aImage.HasMask() )
735 for(
int y = 0; y < h; y++ )
737 for(
int x = 0; x < w; x++ )
739 unsigned char a = 255;
740 unsigned char r = aImage.GetRed( x, y );
741 unsigned char g = aImage.GetGreen( x, y );
742 unsigned char b = aImage.GetBlue( x, y );
744 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen()
745 && b == aImage.GetMaskBlue() )
754 else if( aImage.HasAlpha() )
757 aOut.Write8( aImage.GetAlpha(), size );
772 const double PTsPERMIL = 0.072;
775 auto iuToPdfUserSpace =
780 retval.
y = psPaperSize.
y - retval.
y;
785 std::vector<int> hyperlinkHandles;
791 const BOX2I& box = linkPair.first;
792 const wxString& url = linkPair.second;
799 userSpaceBox.
SetEnd( topRight );
808 const BOX2I& box = menuPair.first;
809 const std::vector<wxString>& urls = menuPair.second;
816 userSpaceBox.
SetEnd( topRight );
823 int hyperLinkArrayHandle = -1;
826 if( hyperlinkHandles.size() > 0 )
833 for(
int handle : hyperlinkHandles )
856 " /ProcSet [/PDF /Text /ImageC /ImageB]\n"
858 " /XObject %d 0 R >>\n"
859 "/MediaBox [0 0 %g %g]\n"
860 "/Contents %d 0 R\n",
868 if( hyperlinkHandles.size() > 0 )
869 fprintf(
m_outputFile,
"/Annots %d 0 R", hyperLinkArrayHandle );
878 wxString pageOutlineName = wxEmptyString;
882 pageOutlineName = wxString::Format(
_(
"Page %s" ),
m_pageNumbers.back() );
900 for(
const std::pair<BOX2I, wxString>& bookmarkPair : groupVector )
902 const BOX2I& box = bookmarkPair.first;
903 const wxString& ref = bookmarkPair.second;
908 actionHandle =
emitGoToAction( pageHandle, bottomLeft, topRight );
913 std::sort( groupOutlineNode->
children.begin(), groupOutlineNode->
children.end(),
916 return a->title < b->title;
929 return StartPlot( aPageNumber, wxEmptyString );
980 "<</S /GoTo /D [%d 0 R /FitR %d %d %d %d]\n"
982 aPageHandle, aBottomLeft.
x, aBottomLeft.
y, aTopRight.
x, aTopRight.
y );
996 "<</S /GoTo /D [%d 0 R /Fit]\n"
1002 return actionHandle;
1010 int prevHandle = -1;
1011 int nextHandle = -1;
1013 for( std::vector<OUTLINE_NODE*>::iterator it = node->
children.begin();
1016 if( it >= node->
children.end() - 1 )
1022 nextHandle = ( *( it + 1 ) )->entryHandle;
1027 prevHandle = ( *it )->entryHandle;
1031 if( parentHandle != -1 )
1071 const wxString& aTitle )
1092 "<< /Type /Outlines\n"
1128 {
"/Helvetica",
"/KicadFont", 0 },
1129 {
"/Helvetica-Oblique",
"/KicadFontI", 0 },
1130 {
"/Helvetica-Bold",
"/KicadFontB", 0 },
1131 {
"/Helvetica-BoldOblique",
"/KicadFontBI", 0 }
1137 for(
int i = 0; i < 4; i++ )
1143 " /Subtype /Type1\n"
1146 " /Encoding /WinAnsiEncoding\n"
1148 fontdefs[i].psname );
1156 for(
int i = 0; i < 4; i++ )
1159 fontdefs[i].rsname, fontdefs[i].font_handle );
1171 fprintf(
m_outputFile,
" /Im%d %d 0 R\n", imgHandle, imgHandle );
1192 "/BitsPerComponent 8\n"
1196 "/Filter /FlateDecode\n"
1201 if( smaskHandle != -1 )
1202 fprintf(
m_outputFile,
"/SMask %d 0 R\n", smaskHandle );
1210 wxFFileOutputStream ffos( outputFFile );
1211 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1212 wxDataOutputStream dos( zos );
1218 long imgStreamSize = ftell(
m_outputFile ) - imgStreamStart;
1227 if( smaskHandle != -1 )
1237 "/BitsPerComponent 8\n"
1238 "/ColorSpace /DeviceGray\n"
1242 "/Filter /FlateDecode\n"
1244 image.GetWidth(),
image.GetHeight(), smaskLenHandle );
1251 wxFFileOutputStream ffos( outputFFile );
1252 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1253 wxDataOutputStream dos( zos );
1258 long smaskStreamSize = ftell(
m_outputFile ) - smaskStreamStart;
1264 fprintf(
m_outputFile,
"%u\n", (
unsigned) smaskStreamSize );
1268 outputFFile.Detach();
1273 const BOX2D& box = linkPair.first;
1274 const wxString& url = linkPair.second;
1282 "/Rect [%g %g %g %g]\n"
1283 "/Border [16 16 0]\n",
1286 wxString pageNumber;
1287 bool pageFound =
false;
1296 "/Dest [%d 0 R /FitB]\n"
1308 fprintf(
m_outputFile,
"/A << /Type /Action /S /NOP >>\n"
1315 "/A << /Type /Action /S /URI /URI %s >>\n"
1325 const BOX2D& box = menuPair.first;
1326 const std::vector<wxString>& urls = menuPair.second;
1327 wxString js = wxT(
"ShM([\n" );
1329 for(
const wxString& url : urls )
1331 if( url.StartsWith(
"!" ) )
1333 wxString
property = url.AfterFirst(
'!' );
1335 if( property.Find(
"http:" ) >= 0 )
1337 wxString href =
property.substr( property.Find(
"http:" ) );
1342 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1346 else if( property.Find(
"https:" ) >= 0 )
1348 wxString href =
property.substr( property.Find(
"https:" ) );
1353 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1357 else if( property.Find(
"file:" ) >= 0 )
1359 wxString href =
property.substr( property.Find(
"file:" ) );
1366 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1372 js += wxString::Format( wxT(
"[\"%s\"],\n" ),
1376 else if( url.StartsWith(
"#" ) )
1378 wxString pageNumber = url.AfterFirst(
'#' );
1384 wxString menuText = wxString::Format(
_(
"Show Page %s" ), pageNumber );
1386 js += wxString::Format( wxT(
"[\"%s\", \"#%d\"],\n" ),
1388 static_cast<int>( ii ) );
1393 else if( url.StartsWith(
"http:" ) || url.StartsWith(
"https:" )
1394 || url.StartsWith(
"file:" ) )
1396 wxString href = url;
1401 if( url.StartsWith(
"file:" ) )
1404 wxString menuText = wxString::Format(
_(
"Open %s" ), href );
1406 js += wxString::Format( wxT(
"[\"%s\", \"%s\"],\n" ),
1420 "/Rect [%g %g %g %g]\n"
1421 "/Border [16 16 0]\n",
1425 "/A << /Type /Action /S /JavaScript /JS %s >>\n"
1436function ShM(aEntries) {
1438 for (var i in aEntries) {
1440 cName: aEntries[i][0],
1441 cReturn: aEntries[i][1]
1445 var cChoice = app.popUpMenuEx.apply(app, aParams);
1446 if (cChoice != null && cChoice.substring(0, 1) == '#') this.pageNum = parseInt(cChoice.slice(1));
1447 else if (cChoice != null && cChoice.substring(0, 4) == 'http') app.launchURL(cChoice);
1448 else if (cChoice != null && cChoice.substring(0, 4) == 'file') app.openDoc(cChoice.substring(7));
1455 " [ (JSInit) << /Type /Action /S /JavaScript /JS %s >> ]\n"
1484 time_t ltime = time(
nullptr );
1485 strftime( date_buf, 250,
"D:%Y%m%d%H%M%S", localtime( <ime ) );
1496 "/Producer (KiCad PDF)\n"
1497 "/CreationDate (%s)\n"
1517 if( outlineHandle > 0 )
1524 "/PageMode /UseOutlines\n"
1525 "/Outlines %d 0 R\n"
1527 "/PageLayout /SinglePage\n"
1540 "/PageMode /UseNone\n"
1541 "/PageLayout /SinglePage\n"
1555 "0000000000 65535 f \n", (
long)
m_xrefTable.size() );
1557 for(
unsigned i = 1; i <
m_xrefTable.size(); i++ )
1565 "<< /Size %lu /Root %d 0 R /Info %d 0 R >>\n"
1569 (
unsigned long)
m_xrefTable.size(), catalogHandle, infoDictHandle, xref_start );
1580 const wxString& aText,
1588 bool aMultilineAllowed,
1594 if( aSize.
x == 0 || aSize.
y == 0 )
1602 const char *fontname = aItalic ? ( aBold ?
"/KicadFontBI" :
"/KicadFontI" )
1603 : ( aBold ?
"/KicadFontB" :
"/KicadFont" );
1606 double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f;
1607 double wideningFactor, heightFactor;
1610 bool textMirrored = aSize.
x < 0;
1613 aWidth, aItalic, aBold, &wideningFactor, &ctm_a, &ctm_b, &ctm_c, &ctm_d,
1614 &ctm_e, &ctm_f, &heightFactor );
1619 wxStringTokenizer str_tok( aText,
" ", wxTOKEN_RET_DELIMS );
1647 while( str_tok.HasMoreTokens() )
1649 wxString word = str_tok.GetNextToken();
1653 &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
1658 aBold, aItalic, aFontMetrics ).
x, 0 );
1667 if( word.Trim(
false ).Trim(
true ).empty() )
1674 fprintf(
m_workFile,
"q %f %f %f %f %f %f cm BT %s %g Tf %d Tr %g Tz ",
1675 ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
1676 fontname, heightFactor,
render_mode, wideningFactor * 100 );
1679 fprintf(
m_workFile,
"%s Tj ET\n", txt_pdf.c_str() );
1685 PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
1686 aBold, aMultilineAllowed, aFont, aFontMetrics );
1692 const wxString& aText,
1701 if( size.
x == 0 || size.
y == 0 )
1726 const wxString &aGroupName )
1729 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
const PROJECT * m_project
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
const wxString ResolveUriByEnvVars(const wxString &aUri, const PROJECT *aProject)
Replace any environment and/or text variables in URIs.
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 NormalizeFileUri(const wxString &aFileUri)
Normalize file path aFileUri to URI convention.
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