webForumDet fria alternativet

Behålla formatering

.NET

1 svar · 274 visningar · startad av Zaiman

Medlem sedan dec. 20014 239 inlägg
Frågan#1

Håller på med lite gammalt skräp :r

Har en textfil som läses in och med hjälp av abcpdf skapas ett pdf dokument.

Men formateringen ifrån textfilen försvinner när pdf dokumentet skapas.

        private void addText()
        {
            string s = "";
            Doc theDoc = new Doc();
            double w = theDoc.MediaBox.Width;
            double h = theDoc.MediaBox.Height;
            double l = theDoc.MediaBox.Left;
            double b = theDoc.MediaBox.Bottom;
            theDoc.Transform.Rotate(90, l, b);
            theDoc.Transform.Translate(w, 0);

            // rotate our rectangle
            theDoc.Rect.Width = h;
            theDoc.Rect.Height = w;

    
            //theDoc.Width = 4;
            theDoc.Rect.Inset(20, 20);
            theDoc.Font = theDoc.AddFont("Arial");
            theDoc.FontSize = 8;
            theDoc.TextStyle.Justification = 1;
            theDoc.Color.String = "255 0 0";
            theDoc.VPos = 0;
            theDoc.HPos = 0.5;
            using (TextReader rd = new StreamReader("C:\\PDF\\temp.txt", System.Text.Encoding.Default , false))
            {
                while ((s = rd.ReadLine()) != null)
                {

                    s += "\r\n";
                    theDoc.AddText(s);

                }
            }
            
            
            theDoc.Save("C:\\PDF\\test2.pdf");
            theDoc.Clear();
        }

Någon med nån bra idé... Har totalt hjärnsläpp idag verkar det som :birp

Medlem sedan dec. 20014 239 inlägg
#2

Hjärnblödning så klart..

Rätt font så fixade det sig...

256 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
122 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)