Print Page | Close Window

Textimport

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=913
Printed Date: 17 May 24 at 3:58AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Textimport
Posted By: KHentschel
Subject: Textimport
Date Posted: 24 Jun 08 at 8:21AM
Hello,
 
i try to convert a Textfile to a PDF File. I do this with DrawTextBox or FitTextBox with a AddStandardFont(0). Everything runs fine, the PDF is created. But how can i keep the formating of Spaces and Tabs?
 
The Textfile looks like this:
 
|***********************************************|
|  Satzart                 :          |         |
|  Versions-Nummer         :          |         |
|  Kunden-Nummer           :          |         |
|  Lieferanten-Nummer      :          |         |
|  Übertragungs-Nummer ALT :          |         |
|  Übertragungs-Nummer NEU :          |         |
|  Übertragungsdatum       :          |         |
|  Ust.IdNr. Empfänger     :          |         |
|  Ust.IdNr. Lieferant     :          |         |
*-----------------------------------------------*
 
the created PDF File looks like this:
 
|***********************************************|
|  Satzart                 :          |         |
|  Versions-Nummer         :          |         |
|  Kunden-Nummer           :        |  |
|  Lieferanten-Nummer      :        |    |
|  Übertragungs-Nummer ALT :          |         |
|  Übertragungs-Nummer NEU :        |  |
|  Übertragungsdatum       :        |         |
|  Ust.IdNr. Empfänger     :        |  |
|  Ust.IdNr. Lieferant     :        |  |
*-----------------------------------------------*
 
i think the DrawText looses the Tabs?!
 
Could anyone can help me in this? Is there a better Function than DrawTextBox or FitTextBox
 
Best regards
 
Klaus Hentschel



Replies:
Posted By: Ingo
Date Posted: 24 Jun 08 at 9:22AM
Hi!

It's the correct font (courier) but it's not enough to add the font.
SelectFont is needed i think.
Hope this helps.

Best regards,
Ingo


Posted By: KHentschel
Date Posted: 24 Jun 08 at 9:34AM

Hi Ingo,

i add the SelectFont into my Programm and also this do not keep the formating. The output was also before (without SelectFont) in Courier.

Thanks
 
Klaus


Posted By: waynefulcher
Date Posted: 24 Jun 08 at 12:24PM
Klaus, I am trying to do the same thing. My program will look for text files in a folder and convert them to pdfs. I can't seem to get it to work. Could you post a code snipit showing how you convert the text file and save it?
 
Thanks
Wayne
 


Posted By: Ingo
Date Posted: 24 Jun 08 at 6:54PM
You can set string (with positions) by string ...
But that's not really a fast way ;-)
DrawHTMLText or DrawHTMLTextBox can be worth to try ... I'm out of office - so only few tips ;-)

Good luck,
Ingo


Posted By: KHentschel
Date Posted: 25 Jun 08 at 3:35AM
Hello Wayne,
 
here is the example. I develop with MS Visual FoxPro
 
lcText = FILETOSTR(GETFILE())
loPDF = CREATEOBJECT("iSED.QuickPDF")
loPDF.UnlockKey('your Code')
lnWidth = FLOOR(loPDF.PAGEWIDTH())
lnHeight = FLOOR(loPDF.PAGEHEIGHT())
loPDF.SetPageSize('A4 Landscape')
lnFontID = loPDF.AddStandardFont(0)
loPDF.SelectFont(lnFontID)
loPDF.FitTextBox(10,lnHeight,lnWidth,lnHeight,lcText,0)
loPDF.SaveToFile(PUTFILE())
RELEASE loPDF
Where is your Problem?
 
Best regards
 
Klaus


Posted By: KHentschel
Date Posted: 25 Jun 08 at 4:03AM

Hi Ingo,

i change the FitTextBox into DrawHTMLTextBox. Now i can not see any Text. What i want is to put plain Text into a PDF, not HTML Text.
 
Best regards
 
Klaus


Posted By: waynefulcher
Date Posted: 30 Jun 08 at 12:23PM
Well one thing to consider if trying to use a horizonal tab character is "where do you specify how many spaces equals one HT?" Unless there is a property for that then I feel like you will need to manually convert the HT to spaces. This is more of a conceptual things for example. At my shop we have several programmers and our code editor used to insert HT into the code but we quickly realized that different programmers had configured their editor to translate a HT into different number of spaces so after one person wrote some code nothing would line up right for another programmer viewing it.
 
Once you get around the HT -> Spaces conversion, then you may experience what I am currently experiencing which is when I draw text to a page, if the text has more than one consecutive space it will remove all but one. So "abc      xyz" gets converted to "abc xyz". I know I encountered this same thing when converting text to XML and back using an XML DOM parser and determined that is the standard in xml conversion so I am assuming the draw text is being ran through some type of conversion and I wonder if I have to URL encode the text first?
I know this will not help much but I can see we are somewhat in the same boat which is trying to figure out how to simply draw text to a PDF and have it match our expectations.
 
wayne
 


Posted By: KHentschel
Date Posted: 01 Jul 08 at 6:34AM
yes Wayne, "we sit in the same boat" :-)
 
as i told you i program with Visual Foxpro. I have to do the following also in my program:
 
- take a plain Textfile with multiple pages (Textfiles have no PageBreak)
- make single Pages
- convert the whole dokument into PDF File
- convert the last Page into PDF File
 
Ok, i have done it know completly in FoxPro. The Spaces are accurate and i have single Pages.
 
Best regards
 
Klaus


Posted By: waynefulcher
Date Posted: 01 Jul 08 at 12:00PM
I finally got mine working as well so for the sake of other readers...
I found that the method FitTextBox will replace multiple spaces with a single space but the method DrawText does not. So as it turned out I had to Draw each line of each page separtely.
 
Now I have another stange thing, one of my Text files works out to be around 3,500 pages. My logic was taking about 5 minutes to convert so I found what was taking so long and now I will post another message to try to get an answer. What I found was if I remove a single line of code which was PDF.SetPageSize('Letter') then it only took about 10 seconds to create the PDF. I call SetPageSize() right after each time I call SelectPage().
 



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