M MroBurk Member Licensed User Jan 16, 2022 #1 Hi, I need help for saving a created pdf into a specific folder, and (the folder) if not exist I need to create... Thanks to any ideas [CODE lang="b4x" title="PanelToPdf"] Private Sub PanelToPdf(Panel As B4XView, FileName As String) Dim pdf As PdfDocument pdf.Initialize pdf.StartPage(595, 842) 'A4 size Dim bmp As B4XBitmap = Panel.Snapshot Dim dest As Rect dest.Initialize(10, 10, 0, 0) dest.Width = bmp.Width / bmp.Scale dest.Height = bmp.Height / bmp.Scale pdf.Canvas.DrawBitmap(bmp, Null, dest) pdf.FinishPage Dim out As OutputStream = File.OpenOutput(provider.SharedFolder, FileName, False) pdf.WriteToStream(out) out.Close pdf.Close Dim in As Intent in.Initialize(in.ACTION_VIEW, "") provider.SetFileUriAsIntentData(in, FileName) in.SetType("application/pdf") StartActivity(in) End Sub[/CODE] Panel to PDF. thanks for any Ideas Attachments 1.zip 1.zip 10.7 KB · Views: 395
Hi, I need help for saving a created pdf into a specific folder, and (the folder) if not exist I need to create... Thanks to any ideas [CODE lang="b4x" title="PanelToPdf"] Private Sub PanelToPdf(Panel As B4XView, FileName As String) Dim pdf As PdfDocument pdf.Initialize pdf.StartPage(595, 842) 'A4 size Dim bmp As B4XBitmap = Panel.Snapshot Dim dest As Rect dest.Initialize(10, 10, 0, 0) dest.Width = bmp.Width / bmp.Scale dest.Height = bmp.Height / bmp.Scale pdf.Canvas.DrawBitmap(bmp, Null, dest) pdf.FinishPage Dim out As OutputStream = File.OpenOutput(provider.SharedFolder, FileName, False) pdf.WriteToStream(out) out.Close pdf.Close Dim in As Intent in.Initialize(in.ACTION_VIEW, "") provider.SetFileUriAsIntentData(in, FileName) in.SetType("application/pdf") StartActivity(in) End Sub[/CODE] Panel to PDF. thanks for any Ideas
Erel B4X founder Staff member Licensed User Longtime User Jan 17, 2022 #2 SaveAs - Let the user select a target folder + list of other related methods Upvote 0
M MroBurk Member Licensed User Jan 17, 2022 #3 Thanks Erel, I tried this code, but it doesn't work with pdf Attachments test.zip test.zip 11.3 KB · Views: 415 Upvote 0
toby Well-Known Member Licensed User Longtime User Jan 18, 2022 #4 What didn't work? Provide details, please. Upvote 0
M MroBurk Member Licensed User Jan 18, 2022 #5 the code allows to save the file, but if you try to open that file, it is damaged.. with *.txt it works very well but it does't work with *.pdf.. you can try yourself with the posted project... Maybe I did anything wrong... Upvote 0
the code allows to save the file, but if you try to open that file, it is damaged.. with *.txt it works very well but it does't work with *.pdf.. you can try yourself with the posted project... Maybe I did anything wrong...
Erel B4X founder Staff member Licensed User Longtime User Jan 18, 2022 #6 Code: Sleep(15000) File.WriteString(File.DirInternal, "1.pdf", "pdf") Wait For (SaveFile(File.OpenInput(File.DirInternal, "1.pdf"), "application/octet-stream", "1.pdf")) Complete (Success As Boolean) Log("File saved successfully? " & Success) 1. You don't this sleep call. 2. The code makes no sense. Code: SaveFile(File.OpenInput(provider.SharedFolder, FileName), "application/pdf", "pdf") Upvote 0
Code: Sleep(15000) File.WriteString(File.DirInternal, "1.pdf", "pdf") Wait For (SaveFile(File.OpenInput(File.DirInternal, "1.pdf"), "application/octet-stream", "1.pdf")) Complete (Success As Boolean) Log("File saved successfully? " & Success) 1. You don't this sleep call. 2. The code makes no sense. Code: SaveFile(File.OpenInput(provider.SharedFolder, FileName), "application/pdf", "pdf")
M MroBurk Member Licensed User Jan 19, 2022 #7 Thank you so much EREL...There is a Course toLearn all this? I want to learn how to develop app and improve myself... thank you again! Upvote 0
Thank you so much EREL...There is a Course toLearn all this? I want to learn how to develop app and improve myself... thank you again!