Print Page | Close Window

Writing to Ms Word File

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1924
Printed Date: 26 Nov 24 at 4:10AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Writing to Ms Word File
Posted By: MoneyRan
Subject: Writing to Ms Word File
Date Posted: 11 Aug 11 at 10:59PM
Hi,
 
 In my program I am opening a Word .doc document, using DrawText to write information on it and then save it sing SaveToFile function.
 
When I open the file in MSWord, all the text that I worte is visible, but on the top and bottom, there is some header adn footer information which loks like garbage. Is there any way to remove that or make it invisible?



Replies:
Posted By: Ingo
Date Posted: 12 Aug 11 at 9:48AM
Hi!

A bit curious ;-)
DrawText (and the whole QuickPDF-lib) is made for pdf-creation and
not for word-documents.

Cheers and welcome here,
Ingo



Posted By: MoneyRan
Date Posted: 12 Aug 11 at 2:14PM
Actually, what I am writing in the file is completely HTML. I tried writing it on PDF, but it comes up as HTML code. I looked up the DrawHTMLText, but apparently it does not support all the tags, hence the Word Document. I have been looking in the function reference for a function that will allow me to modify these headers and footers, but nothing yet.


Posted By: AndrewC
Date Posted: 12 Aug 11 at 3:16PM

Can you post a code sample so we can see what you are doing ?  As Ingo mentioned Quick PDF Library does not work with Word Documents.

Could it be that you are using MS Word to save your document to PDF and then using Quick PDF to load the PDF file and add extra text to it ?

Andrew.


Posted By: MoneyRan
Date Posted: 12 Aug 11 at 6:04PM
I want to write a whole User Control to a file. This is what I am doing:
 
Convert the Control to HMTL:
 
Dim SB As New StringBuilder()
        Dim SW As New StringWriter(SB)
        Dim htmlTW As New HtmlTextWriter(SW)
        States1.RenderControl(htmlTW)

        Dim DataGridHtml As String = SB.ToString()
        Dim path As String = ConfigurationManager.AppSettings("appPath").ToString()
        'Dim extension As String = ".html"
        Dim filename As String = "ApplicationConfirmation_" & txtName.Text

Try to print the HTML on a document:

 This is what I had been doing:

'Dim open As Integer = QP.LoadFromFile(path + filename + ".doc")
        'QP.SetOrigin(1)
        'QP.DrawText(10, 100, 400.0, DataGridHtml)   <--- tried DrawHTMLText for PDF file
        'Dim save As Integer = QP.SaveToFile(path + filename + ".doc")


 This is what I started doing and works perfectly:

Dim writer As StreamWriter
        writer = File.CreateText(path + filename + ".html")
        writer.WriteLine(DataGridHtml)
        writer.Close() 

QuickPDf wrote HTML perfectly to an MS Word document along with some garbage Headers and Footers.
But since the HTML had table tags and everything in it, it did not write properly to a PDF file.
I just need to create a file, regardless of the application type. I have been using QuickPDf in other parts of my application,
so I wanted to stick to PDF file. But I had to change it.  Still, if there is any way to modify those headers,  I will appreciate some idea of how to go about doing it.



Posted By: Ingo
Date Posted: 12 Aug 11 at 8:51PM
Again:
QuickPDF is for pdf not for html or doc.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk