We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ROTATION and TRANSPARENCY problem with aspose.pdf .net

Hello. I am trying to make yellow stripe and a blue stripe all the way down my page. On TOP of that I need to make varying rows of text (I cannot use tables because I need precise positioning). Every other line of text should be rotated. I used the sample code below to show two problem. Problem one is that rotating the text causes alignment and sizing problems (denoted in the code). The second is that the background color of the text ends up BLACK instead of showing whatever was underneath. Are these fixable problems? Any help is appreciated!!!

mat185974958.pdf (30.3 KB)

Private Sub pdftry()
Dim rnd As New Random
Dim d As New Aspose.Pdf.Document() 'create new document
Dim p As Aspose.Pdf.Page
p = d.Pages.Add() 'add page 1

    p.SetPageSize(3 * 72, 3 * 72) 'set page to 3x3 "


    Dim g1 As Aspose.Pdf.Drawing.Graph
    Dim r As Aspose.Pdf.Drawing.Rectangle
    Dim t As Aspose.Pdf.Text.TextFragment


    p.PageInfo.Margin = New Aspose.Pdf.MarginInfo(0, 0, 0, 0) ' margins to 0


    g1 = New Aspose.Pdf.Drawing.Graph(72, 2 * 72) 'build a 1"x2" graph to work in
    g1.IsChangePosition = False
    g1.GraphInfo.RotationAngle = 0
    g1.Left = 0
    g1.Top = 0
    g1.Border = New BorderInfo(BorderSide.All) 'put a border so we can see what's going on

    '''' here we draw a blue stripe and a yellow stripe. We want the text to eventually be on top of these stripes
    'draw yellow 
    r = New Aspose.Pdf.Drawing.Rectangle(0, 0, 36, 3 * 72) 'build a yellow rectangle that takes up the first 1/2" of our graphics area
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Yellow
    g1.Shapes.Add(r)
    'draw blue
    r = New Aspose.Pdf.Drawing.Rectangle(36, 0, 36, 3 * 72) 'build a blue rectangle that takes up the second 1/2" of our graphics area
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Blue
    g1.Shapes.Add(r)


    'no start building the text lines (Eventually these lines will go all the way from top to bottom....but for now there are only 4 lines needed
    'in theory every other line needs to be rotated 180 degrees

    'prep text  1 -- zero rotation
    r = New Aspose.Pdf.Drawing.Rectangle(0, 0, 72, 7)
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
    t = New Aspose.Pdf.Text.TextFragment("ABC")
    t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
    t.TextState.ForegroundColor = Aspose.Pdf.Color.Blue
    t.TextState.FontSize = 7
    r.Text = t
    g1.Shapes.Add(r)


    'prep text 2 -- 180 rotation -- note that in the results, the text is in the wrong place and is truncated
    r = New Aspose.Pdf.Drawing.Rectangle(0, 7, 72, 7)
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
    t = New Aspose.Pdf.Text.TextFragment("DEF")
    t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
    t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
    t.TextState.FontSize = 7
    t.TextState.Rotation = 180
    r.Text = t
    g1.Shapes.Add(r)


    'prep text 3 -- zero rotation
    r = New Aspose.Pdf.Drawing.Rectangle(0, 14, 72, 7)
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
    t = New Aspose.Pdf.Text.TextFragment("GHI")
    t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
    t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
    t.TextState.FontSize = 7
    t.TextState.Rotation = 0
    r.Text = t
    g1.Shapes.Add(r)


    'prep text 4 -- 180 rotation -- note that the only way to fix the problem from line #2 was making the HEIGHT of the rectangle bigger (Which makes no sense, and messes up the alignment)
    r = New Aspose.Pdf.Drawing.Rectangle(0, 21, 72, 7 * 3)
    r.GraphInfo.FillColor = Aspose.Pdf.Color.Empty
    t = New Aspose.Pdf.Text.TextFragment("JKL")
    t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty
    t.TextState.ForegroundColor = Aspose.Pdf.Color.Red
    t.TextState.FontSize = 7
    t.TextState.Rotation = 180
    r.Text = t
    g1.Shapes.Add(r)


    ' ----- also note that the background of the text is not transparent (thus showing the blue/yellow below) but is instead BLACK.
    p.Paragraphs.Add(g1)



    d.Save("c:\test\mat" & rnd.Next & ".pdf")

End Sub

@matucla,
Please do not set the background color of a text fragment to empty, it will resolve the problem of transparency.

[VB]

' problematic line of code
t.TextState.BackgroundColor = Aspose.Pdf.Color.Empty

We managed to replicate the problem of displaced text and truncation in our environment. It has been logged under the ticket ID PDFNET-43154 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.

Best Regards,
Imran Rafique

Thank you for the first part of the fix. I will try it today. And thank you for continuing to research the other portion!

I have tested not setting the Backgroundcolor and that worked perfectly. I look forward to more info on the rotated text problems. Thank you!

@matucla,
Thank you for the confirmation. We will notify you once the ticket PDFNET-43154 will be resolved.

Best Regards,
Imran Rafique

Hello. Do you have any idea WHEN this might be addressed? Thank you.

@matucla,
The linked ticket ID PDFNET-43154 is pending for the analysis and not resolved yet. It is difficult for us to share an estimate before the completion of the analysis phase. We have logged an ETA request under the same ticket ID PDFNET-43154. We will let you know once a significant progress has been made in this regard.

Best Regards,
Imran Rafique