Well, of course you should be able to use wxDC::DrawRectangle. In my previous post I wrote that the problem seems to be a scaling problem, and I'm pretty sure that scaling is the key to the solution.
Can you tell me the values of pageSzMM.x and pageSzMM.y, please?mael15 wrote: ↑Fri Sep 17, 2021 12:50 pm I use this code:Code: Select all
wxPdfDocument pdfDcmt; pdfDcmt.SetCompression(false); ... pdfDcmt.AddPage(orient, papSize); int tpl = pdfDcmt.BeginTemplate(); dc = new wxPdfDC(&pdfDcmt, pageSzMM.x, pageSzMM.y); dc->SetResolution(600);
Most likely the call SetResolution is responsible for the observed behaviour. wxPdfDC calculates internally a pattern size and it seems that the resolution is not taken into account correctly.
In fact, the rectangle is not filled with a solid color. You will see that if you display the PDF document in a PDF viewer and set the magnification factor to 800%, for example. You will see that the rectangle is hatched as requested.mael15 wrote: ↑Fri Sep 17, 2021 12:50 pm and deep within printToDCthat results in the attached pdf with only a solid blue rectangle.Code: Select all
dc.SetPen(ecBlue); dc.SetBrush(wxBrush(ecBlue, wxBRUSHSTYLE_BDIAGONAL_HATCH)); dc.DrawRectangle(pnt, sz);
As said the problem is the scaling. I will have to check the way how wxPdfDC calculates the pattern size. Most likely the calculation has to be changed to take the resolution into account somehow. However, I think we are already quite close to a working solution.
Hm, at least in the PDF document you attached I see no trace at all of this rectangle with "hatch1" pattern.mael15 wrote: ↑Fri Sep 17, 2021 12:50 pm I also tried it like in the minimal example withbut nothing shows up on the page.Code: Select all
pdf.AddPattern(wxS("hatch1"), wxPDF_PATTERNSTYLE_BDIAGONAL_HATCH, 1, 1, wxColour(224, 0, 0)); pdf.SetFillPattern(wxS("hatch1")); pdf.Rect(25, 30, 25, 25, wxPDF_STYLE_FILLDRAW);