Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - File Path
  FAQ FAQ  Forum Search   Register Register  Login Login

File Path

 Post Reply Post Reply
Author
Message
mingoal View Drop Down
Beginner
Beginner


Joined: 24 Jan 10
Location: China
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote mingoal Quote  Post ReplyReply Direct Link To This Post Topic: File Path
    Posted: 31 Jan 10 at 10:35AM
Hello everybody!
 
I use QuickPDF to generate pdf, but I find that it does not work as I thought when I pass a string contains characters to functions which need a path as parameter, such as AddImageFromFile(), SavetoFile() etc.
 
For example:
  if(m_docQPDF.AddImageFromFile("C:\Documents and Settings\mingoal\桌面\map.bmp",0) != 0)
{
     AfxMessageBox("Quick PDF Load Image Failed! ");
}
 
 Can somebody help me to solve this promble ,or give me some hints ?
 
Thanks in advance !
 
Mingoal
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 31 Jan 10 at 1:37PM
Hi Mingoal!

The path isn't the problem ... the used characters between "mingoal" and "map" are the problem.
You take the path/file-name as a string but in strings you can't work with chinese characters.
The newest versions of QuickPDF are changed to work with unicode-characters, too.
In delphi something like AddImageFromFile(WideString(Edit1.Text),0) <> 0 could work ...

Cheers, Ingo

Back to Top
mingoal View Drop Down
Beginner
Beginner


Joined: 24 Jan 10
Location: China
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote mingoal Quote  Post ReplyReply Direct Link To This Post Posted: 01 Feb 10 at 12:46AM
Thank you for your reply, I really appreciate it. I will try it again under your help.
 
 Best regards!
  mingoal
Back to Top
mingoal View Drop Down
Beginner
Beginner


Joined: 24 Jan 10
Location: China
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote mingoal Quote  Post ReplyReply Direct Link To This Post Posted: 05 Feb 10 at 12:26PM
   I checked the API reference again, and I found that Quick PDF supports unicode file name, but I need to encode the file name using UTF8. Thus, I use a small function to convert a CString object to UTF8-encoding string. Here are my c++ sample code:

char* CString2UTF8(CString& strSrc)
{
   long  lBufferSize=0; 
   long  lResult =0; 
   long  lSrcLen=0;  
   lSrcLen=  strSrc.GetLength()  ;  
   lBufferSize  =  lSrcLen*  3  +  1  ; 
   //Don't forget to release the buffer
   char  *pCharUtf8  =  new  char[lBufferSize]  ;   
  //Translate  using  code  page  65001(UTF-8).   
  lResult =  WideCharToMultiByte(CP_UTF8,  0,strSrc.AllocSysString(),  lSrcLen,  pCharUtf8, lBufferSize,  NULL,  0)  ;   
   pCharUtf8[lResult ]  =  NULL  ; 
   return pCharUtf8;
}
 Sample:

//strFilePath is a CString object
char *pCharPath=CString2UTF8(strFilePath);
 if(m_docQPDF.SaveToFile(pCharPath) == 0)
 {
  delete [] pCharPath;
  pCharPath=NULL;
  return FALSE;
 }
 delete [] pCharPath;
 pCharPath=NULL;
 
 
 
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store