PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Missing text when printed over coloured rectangle https://forum.pdfsharp.net/viewtopic.php?f=3&t=4231 |
Page 1 of 1 |
Author: | nsanderson [ Fri Feb 05, 2021 1:09 pm ] | ||
Post subject: | Missing text when printed over coloured rectangle | ||
Hi, Been having an issue with PDFSharp printing text in the same colour as a coloured rectangle. The concern is it doesn't happen all the time! We're producing a set of blocks to represent items on a shelf. There seems to be an intermittent problem with the text (which should ALWAYS be black) . (pdfGraphics.DrawString(sTextBox, xFont, XBrushes.Black, dblX, dblY)) However, if you look for product 73 on the attached image (that's specifying explicitly a black brush) you'll see the rectangle but the text is the same colour as the rectangle (end of shelf 7). Other items are printing correctly using the same method in a loop (see shelf 55) Is this a known bug? I've seen various fixes on the internet, mainly mentioning earlier versions of PDFSharp, and have tried some of the workarounds involving resetting the XGraphics object after outputting any graphics, but nothing seems to resolve the problem. We're using v1.51.5185.0 Thanks for any help.
|
Author: | TH-Soft [ Fri Feb 05, 2021 3:32 pm ] |
Post subject: | Re: Missing text when printed over coloured rectangle |
nsanderson wrote: Is this a known bug? Is it a bug?"Not repro" with just a screenshot. |
Author: | nsanderson [ Fri Feb 05, 2021 3:49 pm ] |
Post subject: | Re: Missing text when printed over coloured rectangle |
This is the code - I've removed the rectangle output as that seems to be working fine: ' Attempt to paint product rectangles onto the frontview Private Function ExportProductsFrontView(ByVal lSectionID As Long, ByVal SectionFrontViewRight As Single, ByVal SectionFrontViewX As Single, lastIndex As Long) As Long Dim SupportFrontViewWidth As Single = modGlobals.Value.Zero ' Valid NEW or EXISTING planogram item id Dim lastProductNumber As Long = 0 Dim lCurrentProductIndex As Long = lastIndex Dim lRetVal As Long Try If modManagement.ValidID(lSectionID) Then Dim thisSupport As New clsSectionSupport thisSupport = FindSupportOnSection(lSectionID) Dim dblBoxRight As Double = 0 Dim dblTextLeft As Double = 0 ' Draw products on the FrontView that do not overlap For Each oProduct In oExportPlanogram.Products.Where(Function(product) product.SectionID = lSectionID) '--- If we change product number, increment the index and update the current product number --- If oProduct.ProductID <> lastProductNumber Then lastProductNumber = oProduct.ProductID lCurrentProductIndex += 1 End If '--- Draw the product index number in a box And put it in the bottom left of the product --- Call modExportPlanogramSharp.TextOut(CInt(oProduct.FrontViewX) + 1, CInt(oProduct.FrontViewBottom) - 1, lCurrentProductIndex.ToString, 3) Next ' Product End If Catch ex As Exception Throw New Exception(Reflection.MethodBase.GetCurrentMethod.Name & " : " & ex.Message) End Try Return lCurrentProductIndex End Function ' ExportProductsFrontView Inside a module called modExportPlanogramSharp, there's the text out method: Friend Sub TextOut(dblX As Double, dblY As Double, sTextBox As String, Optional dblFontSize As Double = EXPORT_FONT_SIZE, Optional bBold As Boolean = False, Optional bItalic As Boolean = False, Optional bUnderline As Boolean = False, Optional bStrikeOut As Boolean = False) Try With pdfExportDocument Dim objStyle As Object = GetFontStyle(bBold, bItalic, bUnderline, bStrikeOut) Dim xFont As XFont = New XFont(EXPORT_FONT_NAME, dblFontSize, DirectCast(objStyle, XFontStyle)) pdfGraphics.DrawString(sTextBox, xFont, XBrushes.Black, dblX, dblY) End With Catch ex As Exception Call WriteErrorLogAndShowMessage(Reflection.MethodBase.GetCurrentMethod.Name, Err.Number, "MESSAGE_000XXX", "Did not draw textout.", ex.Message) End Try End Sub A product record is included in the attachment. Hopefully you can see that this is printing a black string into the PDF for every item in the list of products (~540) Sometimes, that XBrushes.Black is green or grey. I tried attaching the PDF but it only seems to accept images? |
Author: | nsanderson [ Fri Feb 05, 2021 3:55 pm ] |
Post subject: | Re: Missing text when printed over coloured rectangle |
A slightly closer view of the problem where I've highlighted the hidden text (73) You can CTL+C CTRL+V the text into Notepad and it's there - it's just the wrong colour in the PDF output. Attachment: OverflowingProduct3.PNG [ 1.56 KiB | Viewed 18298 times ] |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |