---
title: "Behålla formatering"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/156656-behålla-formatering"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Zaiman"
published: "2007-02-01T14:03:07.000Z"
updated: "2007-02-01T14:35:24.000Z"
replies: 1
views: 280
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/156656-behålla-formatering"
---

# Behålla formatering

## #1 — Zaiman, 2007-02-01T14:03Z

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

Permalänk: https://www.webforum.nu/p/156656

## #2 — Zaiman, 2007-02-01T14:35Z

Hjärnblödning så klart..

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

Permalänk: https://www.webforum.nu/p/1928555

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/156656-behålla-formatering
