Programming/c# & winform2020. 10. 23. 14:38

예전 MFC 보다 많이 편해진 느낌?

 

 

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    e.Cancel = true;
}

[링크 : https://stackoverflow.com/questions/14943/how-to-disable-alt-f4-closing-form]

'Programming > c# & winform' 카테고리의 다른 글

c# winform picturebox 끼리는 투명 적용 되지 않음  (0) 2020.10.23
자식에서 부모창의 자원 접근하기  (0) 2020.10.23
markdig custom markdown  (0) 2020.10.22
pdfsharp , migradoc  (0) 2020.10.22
itext7  (0) 2020.10.22
Posted by 구차니
Programming/c# & winform2020. 10. 22. 18:24

돌려는 봤는데 어렵네 ㅠㅠ

어떻게 파서를 짜야하려나?

 

[링크 : https://www.cyotek.com/blog/writing-custom-markdig-extensions]

  [링크 : https://www.cyotek.com/downloads/view/MarkdigMantisLink.zip/]

 

[링크 : https://odetocode.com/blogs/scott/archive/2020/01/23/a-custom-renderer-extension-for-markdig.aspx]

 

+ 2020.10.29

원래 구현하고자 하는 것은

[ ]

[x]

을 받으면 HTML의 input type=checkbox 로 변환하는 건데

MantisLink 예제를 따라해보니 [는 걸려지지 않는다.

아무래도 링크로 연관되어 [는 이미 처리되어버리기 때문에 걸러내질 못하는 듯..

 

그러면 github 등에서 어떻게 구현을 해서 쓰고 있는걸까?

'Programming > c# & winform' 카테고리의 다른 글

자식에서 부모창의 자원 접근하기  (0) 2020.10.23
c# winform 자식 다이얼로그에서 F4 막기  (0) 2020.10.23
pdfsharp , migradoc  (0) 2020.10.22
itext7  (0) 2020.10.22
c# pdf itextsharp -> itext7  (0) 2020.10.22
Posted by 구차니
Programming/c# & winform2020. 10. 22. 18:04

MIT license

[링크 : http://www.pdfsharp.net/Licensing.ashx]

 

 

다만 html 을 pdf로 변환하는 기능은 없다고 -_ㅠ

Can I use PDFsharp to convert HTML or RTF to PDF?¶
No, not "out of the box", and we do not plan to write such a converter in the near future.

Yes, PDFsharp with some extra code can do it. But we do not supply that extra code.
On NuGet and other sources you can find a third party library "HTML Renderer for PDF using PdfSharp" that converts HTML to PDF. And there may be other libraries for the same or similar purposes, too. Maybe they work for you, maybe they get you started.

[링크 : https://stackoverflow.com/questions/48759671/convert-html-string-to-pdf-with-migradoc]

 

+

HtmlRenderer.RdfSharp 라는게 가장 위에 나오는데

BSD 3 clause 라이센스..

[링크 : https://archive.codeplex.com/?p=htmlrenderer]

[링크 : https://github.com/ArthurHub/HTML-Renderer]

'Programming > c# & winform' 카테고리의 다른 글

c# winform 자식 다이얼로그에서 F4 막기  (0) 2020.10.23
markdig custom markdown  (0) 2020.10.22
itext7  (0) 2020.10.22
c# pdf itextsharp -> itext7  (0) 2020.10.22
c# print 하기  (0) 2020.10.19
Posted by 구차니
Programming/c# & winform2020. 10. 22. 16:51

HtmlConverter.ConvertToPdf()

는 하나의 HTML을 pdf로 변환하고 close 하기 때문에

merger를 이용해서 합쳐야 하는 듯 하고

 

HtmlConverter.ConvertToDocument()

는 pdf로 변환하지만 ConvertToPdf()와는 다르게 div()를 정상적으로 처리하지 못한다.

 

[링크 : https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-converting-html-to-pdf-with-pdfhtml/chapter-7-frequently-asked-questions-about-pdfhtml/how-to-parse-multiple-html-files-into-one-pdf] java

 

private void button2_Click(object sender, EventArgs e)
        {
            String DEST = "hello_world.pdf";

            FileInfo file = new FileInfo(DEST);
            file.Directory.Create();

            PdfWriter writer = new PdfWriter(DEST);
            PdfDocument pdf = new PdfDocument(writer);
            Document document = new Document(pdf, PageSize.A4.Rotate());
            document.SetMargins(20, 20, 20, 20);
            PdfMerger pdfMerger = new PdfMerger(pdf);

            document.Add(new Paragraph("Hello World!"));

            String[] SRC = {
            @"d:\test1.html",
            @"d:\test2.html",
            @"d:\test3.html",
            @"d:\test4.html" };

            foreach (var html in SRC)
            {
                MemoryStream baos = new MemoryStream();
                PdfDocument temp = new PdfDocument(new PdfWriter(baos));
                temp.SetDefaultPageSize(PageSize.A4.Rotate());
                HtmlConverter.ConvertToPdf(System.IO.File.ReadAllText(html), temp, new ConverterProperties());
                ReaderProperties rp = new ReaderProperties();
                baos = new MemoryStream(baos.ToArray());
                temp = new PdfDocument(new PdfReader(baos, rp));
                pdfMerger.Merge(temp, 1, temp.GetNumberOfPages());
                temp.Close();
            }
            pdfMerger.Close();            
        }

[링크 : https://stackoverflow.com/questions/57415902/generate-one-pdf-document-with-multiple-pages-converting-from-html-using-itext-7] .net

 

pdf 특성상 붙이는 파일의 용지 방향을 지정해 주어야 한다.

[링크 : https://stackoverflow.com/questions/54347293/how-to-set-orientation-to-landscape-in-itext-7]

'Programming > c# & winform' 카테고리의 다른 글

markdig custom markdown  (0) 2020.10.22
pdfsharp , migradoc  (0) 2020.10.22
c# pdf itextsharp -> itext7  (0) 2020.10.22
c# print 하기  (0) 2020.10.19
c# printer 사용하기 - printer enumeration  (0) 2020.10.19
Posted by 구차니
Programming/c# & winform2020. 10. 22. 15:10

iTextSharp

pdf 파일에 직접 내용을 만들어 넣기(Paragraph 등으로)

[링크 : http://www.csharpstudy.com/Practical/Prac-pdf.aspx]

[링크 : https://stackoverflow.com/questions/11307749/creating-multiple-page-pdf-using-itextsharp]

  [링크 : https://www.nuget.org/packages/iTextSharp/]

 

iTextSharp에 HTML 내용을 넣기

[링크 : https://jujun.tistory.com/118]

 

iTextSharp

Docuement.NewPage()

한페이지 추가하기

[링크 : https://stackoverflow.com/questions/4124106/add-a-page-to-pdf-document-using-itextsharp]

 

 

        private void button2_Click(object sender, EventArgs e)
        {

            Document doc = new Document(iTextSharp.text.PageSize.A4);
            PdfWriter wr = PdfWriter.GetInstance(doc, new FileStream("simple.pdf", FileMode.Create));

            doc.Open();

            doc.AddTitle("Simple PDF 생성 예제");
            doc.AddAuthor("Alex");
            doc.AddCreationDate();

            // 영문쓰기
            doc.Add(new Paragraph("English : How are you?"));
            doc.Add(new Paragraph("국문: 어때요?"));

            doc.NewPage();

            StyleSheet styles = new StyleSheet();
            HtmlWorker hw = new HtmlWorker(doc);

            String html_data = System.IO.File.ReadAllText(@"d:\test.html");
            hw.Parse(new StringReader(html_data));

            doc.NewPage();

            String html_data2 = System.IO.File.ReadAllText(@"d:\test2.html");
            hw.Parse(new StringReader(html_data2));

            hw.EndDocument();
            hw.Close();

            doc.Close();
        }

---

 

 

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;

using iText.Html2pdf;
using iText.Html2pdf.Attach.Impl;
using iText.Layout.Font;

        private void button2_Click(object sender, EventArgs e)
        {
            String DEST = "hello_world.pdf";

            FileInfo file = new FileInfo(DEST);
            file.Directory.Create();

            PdfWriter writer = new PdfWriter(DEST);
            PdfDocument pdf = new PdfDocument(writer);
            Document document = new Document(pdf);
            document.Add(new Paragraph("Hello World!"));

            HtmlConverter.ConvertToPdf(new FileStream(@"d:\test2.html", FileMode.Open), pdf);
            document.Close();
        }

[링크 : https://kb.itextpdf.com/home/it7kb/examples/pdfhtml-accessible-pdf-creation]

 

[링크 : https://github.com/itext/itextsharp]

[링크 : https://github.com/itext/itext7-dotnet]

 

+

document.Add(new AreaBreak());

[링크 : https://stackoverflow.com/questions/17198337/how-can-i-make-a-page-break-using-itext]

[링크 : https://www.tutorialspoint.com/itext/itext_adding_areabreak.htm]

 

 

+

ConverToPdf() 메소드는 호출 이후 document를 close() 해버린다고.. -_-

The convertToPdf()/ConvertToPdf() methods create a complete PDF file. Any File, FileInfo, OutputStream, PdfWriter (Java/.NET), or PdfDocument (Java/.NET) that is passed to the convertToPdf()/ConvertToPdf() method is closed once the input is parsed and converted to PDF. This might not always be what you want.

In some cases, you want to add some extra information to the Document(Java/.NET), or maybe you don't want to convert the HTML to a PDF file, but to a series of iText objects you can use for a different purpose. That's what the convertToDocument()/ConvertToDocument() and convertToElements()/ConvertToElements() methods are about.

In the C01E07_HelloWorld.java example, we convert our Hello World HTML to a Document (Java/.NET) because we want to add some extra content after we've done parsing the HTML:

[링크 : https://kb.itextpdf.com/.../itext-7-converting-html-to-pdf-with-pdfhtml/chapter-1-hello-html-to-pdf]

'Programming > c# & winform' 카테고리의 다른 글

pdfsharp , migradoc  (0) 2020.10.22
itext7  (0) 2020.10.22
c# print 하기  (0) 2020.10.19
c# printer 사용하기 - printer enumeration  (0) 2020.10.19
c# dialog dual screen  (0) 2020.10.15
Posted by 구차니
Programming/c# & winform2020. 10. 19. 14:02

 

[링크 : https://stackoverflow.com/questions/6103705/]

[링크 : https://www.nuget.org/packages/PdfiumViewer/] apache 2.0 license

[링크 : https://www.nuget.org/packages/PdfiumViewer.Native.x86_64.v8-xfa/] apache 2.0 license

 

+

[링크 : https://stackoverflow.com/questions/48740924]

 

[링크 : https://stackoverflow.com/questions/57415902]

  [링크 : https://www.nuget.org/packages/HtmlConvert]

  [링크 : https://www.nuget.org/packages/DynamicPDF/]

    [링크 : www.dynamicpdf.com/Merge-PDF-.NET.aspx]

  [링크 : https://www.codeproject.com/Articles/28283/Simple-NET-PDF-Merger] ??

'Programming > c# & winform' 카테고리의 다른 글

itext7  (0) 2020.10.22
c# pdf itextsharp -> itext7  (0) 2020.10.22
c# printer 사용하기 - printer enumeration  (0) 2020.10.19
c# dialog dual screen  (0) 2020.10.15
c# dialog 전체화면  (0) 2020.10.15
Posted by 구차니
Programming/c# & winform2020. 10. 19. 12:36

일단은 프린터 나열부터 시작

        private void button1_Click(object sender, EventArgs e)
        {
            PrintQueue printQueue = null;
            LocalPrintServer localPrintServer = new LocalPrintServer();
            PrintQueueCollection localPrinterCollection = localPrintServer.GetPrintQueues();

            //Console.WriteLine("These are your shared, local print queues:\n\n");

            foreach (PrintQueue printer in localPrinterCollection)
            {
                //Console.WriteLine("\tThe shared printer " + printer.Name + " is located at " + printer.Location + "\n");
                textBox1.Text += printer.Name + "@" + printer.Location + "\r\n";
            }
            //Console.WriteLine("Press enter to continue.");
            //Console.ReadLine();
            //System.Collections.IEnumerator localPrinterEnumerator = localPrinterCollection.GetEnumerator();

        }

 

[링크 : https://docs.microsoft.com/ko-kr/dotnet/desktop/wpf/advanced/how-to-enumerate-a-subset-of-print-queues?view=netframeworkdesktop-4.8]

'Programming > c# & winform' 카테고리의 다른 글

c# pdf itextsharp -> itext7  (0) 2020.10.22
c# print 하기  (0) 2020.10.19
c# dialog dual screen  (0) 2020.10.15
c# dialog 전체화면  (0) 2020.10.15
c# winform / 버튼클릭 이벤트 호출하기  (2) 2020.10.15
Posted by 구차니
Programming/c# & winform2020. 10. 15. 18:24

1번 디스플레이가 0번 스크린으로 인식된다.

 

this.Location = Screen.AllScreens[0].WorkingArea.Location;

[링크 : https://stackoverflow.com/questions/57288060/showing-winforms-on-dual-screen-setup]

 

 

+

물리적으로 가장 왼쪽 부터 하고 싶은 경우에는 어떻게 해야하려나...

'Programming > c# & winform' 카테고리의 다른 글

c# print 하기  (0) 2020.10.19
c# printer 사용하기 - printer enumeration  (0) 2020.10.19
c# dialog 전체화면  (0) 2020.10.15
c# winform / 버튼클릭 이벤트 호출하기  (2) 2020.10.15
c# webBrowser css 적용하기...?  (0) 2020.10.15
Posted by 구차니
Programming/c# & winform2020. 10. 15. 18:23

속성에서 WindowState를

Normal에서 Maximized로 하면 전체 화면 모드로 된다.

 

[링크 : https://stackoverflow.com/questions/505167/]

[링크 : https://stackoverflow.com/questions/2272019/]

[링크 : https://outshine90.tistory.com/entry/폼-FullScreen]

Posted by 구차니
Programming/c# & winform2020. 10. 15. 17:31

InitializeComponent() 직후에 호출하니 안 먹네.. ㅠㅠ

 

Button.PerformClick()

[링크 : https://docs.microsoft.com/ko-kr/dotnet/api/system.windows.forms.button.performclick?view=netcore-3.1]

[링크 : https://iamadeveloper.tistory.com/180]

 

 

+

2020.10.19

번개모양을 누르면 Event로 바뀌는데 거기서 Load에 추가해주면 된다.

 

[링크 : https://docs.microsoft.com/ko-kr/dotnet/api/system.windows.forms.form.load?view=netcore-3.1]

[링크 : https://stackoverflow.com/questions/218732/how-do-i-execute-code-after-a-form-has-loaded]

 

+

다이얼로그 비어있는데 더블 클릭하니 Form1_load() 함수가 생기면서 Load 이벤트가 등록된다.

'Programming > c# & winform' 카테고리의 다른 글

c# dialog dual screen  (0) 2020.10.15
c# dialog 전체화면  (0) 2020.10.15
c# webBrowser css 적용하기...?  (0) 2020.10.15
c# webBrowser control/class IE 버전  (0) 2020.10.15
c# webBrowser + markdig  (0) 2020.10.15
Posted by 구차니