2023-01-03 08:48 PM
2023-01-04 04:37 PM
How create and store a correct pdf file with fatfs
2023-01-04 07:49 PM
Using FATS (file handling commands) of STM32 MCU.
f_open(&myFile, "TEST.TXT", FA_WRITE |FA_OPEN_APPEND);//for text files
f_open(&myFile, "TEST.pdf", FA_WRITE |FA_OPEN_APPEND);//for PDF files
.pdf get created in my connected pen drive but when i try to open that file it show format of file is not correct.
2023-01-04 11:18 PM
Do you realise that PDF is a special file format to make documents to be printed always look identical, regardless of the printer?
To create PDF, you would need quite complex special software, which is much more extensive than the memory available in the STM32. For this reason, it is probably not possible to create PDFs on an STM32 in a meaningful way.
Regards
/Peter
2023-01-05 06:17 AM
Hello @KSing.8
To create a project using FatFs in STM32 with CubeMX, follow these steps:
Thx
Ghofrane
2023-01-05 07:50 PM
Hi @Ghofrane GSOURI
I have already followed the above mentioned steps but i am not able to create a PDF file using f_open command.
Thanks
Karanvir Singh
2023-01-05 11:18 PM
Hello @KSing.8 (Community Member)
It's possible that the issue is with the file name or access mode that you are using with the f_open function. Make sure that you are specifying the correct file name, including the ".pdf" extension, and that you are using the correct access mode.
For example, to create a new PDF file with read-write access, you can use the following code:
FIL file;
FRESULT result;
result = f_open(&file, "myfile.pdf", FA_CREATE_ALWAYS | FA_WRITE);
if (result != FR_OK) {
// an error occurred, check the error code (f_err)
}
Keep in mind that the FatFs library uses 8.3 file naming conventions, so the maximum length of the file name (excluding the extension) is 8 characters.
Thx
Ghofrane
2023-01-05 11:47 PM
@KSing.8 Before we continue to talk past each other, please explain what data you actually write in the file TEST.pdf?
As mentioned above, a PDF file does not contain text, but a binary structure that has been standardised as ISO32000. You had also written earlier:
Using FATS (file handling commands) of STM32 MCU
[...] f_open(&myFile, "TEST.pdf", [...]
.pdf get created in my connected pen drive
so that the file is obviously also created. You can also call this file TEST.exe or TEST.odf, but this does not make it an executable Windows program or an OpenDocument for e.g. LibreOffice.
If you want to create a real PDF, you must also write the appropriate data into the file.
Regards
/Peter
2023-01-06 10:35 PM
@Peter BENSCH "If you want to create a real PDF, you must also write the appropriate data into the file."
So i am looking for way to to convert my data lets say any string into data that further gets stored in pdf file and shows my string.Is there any possible way for this..
Thanks
Karanvir Singh
2023-01-08 04:58 PM
https://www.microchip.com/forums/m956973.aspx
Anyway, that is not a task for an absolute beginners...